Try out the multi process build
This commit is contained in:
112
build_file.cpp
112
build_file.cpp
@@ -1,66 +1,116 @@
|
|||||||
#include "build_tool/library.cpp"
|
#include "build_tool/library.cpp"
|
||||||
|
|
||||||
void Compile(S8_String cc, S8_String files);
|
|
||||||
int ReturnValue = 0;
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Array<S8_String> cmd = CMD_Make(argv, argc);
|
MA_Scratch scratch;
|
||||||
S8_String cc = CMD_Get(cmd, "cc", IF_WINDOWS("cl") IF_MAC("clang") IF_LINUX("gcc"));
|
S8_String working_dir = OS_GetWorkingDir(scratch);
|
||||||
|
|
||||||
Compile(cc, "../tests/test_thread.cpp");
|
Array<S8_String> files = {scratch};
|
||||||
// Compile(cc, "../tests/test_main.cpp");
|
files.add("../../tests/test_main.cpp");
|
||||||
// Compile(cc, "../tests/test_filesystem.c");
|
files.add("../../tests/test_filesystem.c");
|
||||||
|
|
||||||
return ReturnValue;
|
Array<S8_String> exes = {scratch};
|
||||||
}
|
Array<Process> processes = {scratch};
|
||||||
|
|
||||||
void Compile(S8_String cc, S8_String file) {
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
|
For2(file, files) {
|
||||||
S8_String name_no_ext = S8_GetNameNoExt(file);
|
S8_String name_no_ext = S8_GetNameNoExt(file);
|
||||||
S8_String exe = Fmt("%.*s.exe", S8_Expand(name_no_ext));
|
S8_String exe = Fmt("%.*s.exe", S8_Expand(name_no_ext));
|
||||||
bool is_cpp = S8_EndsWith(file, ".cpp");
|
bool is_cpp = S8_EndsWith(file, ".cpp");
|
||||||
|
|
||||||
if (cc == "cl") {
|
#if OS_WINDOWS
|
||||||
|
{
|
||||||
|
S8_String cc = "cl";
|
||||||
|
|
||||||
Array<S8_String> flags = {Perm};
|
Array<S8_String> flags = {scratch};
|
||||||
flags += "/MP /Zi -D_CRT_SECURE_NO_WARNINGS";
|
flags += "/MP /Zi -D_CRT_SECURE_NO_WARNINGS";
|
||||||
flags += "/FC /WX /W3 /wd4200 /diagnostics:column /nologo";
|
flags += "/FC /WX /W3 /wd4200 /diagnostics:column /nologo";
|
||||||
flags += "/GF /Gm- /Oi";
|
flags += "/GF /Gm- /Oi";
|
||||||
flags += "/GR- /EHa-";
|
flags += "/GR- /EHa-";
|
||||||
flags += "/D_DEBUG -RTC1 -Od";
|
|
||||||
flags += Fmt("/Fe:%.*s", S8_Expand(exe));
|
flags += Fmt("/Fe:%.*s", S8_Expand(exe));
|
||||||
|
|
||||||
Array<S8_String> link = {Perm};
|
Array<S8_String> debug = {scratch};
|
||||||
|
debug += "/D_DEBUG -RTC1 -Od";
|
||||||
|
|
||||||
|
Array<S8_String> release = {scratch};
|
||||||
|
release += "-O2 -MT -DNDEBUG -GL";
|
||||||
|
|
||||||
|
Array<S8_String> link = {scratch};
|
||||||
link += "/link /incremental:no";
|
link += "/link /incremental:no";
|
||||||
|
|
||||||
result = Run(cc + file + flags + link);
|
S8_String dir_debug = Fmt("%.*s/%.*s_cl_debug_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
||||||
}
|
S8_String dir_release = Fmt("%.*s/%.*s_cl_release_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
||||||
else if (cc == "clang") {
|
|
||||||
if (is_cpp) cc = "clang++";
|
|
||||||
|
|
||||||
Array<S8_String> flags = {Perm};
|
Array<S8_String> cmd_debug = cc + file + flags + debug + link;
|
||||||
|
Array<S8_String> cmd_release = cc + file + flags + release + link;
|
||||||
|
|
||||||
|
Process p1 = RunEx(cmd_debug, dir_debug);
|
||||||
|
Process p2 = RunEx(cmd_release, dir_release);
|
||||||
|
|
||||||
|
processes.add(p1);
|
||||||
|
processes.add(p2);
|
||||||
|
|
||||||
|
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir_debug), S8_Expand(exe)));
|
||||||
|
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir_release), S8_Expand(exe)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
S8_String cc = is_cpp ? "clang++" : "clang";
|
||||||
|
|
||||||
|
Array<S8_String> flags = {scratch};
|
||||||
flags += "-g -Wno-write-strings";
|
flags += "-g -Wno-write-strings";
|
||||||
flags += "-fdiagnostics-absolute-paths";
|
flags += "-fdiagnostics-absolute-paths";
|
||||||
flags += "-fsanitize=address";
|
flags += "-fsanitize=address";
|
||||||
if (is_cpp) flags += "-std=c++11";
|
if (is_cpp) flags += "-std=c++11";
|
||||||
flags += Fmt("-o %.*s", S8_Expand(exe));
|
flags += Fmt("-o %.*s", S8_Expand(exe));
|
||||||
|
|
||||||
result = Run(cc + file + flags);
|
S8_String dir = Fmt("%.*s/%.*s_debug_clang_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
||||||
|
Process p = RunEx(cc + file + flags, dir);
|
||||||
|
processes.add(p);
|
||||||
|
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir), S8_Expand(exe)));
|
||||||
}
|
}
|
||||||
else {
|
#if OS_LINUX
|
||||||
IO_Assert(cc == "gcc");
|
{
|
||||||
if (is_cpp) cc = "g++";
|
S8_String cc = is_cpp ? "g++" : "gcc";
|
||||||
|
Array<S8_String> flags = {scratch};
|
||||||
Array<S8_String> flags = {Perm};
|
|
||||||
flags += "-g -Wno-write-strings";
|
flags += "-g -Wno-write-strings";
|
||||||
flags += "-fsanitize=address";
|
flags += "-fsanitize=address";
|
||||||
if (is_cpp) flags += "-std=c++11";
|
if (is_cpp) flags += "-std=c++11";
|
||||||
flags += Fmt("-o %.*s", S8_Expand(exe));
|
flags += Fmt("-o %.*s", S8_Expand(exe));
|
||||||
|
|
||||||
result = Run(cc + file + flags);
|
S8_String dir = Fmt("%.*s/%.*s_debug_gcc_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
||||||
|
Process p = RunEx(cc + file + flags, dir);
|
||||||
|
processes.add(p);
|
||||||
|
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir), S8_Expand(exe)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0) result = OS_SystemF(IF_WINDOWS_ELSE("", "./") "%.*s", S8_Expand(exe));
|
//
|
||||||
else ReturnValue = result;
|
// Wait for all compilation to finalize
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
For(processes) {
|
||||||
|
int exit_code = Wait(&it);
|
||||||
|
if (exit_code != 0) result = exit_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Run exes if there were no errors
|
||||||
|
//
|
||||||
|
if (result == 0) {
|
||||||
|
processes.reset();
|
||||||
|
For(exes) {
|
||||||
|
Process p = RunEx(it);
|
||||||
|
processes.add(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
For(processes) {
|
||||||
|
int exit_code = Wait(&it);
|
||||||
|
S8_String name = exes[i++];
|
||||||
|
IO_Printf("%.*s - %d\n", S8_Expand(name), exit_code);
|
||||||
|
if (exit_code != 0) result = exit_code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ S8_String Fmt(const char *str, ...) {
|
|||||||
return str_fmt;
|
return str_fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Run(Array<S8_String> s) {
|
|
||||||
S8_String cmd = Merge(s);
|
|
||||||
return OS_SystemF("%.*s", S8_Expand(cmd));
|
|
||||||
}
|
|
||||||
|
|
||||||
Array<S8_String> ListDir(char *dir) {
|
Array<S8_String> ListDir(char *dir) {
|
||||||
Array<S8_String> result = {};
|
Array<S8_String> result = {};
|
||||||
for (OS_FileIter it = OS_IterateFiles(Perm, S8_MakeFromChar(dir)); OS_IsValid(it); OS_Advance(&it)) {
|
for (OS_FileIter it = OS_IterateFiles(Perm, S8_MakeFromChar(dir)); OS_IsValid(it); OS_Advance(&it)) {
|
||||||
@@ -94,7 +89,7 @@ Array<S8_String> ListDir(char *dir) {
|
|||||||
|
|
||||||
Array<S8_String> CMD_Make(char **argv, int argc) {
|
Array<S8_String> CMD_Make(char **argv, int argc) {
|
||||||
Array<S8_String> result = {Perm};
|
Array<S8_String> result = {Perm};
|
||||||
IO_Printf("Command line arguments:\n");
|
if (argc > 1) IO_Printf("Command line arguments:\n");
|
||||||
for (int i = 1; i < argc; i += 1) {
|
for (int i = 1; i < argc; i += 1) {
|
||||||
S8_String it = S8_MakeFromChar(argv[i]);
|
S8_String it = S8_MakeFromChar(argv[i]);
|
||||||
result.add(it);
|
result.add(it);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Table<S8_String> CMDLine;
|
|||||||
|
|
||||||
#include "cache.cpp"
|
#include "cache.cpp"
|
||||||
#include "easy_strings.cpp"
|
#include "easy_strings.cpp"
|
||||||
|
#include "process.cpp"
|
||||||
|
|
||||||
S8_String CL_Flags = "/MP /Zi /FC /WX /W3 /wd4200 /diagnostics:column /nologo -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi";
|
S8_String CL_Flags = "/MP /Zi /FC /WX /W3 /wd4200 /diagnostics:column /nologo -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi";
|
||||||
S8_String CL_Link = "/link /incremental:no";
|
S8_String CL_Link = "/link /incremental:no";
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IO_Assert(cc == "gcc");
|
IO_Assert(cc == "gcc");
|
||||||
result = OS_SystemF("gcc -Wno-write-strings %.*s -o %.*s -g", S8_Expand(build_file), S8_Expand(exe_name));
|
result = OS_SystemF("g++ -Wno-write-strings %.*s -o %.*s -g", S8_Expand(build_file), S8_Expand(exe_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
struct TH_Process {
|
struct Process {
|
||||||
bool is_valid;
|
bool is_valid;
|
||||||
char platform[32];
|
char platform[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
TH_Process TH_CreateProcess(S8_String in_cmd, S8_String in_working_dir = "") {
|
Process RunEx(S8_String in_cmd) {
|
||||||
MA_Scratch scratch;
|
MA_Scratch scratch;
|
||||||
if (in_working_dir != "" && !OS_IsAbsolute(in_working_dir)) {
|
|
||||||
in_working_dir = OS_GetAbsolutePath(scratch, in_working_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
wchar_t *application_name = NULL;
|
wchar_t *application_name = NULL;
|
||||||
wchar_t *cmd = S8_ToWidechar(scratch, in_cmd);
|
wchar_t *cmd = S8_ToWidechar(scratch, in_cmd);
|
||||||
BOOL inherit_handles = FALSE;
|
BOOL inherit_handles = FALSE;
|
||||||
DWORD creation_flags = 0;
|
DWORD creation_flags = 0;
|
||||||
void *enviroment = NULL;
|
void *enviroment = NULL;
|
||||||
wchar_t *working_dir = in_working_dir == "" ? NULL : S8_ToWidechar(scratch, in_working_dir);
|
wchar_t *working_dir = NULL;
|
||||||
STARTUPINFOW startup_info = {};
|
STARTUPINFOW startup_info = {};
|
||||||
startup_info.cb = sizeof(STARTUPINFOW);
|
startup_info.cb = sizeof(STARTUPINFOW);
|
||||||
TH_Process result = {};
|
Process result = {};
|
||||||
IO_Assert(sizeof(result.platform) >= sizeof(PROCESS_INFORMATION));
|
IO_Assert(sizeof(result.platform) >= sizeof(PROCESS_INFORMATION));
|
||||||
PROCESS_INFORMATION *process_info = (PROCESS_INFORMATION *)result.platform;
|
PROCESS_INFORMATION *process_info = (PROCESS_INFORMATION *)result.platform;
|
||||||
BOOL success = CreateProcessW(application_name, cmd, NULL, NULL, inherit_handles, creation_flags, enviroment, working_dir, &startup_info, process_info);
|
BOOL success = CreateProcessW(application_name, cmd, NULL, NULL, inherit_handles, creation_flags, enviroment, working_dir, &startup_info, process_info);
|
||||||
@@ -32,12 +28,12 @@ TH_Process TH_CreateProcess(S8_String in_cmd, S8_String in_working_dir = "") {
|
|||||||
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
|
NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
|
||||||
LocalFree(lpMsgBuf);
|
LocalFree(lpMsgBuf);
|
||||||
|
|
||||||
IO_FatalErrorf("Failed to create process \nworking_dir: %.*s\ncmd: %.*s\nwindows_message: %s", S8_Expand(in_working_dir), S8_Expand(in_cmd), lpMsgBuf);
|
IO_FatalErrorf("Failed to create process \ncmd: %.*s\nwindows_message: %s", S8_Expand(in_cmd), lpMsgBuf);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TH_WaitForProcessExit(TH_Process *process) {
|
int Wait(Process *process) {
|
||||||
IO_Assert(process->is_valid);
|
IO_Assert(process->is_valid);
|
||||||
PROCESS_INFORMATION *pi = (PROCESS_INFORMATION *)process->platform;
|
PROCESS_INFORMATION *pi = (PROCESS_INFORMATION *)process->platform;
|
||||||
WaitForSingleObject(pi->hProcess, INFINITE);
|
WaitForSingleObject(pi->hProcess, INFINITE);
|
||||||
@@ -61,13 +57,9 @@ struct TH_UnixProcess {
|
|||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
TH_Process TH_CreateProcess(S8_String cmd, S8_String working_dir = "") {
|
Process RunEx(S8_String cmd) {
|
||||||
MA_Scratch scratch;
|
MA_Scratch scratch;
|
||||||
if (working_dir != "" && !OS_IsAbsolute(working_dir)) {
|
Process result = {};
|
||||||
working_dir = OS_GetAbsolutePath(scratch, working_dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
TH_Process result = {};
|
|
||||||
IO_Assert(sizeof(result.platform) >= sizeof(TH_UnixProcess));
|
IO_Assert(sizeof(result.platform) >= sizeof(TH_UnixProcess));
|
||||||
TH_UnixProcess *u = (TH_UnixProcess *)result.platform;
|
TH_UnixProcess *u = (TH_UnixProcess *)result.platform;
|
||||||
|
|
||||||
@@ -101,23 +93,19 @@ TH_Process TH_CreateProcess(S8_String cmd, S8_String working_dir = "") {
|
|||||||
args.add(NULL);
|
args.add(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
S8_String prev_dir = {};
|
|
||||||
if (working_dir != "") prev_dir = OS_GetWorkingDir(scratch);
|
|
||||||
if (working_dir != "") OS_SetWorkingDir(working_dir);
|
|
||||||
int err = posix_spawnp(&u->pid, exec_file.str, NULL, NULL, args.data, environ);
|
int err = posix_spawnp(&u->pid, exec_file.str, NULL, NULL, args.data, environ);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
result.is_valid = true;
|
result.is_valid = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
perror("Failed to create process");
|
perror("posix_spawnp error");
|
||||||
IO_FatalErrorf("Failed to create process \nworking_dir: %.*s\ncmd: %.*s", S8_Expand(working_dir), S8_Expand(cmd));
|
IO_FatalErrorf("Failed to create process, cmd: %.*s", S8_Expand(cmd));
|
||||||
}
|
}
|
||||||
if (working_dir != "") OS_SetWorkingDir(prev_dir);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TH_WaitForProcessExit(TH_Process *process) {
|
int Wait(Process *process) {
|
||||||
if (!process->is_valid) return 1;
|
if (!process->is_valid) return 1;
|
||||||
TH_UnixProcess *u = (TH_UnixProcess *)process->platform;
|
TH_UnixProcess *u = (TH_UnixProcess *)process->platform;
|
||||||
|
|
||||||
@@ -137,3 +125,31 @@ int TH_WaitForProcessExit(TH_Process *process) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Process RunEx(Array<S8_String> s) {
|
||||||
|
S8_String cmd = Merge(s);
|
||||||
|
Process proc = RunEx(cmd);
|
||||||
|
return proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process RunEx(Array<S8_String> s, S8_String process_start_dir) {
|
||||||
|
OS_MakeDir(process_start_dir);
|
||||||
|
S8_String working_dir = OS_GetWorkingDir(Perm);
|
||||||
|
OS_SetWorkingDir(process_start_dir);
|
||||||
|
S8_String cmd = Merge(s);
|
||||||
|
Process proc = RunEx(cmd);
|
||||||
|
OS_SetWorkingDir(working_dir);
|
||||||
|
return proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Run(S8_String cmd) {
|
||||||
|
Process process = RunEx(cmd);
|
||||||
|
int result = Wait(&process);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Run(Array<S8_String> cmd) {
|
||||||
|
S8_String cmds = Merge(cmd);
|
||||||
|
int result = Run(cmds);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,128 +1 @@
|
|||||||
#include "../build_tool/library.cpp"
|
#include "../build_tool/library.cpp"
|
||||||
#include "../build_tool/process.cpp"
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
MA_Scratch scratch;
|
|
||||||
S8_String working_dir = OS_GetWorkingDir(scratch);
|
|
||||||
|
|
||||||
Array<S8_String> exes = {scratch};
|
|
||||||
Array<TH_Process> proc = {scratch};
|
|
||||||
Array<S8_String> files = {scratch};
|
|
||||||
files.add("../../tests/test_main.cpp");
|
|
||||||
files.add("../../tests/test_filesystem.c");
|
|
||||||
|
|
||||||
For2(file, files) {
|
|
||||||
S8_String name_no_ext = S8_GetNameNoExt(file);
|
|
||||||
S8_String exe = Fmt("%.*s.exe", S8_Expand(name_no_ext));
|
|
||||||
bool is_cpp = S8_EndsWith(file, ".cpp");
|
|
||||||
|
|
||||||
#if OS_WINDOWS
|
|
||||||
// Setup CL Debug
|
|
||||||
{
|
|
||||||
S8_String cc = "cl";
|
|
||||||
|
|
||||||
Array<S8_String> flags = {scratch};
|
|
||||||
flags += "/MP /Zi -D_CRT_SECURE_NO_WARNINGS";
|
|
||||||
flags += "/FC /WX /W3 /wd4200 /diagnostics:column /nologo";
|
|
||||||
flags += "/GF /Gm- /Oi";
|
|
||||||
flags += "/GR- /EHa-";
|
|
||||||
flags += Fmt("/Fe:%.*s", S8_Expand(exe));
|
|
||||||
|
|
||||||
Array<S8_String> debug = {scratch};
|
|
||||||
debug += "/D_DEBUG -RTC1 -Od";
|
|
||||||
|
|
||||||
Array<S8_String> release = {scratch};
|
|
||||||
release += "-O2 -MT -DNDEBUG -GL";
|
|
||||||
|
|
||||||
Array<S8_String> link = {scratch};
|
|
||||||
link += "/link /incremental:no";
|
|
||||||
|
|
||||||
S8_String dir_debug = Fmt("%.*s/%.*s_cl_debug_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
|
||||||
S8_String dir_release = Fmt("%.*s/%.*s_cl_release_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
|
||||||
|
|
||||||
OS_MakeDir(dir_debug);
|
|
||||||
OS_MakeDir(dir_release);
|
|
||||||
|
|
||||||
Array<S8_String> cmd_debug = cc + file + flags + debug + link;
|
|
||||||
Array<S8_String> cmd_release = cc + file + flags + release + link;
|
|
||||||
|
|
||||||
S8_String cmd_debug_m = Merge(cmd_debug);
|
|
||||||
S8_String cmd_release_m = Merge(cmd_release);
|
|
||||||
|
|
||||||
TH_Process p1 = TH_CreateProcess(cmd_debug_m, dir_debug);
|
|
||||||
TH_Process p2 = TH_CreateProcess(cmd_release_m, dir_release);
|
|
||||||
|
|
||||||
proc.add(p1);
|
|
||||||
proc.add(p2);
|
|
||||||
|
|
||||||
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir_debug), S8_Expand(exe)));
|
|
||||||
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir_release), S8_Expand(exe)));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
S8_String cc = is_cpp ? "clang++" : "clang";
|
|
||||||
|
|
||||||
Array<S8_String> flags = {scratch};
|
|
||||||
flags += "-g -Wno-write-strings";
|
|
||||||
flags += "-fdiagnostics-absolute-paths";
|
|
||||||
flags += "-fsanitize=address";
|
|
||||||
if (is_cpp) flags += "-std=c++11";
|
|
||||||
flags += Fmt("-o %.*s", S8_Expand(exe));
|
|
||||||
|
|
||||||
S8_String dir = Fmt("%.*s/%.*s_debug_clang_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
|
||||||
OS_MakeDir(dir);
|
|
||||||
|
|
||||||
S8_String cmd = Merge(cc + file + flags);
|
|
||||||
TH_Process p = TH_CreateProcess(cmd, dir);
|
|
||||||
proc.add(p);
|
|
||||||
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir), S8_Expand(exe)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OS_LINUX
|
|
||||||
{
|
|
||||||
S8_String cc = is_cpp ? "g++" : "gcc";
|
|
||||||
Array<S8_String> flags = {scratch};
|
|
||||||
flags += "-g -Wno-write-strings";
|
|
||||||
flags += "-fsanitize=address";
|
|
||||||
if (is_cpp) flags += "-std=c++11";
|
|
||||||
flags += Fmt("-o %.*s", S8_Expand(exe));
|
|
||||||
|
|
||||||
S8_String dir = Fmt("%.*s/%.*s_debug_gcc_" OS_NAME, S8_Expand(working_dir), S8_Expand(name_no_ext));
|
|
||||||
OS_MakeDir(dir);
|
|
||||||
|
|
||||||
S8_String cmd = Merge(cc + file + flags);
|
|
||||||
TH_Process p = TH_CreateProcess(cmd, dir);
|
|
||||||
proc.add(p);
|
|
||||||
exes.add(Fmt("%.*s/%.*s", S8_Expand(dir), S8_Expand(exe)));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Wait for all compilation to finalize
|
|
||||||
//
|
|
||||||
int result = 0;
|
|
||||||
For(proc) {
|
|
||||||
int exit_code = TH_WaitForProcessExit(&it);
|
|
||||||
if (exit_code != 0) result = exit_code;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Run exes if there were no errors
|
|
||||||
//
|
|
||||||
if (result == 0) {
|
|
||||||
proc.reset();
|
|
||||||
For(exes) {
|
|
||||||
TH_Process p = TH_CreateProcess(it);
|
|
||||||
proc.add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
For(proc) {
|
|
||||||
int exit_code = TH_WaitForProcessExit(&it);
|
|
||||||
if (exit_code != 0) result = exit_code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user