Porting bld to linux
This commit is contained in:
28
bld_main.cpp
28
bld_main.cpp
@@ -6,6 +6,14 @@ int main(int argument_count, char **arguments) {
|
||||
OS_SetWorkingDir(S8_Lit("build"));
|
||||
IO_Printf("WORKING DIR: %Q\n", OS_GetWorkingDir(Perm));
|
||||
|
||||
#if OS_LINUX
|
||||
S8_String cc = "gcc"_s;
|
||||
#elif OS_WINDOWS
|
||||
S8_String cc = "cl"_s;
|
||||
#else
|
||||
S8_String cc = "clang"_s;
|
||||
#endif
|
||||
|
||||
for (int i = 1; i < argument_count; i += 1) {
|
||||
S8_String arg = S8_MakeFromChar(arguments[i]);
|
||||
if (arg == "clear_cache"_s) OS_DeleteFile("bld.cache"_s);
|
||||
@@ -18,7 +26,7 @@ int main(int argument_count, char **arguments) {
|
||||
{
|
||||
S8_List files_current_dir = OS_ListDir(Perm, S8_Lit(".."), 0);
|
||||
for (S8_Node *it = files_current_dir.first; it; it = it->next) {
|
||||
if (S8_Find(it->string, S8_Lit("build.c"), S8_IGNORE_CASE, 0)) {
|
||||
if (S8_Find(it->string, S8_Lit("bld_file.c"), S8_IGNORE_CASE, 0)) {
|
||||
build_file = it->string;
|
||||
}
|
||||
}
|
||||
@@ -37,8 +45,18 @@ int main(int argument_count, char **arguments) {
|
||||
// Compile the build file only if code changed
|
||||
if (SRC_WasModified(build_file)) {
|
||||
double time = OS_GetTime();
|
||||
S8_String f = S8_Lit("-WX -W3 -wd4200 -diagnostics:column -nologo -Zi");
|
||||
int result = OS_SystemF("cl %Q %Q -Fe:%Q ", build_file, f, exe_name);
|
||||
int result = 0;
|
||||
if (cc == "cl"_s) {
|
||||
result = OS_SystemF("cl %Q -Fe:%Q -WX -W3 -wd4200 -diagnostics:column -nologo -Zi", build_file, exe_name);
|
||||
}
|
||||
else if (cc == "clang"_s) {
|
||||
result = OS_SystemF("clang -Wno-writable-strings %Q -o %Q -g", build_file, exe_name);
|
||||
}
|
||||
else {
|
||||
IO_Assert(cc == "gcc"_s);
|
||||
result = OS_SystemF("gcc -Wno-write-strings %Q -o %Q -g", build_file, exe_name);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
IO_Printf("FAILED compilation of the build file!\n");
|
||||
return result;
|
||||
@@ -50,7 +68,11 @@ int main(int argument_count, char **arguments) {
|
||||
// Run the build file
|
||||
double time = OS_GetTime();
|
||||
if (build_file.str) {
|
||||
#if OS_WINDOWS
|
||||
int result = OS_SystemF("%.*s", S8_Expand(exe_name));
|
||||
#else
|
||||
int result = OS_SystemF("./%.*s", S8_Expand(exe_name));
|
||||
#endif
|
||||
if (result != 0) {
|
||||
printf("FAILED execution of the build file!\n");
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user