Improve build tool api, cleanup pass, add lexer tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
#define BUILD_MAIN
|
||||
#include "library.cpp"
|
||||
|
||||
int main(int argument_count, char **arguments) {
|
||||
@@ -7,21 +6,17 @@ int main(int argument_count, char **arguments) {
|
||||
S8_String working_dir = OS_GetWorkingDir(Perm);
|
||||
IO_Printf("WORKING DIR: %.*s\n", S8_Expand(working_dir));
|
||||
|
||||
S8_String cc = ON_WINDOWS("cl"_s) ON_MAC("clang"_s) ON_LINUX("gcc"_s);
|
||||
S8_String cache_filename = "build_tool.cache"_s;
|
||||
|
||||
S8_String cmdline_args = S8_MakeEmpty();
|
||||
for (int i = 1; i < argument_count; i += 1) {
|
||||
S8_String arg = S8_MakeFromChar(arguments[i]);
|
||||
if (arg == "clear_cache"_s) {
|
||||
OS_DeleteFile(cache_filename);
|
||||
break;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
cmdline_args = S8_Format(Perm, "%.*s%.*s ", S8_Expand(cmdline_args), S8_Expand(arg));
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRC_InitCache(Perm, cache_filename);
|
||||
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("gcc"));
|
||||
|
||||
// Search for build file in the project directory
|
||||
S8_String build_file = {};
|
||||
@@ -38,6 +33,7 @@ int main(int argument_count, char **arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
SRC_CacheScope("build_tool.cache");
|
||||
S8_String name_no_ext = S8_GetNameNoExt(build_file);
|
||||
S8_String exe_name = S8_Format(Perm, "%.*s.exe", S8_Expand(name_no_ext));
|
||||
|
||||
@@ -45,14 +41,14 @@ int main(int argument_count, char **arguments) {
|
||||
if (SRC_WasModified(build_file, exe_name)) {
|
||||
double time = OS_GetTime();
|
||||
int result = 0;
|
||||
if (cc == "cl"_s) {
|
||||
if (cc == "cl") {
|
||||
result = OS_SystemF("cl %.*s -Fe:%.*s -WX -W3 -wd4200 -diagnostics:column -nologo -Zi", S8_Expand(build_file), S8_Expand(exe_name));
|
||||
}
|
||||
else if (cc == "clang"_s) {
|
||||
else if (cc == "clang") {
|
||||
result = OS_SystemF("clang++ -std=c++11 -fdiagnostics-absolute-paths -Wno-writable-strings %.*s -o %.*s -g", S8_Expand(build_file), S8_Expand(exe_name));
|
||||
}
|
||||
else {
|
||||
IO_Assert(cc == "gcc"_s);
|
||||
IO_Assert(cc == "gcc");
|
||||
result = OS_SystemF("gcc -Wno-write-strings %.*s -o %.*s -g", S8_Expand(build_file), S8_Expand(exe_name));
|
||||
}
|
||||
|
||||
@@ -64,6 +60,8 @@ int main(int argument_count, char **arguments) {
|
||||
IO_Printf("TIME Build file compilation: %f\n", time);
|
||||
}
|
||||
|
||||
S8_String cmdline_args = Merge(cmd);
|
||||
|
||||
// Run the build file
|
||||
double time = OS_GetTime();
|
||||
if (build_file.str) {
|
||||
@@ -75,7 +73,4 @@ int main(int argument_count, char **arguments) {
|
||||
}
|
||||
time = OS_GetTime() - time;
|
||||
IO_Printf("TIME total build file execution: %f\n", time);
|
||||
|
||||
SRC_SaveCache();
|
||||
// OS_SetWorkingDir(S8_Lit(".."));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user