Add easy_strings, S8_List iterator

This commit is contained in:
Krzosa Karol
2024-01-14 16:44:25 +01:00
parent 37eed81ea5
commit bad74c2dcd
6 changed files with 189 additions and 184 deletions

View File

@@ -1,25 +1,59 @@
#include "build_tool/library.cpp"
void Compile(Strs cc, Str files);
void Compile(S8_String cc, S8_String files);
int ReturnValue = 0;
int Main() {
Strs cc = CMDLine.get("cc"_s, ON_WINDOWS("cl"_s) ON_MAC("clang"_s) ON_LINUX("gcc"_s));
S8_String cc = CMDLine.get("cc", ON_WINDOWS("cl") ON_MAC("clang") ON_LINUX("gcc"));
Compile(cc, "../tests/test_main.cpp");
Compile(cc, "../tests/test_filesystem.c");
return ReturnValue;
}
void Compile(Strs cc, Str file) {
void Compile(S8_String cc, S8_String file) {
int result = 0;
Str exe = FilenameWithoutExt(file);
bool is_cpp = S8_EndsWith(file, ".cpp");
if (cc == "gcc" && is_cpp) result = OS_SystemF("g++ -o %.*s.exe %.*s -g -Wno-write-strings -fsanitize=address", S8_Expand(exe), S8_Expand(file));
else if (cc == "gcc" && !is_cpp) result = OS_SystemF("g -o %.*s.exe %.*s -g -Wno-write-strings -fsanitize=address", S8_Expand(exe), S8_Expand(file));
else if (cc == "clang" && is_cpp) result = OS_SystemF("clang++ -std=c++11 -o %.*s.exe %.*s -fdiagnostics-absolute-paths -g -Wno-writable-strings -fsanitize=address", S8_Expand(exe), S8_Expand(file));
else if (cc == "clang" && !is_cpp) result = OS_SystemF("clang -o %.*s.exe %.*s -fdiagnostics-absolute-paths -g -Wno-writable-strings -fsanitize=address", S8_Expand(exe), S8_Expand(file));
else result = OS_SystemF("cl -Fe:%.*s.exe %.*s -FC -Zi -WX -W3 -wd4200 -diagnostics:column -nologo -D_CRT_SECURE_NO_WARNINGS -fsanitize=address -RTC1", S8_Expand(exe), S8_Expand(file));
S8_String name_no_ext = S8_GetNameNoExt(file);
S8_String exe = Fmt("%.*s.exe", S8_Expand(name_no_ext));
if (cc == "cl") {
Array<S8_String> flags = Split("/MP /Zi -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi");
flags += Split("/FC /WX /W3 /wd4200 /diagnostics:column /nologo");
flags += Split("/GR- /EHa-");
flags += Split("-fsanitize=address -RTC1");
Array<S8_String> link = Split("/link /incremental:no");
S8_String name = Fmt("/Fe:%.*s", S8_Expand(exe));
result = Run(cc + file + name + flags + link);
}
else if (cc == "clang") {
Array<S8_String> flags = Split("-g -Wno-write-strings -fdiagnostics-absolute-paths");
flags += "-fsanitize=address";
if (S8_EndsWith(file, ".cpp")) {
cc = "clang++";
flags += "-std=c++11";
}
S8_String name = Fmt("-o %.*s", S8_Expand(exe));
result = Run(cc + file + name + flags);
}
else {
IO_Assert(cc == "gcc");
Array<S8_String> flags = Split("-g -Wno-write-strings");
flags += "-fsanitize=address";
if (S8_EndsWith(file, ".cpp")) {
cc = "g++";
flags += "-std=c++11";
}
S8_String name = Fmt("-o %.*s", S8_Expand(exe));
result = Run(cc + file + name + flags);
}
if (result == 0) result = OS_SystemF(IF_WINDOWS_ELSE("", "./") "%.*s.exe", S8_Expand(exe));
else ReturnValue = result;