Improve build tool
This commit is contained in:
@@ -7,15 +7,6 @@ int main(int argument_count, char **arguments) {
|
|||||||
IO_Printf("WORKING DIR: %.*s\n", S8_Expand(working_dir));
|
IO_Printf("WORKING DIR: %.*s\n", S8_Expand(working_dir));
|
||||||
|
|
||||||
Array<S8_String> cmd = CMD_Make(arguments, argument_count);
|
Array<S8_String> cmd = CMD_Make(arguments, argument_count);
|
||||||
if (CMD_Match(cmd, "clear_cache")) {
|
|
||||||
for (OS_FileIter it = OS_IterateFiles(Perm, "./"); OS_IsValid(it); OS_Advance(&it)) {
|
|
||||||
if (!it.is_directory && S8_EndsWith(it.filename, ".cache", true)) {
|
|
||||||
OS_DeleteFile(it.absolute_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("gcc"));
|
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("gcc"));
|
||||||
|
|
||||||
// Search for build file in the project directory
|
// Search for build file in the project directory
|
||||||
@@ -31,7 +22,6 @@ int main(int argument_count, char **arguments) {
|
|||||||
IO_Printf("Couldnt find build file in current dir: %.*s, exiting ... \n", S8_Expand(working_dir));
|
IO_Printf("Couldnt find build file in current dir: %.*s, exiting ... \n", S8_Expand(working_dir));
|
||||||
IO_Printf("- Proper build file contains 'build_file.c' in it's name\n");
|
IO_Printf("- Proper build file contains 'build_file.c' in it's name\n");
|
||||||
IO_Printf("- Alternative compiler can be chosen like this: bld cc=clang\n");
|
IO_Printf("- Alternative compiler can be chosen like this: bld cc=clang\n");
|
||||||
IO_Printf("- Cache can be cleared like this: bld clear_cache\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,10 +38,9 @@ int main(int argument_count, char **arguments) {
|
|||||||
Array<S8_String> flags = {Perm};
|
Array<S8_String> flags = {Perm};
|
||||||
flags += "-nologo -Zi";
|
flags += "-nologo -Zi";
|
||||||
flags += "-WX -W3 -wd4200 -diagnostics:column";
|
flags += "-WX -W3 -wd4200 -diagnostics:column";
|
||||||
flags += Fmt("/Fe:%.*s", S8_Expand(exe_name));
|
flags += Fmt("/Fe:%.*s /Fd:%.*s.pdb", S8_Expand(exe_name), S8_Expand(exe_name));
|
||||||
result = Run(cc + build_file + flags);
|
result = Run(cc + build_file + flags);
|
||||||
}
|
} else if (cc == "clang") {
|
||||||
else if (cc == "clang") {
|
|
||||||
Array<S8_String> flags = {Perm};
|
Array<S8_String> flags = {Perm};
|
||||||
flags += "-std=c++11 -g";
|
flags += "-std=c++11 -g";
|
||||||
flags += "-fdiagnostics-absolute-paths";
|
flags += "-fdiagnostics-absolute-paths";
|
||||||
@@ -61,8 +50,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
flags += "-lm";
|
flags += "-lm";
|
||||||
flags += Fmt("-o %.*s", S8_Expand(exe_name));
|
flags += Fmt("-o %.*s", S8_Expand(exe_name));
|
||||||
result = Run(cc + build_file + flags);
|
result = Run(cc + build_file + flags);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
IO_Assert(cc == "gcc");
|
IO_Assert(cc == "gcc");
|
||||||
|
|
||||||
Array<S8_String> flags = {Perm};
|
Array<S8_String> flags = {Perm};
|
||||||
@@ -77,6 +65,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
IO_Printf("FAILED compilation of the build file!\n");
|
IO_Printf("FAILED compilation of the build file!\n");
|
||||||
|
OS_DeleteFile("build_tool.cache");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
time = OS_GetTime() - time;
|
time = OS_GetTime() - time;
|
||||||
@@ -90,6 +79,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
int result = Run(exe_name + cmd);
|
int result = Run(exe_name + cmd);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
IO_Printf("FAILED execution of the build file!\n");
|
IO_Printf("FAILED execution of the build file!\n");
|
||||||
|
OS_DeleteFile("build_tool.cache");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user