Port bld cache to linux successfuly
This commit is contained in:
35
bld_file.cpp
35
bld_file.cpp
@@ -1,5 +1,35 @@
|
|||||||
#include "bld_lib.cpp"
|
#include "bld_lib.cpp"
|
||||||
|
|
||||||
|
Strs cc = ON_WINDOWS("cl") ON_MAC("clang") ON_LINUX("gcc");
|
||||||
|
|
||||||
|
int CompileFiles(Strs files) {
|
||||||
|
int result = 0;
|
||||||
|
Str exe = FilenameWithoutExt(files[0]);
|
||||||
|
Str filestr = Merge(files);
|
||||||
|
if (cc == "gcc") {
|
||||||
|
result = OS_SystemF("g++ -o %Q.exe %Q -g -Wno-write-strings", exe, filestr);
|
||||||
|
}
|
||||||
|
else if (cc == "clang") {
|
||||||
|
result = OS_SystemF("clang++ -o %Q.exe %Q -g -Wno-writable-strings", exe, filestr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = OS_SystemF("cl -Fe:%Q.exe %Q -Zi -WX -W3 -wd4200 -diagnostics:column -nologo -D_CRT_SECURE_NO_WARNINGS", exe, filestr);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Main() {
|
||||||
|
Strs files = ListDir("../test");
|
||||||
|
For(files) {
|
||||||
|
if (S8_Find(it, "test_"_s, 0, 0)) {
|
||||||
|
CompileFiles(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0 // msvc flag reference
|
||||||
int Main() {
|
int Main() {
|
||||||
bool debug = true;
|
bool debug = true;
|
||||||
bool release = !debug;
|
bool release = !debug;
|
||||||
@@ -9,7 +39,7 @@ int Main() {
|
|||||||
Strs flags = Split("-WX -W3 -wd4200 -diagnostics:column -nologo -Z7 -FC -GF -Gm- -Oi -Zo -D_CRT_SECURE_NO_WARNINGS");
|
Strs flags = Split("-WX -W3 -wd4200 -diagnostics:column -nologo -Z7 -FC -GF -Gm- -Oi -Zo -D_CRT_SECURE_NO_WARNINGS");
|
||||||
Strs link = Split("-link -incremental:no");
|
Strs link = Split("-link -incremental:no");
|
||||||
Strs files = Split("../test/main_core_as_header.cpp ../core.c");
|
Strs files = Split("../test/main_core_as_header.cpp ../core.c");
|
||||||
// files += IfCodeWasModified("../core.c", "../core.obj");
|
// files += IfCodeWasModified("../core.c", "../core.obj"); // .o for linux!
|
||||||
if (use_std) {
|
if (use_std) {
|
||||||
flags += Split("-GR- -EHa-");
|
flags += Split("-GR- -EHa-");
|
||||||
}
|
}
|
||||||
@@ -32,8 +62,9 @@ int Main() {
|
|||||||
if (error != 0) return error;
|
if (error != 0) return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
objs += S8_Format(Perm, "../build/%Q.obj", FilenameWithoutExt(it));
|
objs += S8_Format(Perm, "../build/%Q.obj", FilenameWithoutExt(it)); // .o for linux!
|
||||||
}
|
}
|
||||||
int error = Run(cc + objs + flags + link);
|
int error = Run(cc + objs + flags + link);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
19
bld_lib.cpp
19
bld_lib.cpp
@@ -121,7 +121,7 @@ bool SRC_WasModified(S8_String file) {
|
|||||||
|
|
||||||
S8_String without_ext = S8_ChopLastPeriod(file);
|
S8_String without_ext = S8_ChopLastPeriod(file);
|
||||||
S8_String name_only = S8_SkipToLastSlash(without_ext);
|
S8_String name_only = S8_SkipToLastSlash(without_ext);
|
||||||
S8_String obj = S8_Format(Perm, "%.*s.obj", S8_Expand(name_only));
|
S8_String obj = S8_Format(Perm, "%.*s.%s", S8_Expand(name_only), IF_WINDOWS_ELSE("obj", "o"));
|
||||||
bool modified = OS_FileExists(obj) == false;
|
bool modified = OS_FileExists(obj) == false;
|
||||||
|
|
||||||
SRC_CacheEntry *in_memory = SRC_HashFile(file, 0);
|
SRC_CacheEntry *in_memory = SRC_HashFile(file, 0);
|
||||||
@@ -150,9 +150,19 @@ struct Strs : Array<Str> {
|
|||||||
*this = {};
|
*this = {};
|
||||||
this->add(S8_MakeFromChar(str));
|
this->add(S8_MakeFromChar(str));
|
||||||
}
|
}
|
||||||
|
Strs(Str a) {
|
||||||
|
*this = {};
|
||||||
|
this->add(a);
|
||||||
|
}
|
||||||
Strs(Array<Str> a) { MA_MemoryCopy(this, &a, sizeof(a)); }
|
Strs(Array<Str> a) { MA_MemoryCopy(this, &a, sizeof(a)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool operator==(Strs a, char *b) {
|
||||||
|
if (a.len != 1) return false;
|
||||||
|
bool result = a[0] == S8_MakeFromChar(b);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Strs operator+(Strs a, Strs b) {
|
Strs operator+(Strs a, Strs b) {
|
||||||
Strs c = {a.copy(*Perm)};
|
Strs c = {a.copy(*Perm)};
|
||||||
c.add_array(b);
|
c.add_array(b);
|
||||||
@@ -258,6 +268,13 @@ int Run(Strs s) {
|
|||||||
return OS_SystemF("%Q", cmd);
|
return OS_SystemF("%Q", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Strs ListDir(char *dir) {
|
||||||
|
Strs result = {};
|
||||||
|
S8_List files = OS_ListDir(Perm, S8_MakeFromChar(dir), 0);
|
||||||
|
S8_For(it, files) result.add(it->string);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef BLD_MAIN
|
#ifndef BLD_MAIN
|
||||||
int Main();
|
int Main();
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
11
bld_main.cpp
11
bld_main.cpp
@@ -6,13 +6,7 @@ int main(int argument_count, char **arguments) {
|
|||||||
OS_SetWorkingDir(S8_Lit("build"));
|
OS_SetWorkingDir(S8_Lit("build"));
|
||||||
IO_Printf("WORKING DIR: %Q\n", OS_GetWorkingDir(Perm));
|
IO_Printf("WORKING DIR: %Q\n", OS_GetWorkingDir(Perm));
|
||||||
|
|
||||||
#if OS_LINUX
|
S8_String cc = ON_WINDOWS("cl"_s) ON_MAC("clang"_s) ON_LINUX("gcc"_s);
|
||||||
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) {
|
for (int i = 1; i < argument_count; i += 1) {
|
||||||
S8_String arg = S8_MakeFromChar(arguments[i]);
|
S8_String arg = S8_MakeFromChar(arguments[i]);
|
||||||
@@ -54,7 +48,8 @@ int main(int argument_count, char **arguments) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IO_Assert(cc == "gcc"_s);
|
IO_Assert(cc == "gcc"_s);
|
||||||
result = OS_SystemF("gcc -Wno-write-strings %Q -o %Q -g", build_file, exe_name);
|
if (result == 0) result = OS_SystemF("gcc -c -Wno-write-strings %Q -o %Q.o -g", build_file, b);
|
||||||
|
if (result == 0) result = OS_SystemF("gcc -Wno-write-strings %Q.o -o %Q -g", b, exe_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
|||||||
2
build.sh
2
build.sh
@@ -2,7 +2,7 @@
|
|||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
set -e
|
set -e
|
||||||
gcc -o bld ../bld_main.cpp -fno-exceptions -fno-rtti -Wno-write-strings
|
gcc -o bld ../bld_main.cpp -g -fno-exceptions -fno-rtti -Wno-write-strings
|
||||||
cd ..
|
cd ..
|
||||||
./build/bld
|
./build/bld
|
||||||
# gcc -o test_filesystem ../test/test_filesystem.c -Wno-write-strings
|
# gcc -o test_filesystem ../test/test_filesystem.c -Wno-write-strings
|
||||||
|
|||||||
@@ -80,6 +80,26 @@
|
|||||||
#define FORCE_INLINE inline
|
#define FORCE_INLINE inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OS_MAC
|
||||||
|
#define ON_MAC(x) x
|
||||||
|
#else
|
||||||
|
#define ON_MAC(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OS_WINDOWS
|
||||||
|
#define ON_WINDOWS(x) x
|
||||||
|
#define IF_WINDOWS_ELSE(x, y) x
|
||||||
|
#else
|
||||||
|
#define ON_WINDOWS(x)
|
||||||
|
#define IF_WINDOWS_ELSE(x, y) y
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OS_LINUX
|
||||||
|
#define ON_LINUX(x) x
|
||||||
|
#else
|
||||||
|
#define ON_LINUX(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
// #if COMPILER_CLANG
|
// #if COMPILER_CLANG
|
||||||
// #pragma clang diagnostic push
|
// #pragma clang diagnostic push
|
||||||
// #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
|
// #pragma clang diagnostic ignored "-Wmicrosoft-enum-forward-reference"
|
||||||
|
|||||||
Reference in New Issue
Block a user