commit 18c91b7371cc0b7b20e0c1c3ba736e6706b4aa81
parent d0a7efd3a0d314a257fcffaaac4f197c4270d7ee
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 27 Dec 2019 13:16:03 +0100
store intermediary object files for normal, test and memcheck builds in different folder
The test folder has the same path as the normal build (sheepy -e shows
the build path) with 'Test' appended at the end.
The memcheck folder has the same path as the normal build with
'Memcheck'
appended at the end.
The tests run faster because the object files are reused and the tests
can be run in parallel.
src/sheepy.c | 43 ++++++++++++++++++++++++++++++++++++++-----
src/spm.c | 39 +++++++++++++++++++++------------------
2 files changed, 59 insertions(+), 23 deletions(-)
Diffstat:
| M | src/sheepy.c | | | 43 | ++++++++++++++++++++++++++++++++++++++----- |
| M | src/spm.c | | | 39 | +++++++++++++++++++++------------------ |
2 files changed, 59 insertions(+), 23 deletions(-)
diff --git a/src/sheepy.c b/src/sheepy.c
@@ -679,7 +679,40 @@ int MAIN(int ARGC, char** ARGV) {
actualDir = shDirname(actualpath);
//logVarG(actualDir);
- char *buildPath = catS(homedir, "build", actualDir);
+ char *buildPath;
+
+ if (sheepyParams.test) {
+ buildPath = catS(homedir, "build", actualDir, "Test");
+ }
+ else if (sheepyParams.memcheck) {
+ buildPath = catS(homedir, "build", actualDir, "Memcheck");
+ }
+ else {
+ // compile, run or clean
+ buildPath = catS(homedir, "build", actualDir);
+ if (sheepyParams.clean) {
+ // delete test build folders: test, memcheck...
+ dum = catS(homedir, "build", actualDir, "Test");
+ if (isDir(dum)) {
+ if (getG(cfgD, rtBool, "print_compile_commands")) {
+ printf("rm -rf %s", dum);
+ printf("\n");
+ }
+ rmAll(dum);
+ }
+ free(dum);
+ dum = catS(homedir, "build", actualDir, "Memcheck");
+ if (isDir(dum)) {
+ if (getG(cfgD, rtBool, "print_compile_commands")) {
+ printf("rm -rf %s", dum);
+ printf("\n");
+ }
+ rmAll(dum);
+ }
+ free(dum);
+ }
+ }
+
char *buildExePath = catS(buildPath, "/", rootMain);
//logVarG(buildPath);
@@ -2065,20 +2098,20 @@ int MAIN(int ARGC, char** ARGV) {
copy(buildExePath, exePath);
if (!sheepyParams.clean) {
if (programResult) {
- dum = BLD UDL BGYLW RED"Failed to build Executable:"RST" %s";
+ dum = BLD UDL BGYLW RED"Failed to build Executable:"RST" %s\n";
}
else {
- dum = BLD GRN"Built Executable:"RST" %s";
+ dum = BLD GRN"Built Executable:"RST" %s\n";
}
printf(dum, exePath);
}
}
if (getG(cfgD, rtBool, "print_compile_commands") && !isEmptyS(run) && !sheepyParams.clean) {
if (programResult) {
- dum = BLD UDL BGYLW RED"Failed to build Executable:"RST" %s";
+ dum = BLD UDL BGYLW RED"Failed to build Executable:"RST" %s\n";
}
else {
- dum = BLD GRN"Built Executable:"RST" %s";
+ dum = BLD GRN"Built Executable:"RST" %s\n";
}
printf(dum, buildExePath);
}
diff --git a/src/spm.c b/src/spm.c
@@ -1299,11 +1299,9 @@ int testPackage(smallDictt *cfgD, smallDictt *packageyml) {
if (hasG(packageyml, "testBin")) {
char *bin = getNDupG(packageyml, rtChar, "testBin");
- // delete intermediary files
- if (getG(cfgD, rtBool, "print_compile_commands")) {
- printf("sheepy -d %s\n", bin);
- }
- systemf("sheepy -d %s", bin);
+ // dont need to delete intermediary files because the test is compiled in a seperate folder
+ // (delete intermediary files)
+
// compile test
if (getG(cfgD, rtBool, "print_compile_commands")) {
printf("sheepy -t %s\n", bin);
@@ -1322,11 +1320,14 @@ int testPackage(smallDictt *cfgD, smallDictt *packageyml) {
}
exitCode = command(bin);;
- if (getG(cfgD, rtBool, "print_compile_commands")) {
- printf("sheepy -d %s\n", getG(packageyml, rtChar, "testBin"));
- }
- systemf("sheepy -d %s", getG(packageyml, rtChar, "testBin"));
+ if (getG(cfgD, rtBool, "clean_exe")) {
+ if (getG(cfgD, rtBool, "print_compile_commands")) {
+ printf("rm %s", bin);
+ printf("\n");
+ }
+ rmAll(bin);
}
+ }
return(exitCode);
}
@@ -1362,11 +1363,9 @@ void memcheckPackage(smallDictt *cfgD, smallDictt *packageyml) {
return;
}
- // delete intermediary files
- if (getG(cfgD, rtBool, "print_compile_commands")) {
- printf("sheepy -d %s\n", bin);
- }
- systemf("sheepy -d %s", bin);
+ // dont need to delete intermediary files because the test is compiled in a seperate folder
+ // (delete intermediary files)
+
// compile test
if (getG(cfgD, rtBool, "print_compile_commands")) {
printf("sheepy -m %s\n", bin);
@@ -1387,12 +1386,16 @@ void memcheckPackage(smallDictt *cfgD, smallDictt *packageyml) {
}
systemf("%s ; %s %s\n", bin, mcheckCmd, bin);
- if (getG(cfgD, rtBool, "print_compile_commands")) {
- printf("sheepy -d %s\n", getG(packageyml, rtChar, "memcheckBin"));
- }
- systemf("sheepy -d %s", getG(packageyml, rtChar, "memcheckBin"));
+
+ if (getG(cfgD, rtBool, "clean_exe")) {
+ if (getG(cfgD, rtBool, "print_compile_commands")) {
+ printf("rm %s", bin);
+ printf("\n");
+ }
+ rmAll(bin);
}
}
+ }
void listAllPackages(smallDictt *cfgD, smallArrayt *options) {