Fixes in filesystem and build
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,7 +11,7 @@
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
backup.*
|
||||
|
||||
bld
|
||||
imgui.ini
|
||||
|
||||
__pycache__/
|
||||
|
||||
@@ -3,7 +3,7 @@ call ../misc/compile_setup.bat
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cl -Fe:bld.exe ../bld_main.cpp -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS /MD
|
||||
cl -Fe:bld.exe ../build_main.cpp -WX -W3 -wd4200 -diagnostics:column -nologo -Zi -D_CRT_SECURE_NO_WARNINGS /MD
|
||||
cd ..
|
||||
build\bld.exe
|
||||
|
||||
|
||||
2
build.sh
2
build.sh
@@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
gcc -o bld bld_main.cpp -g
|
||||
gcc -o bld build_main.cpp -g
|
||||
./bld
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "bld_lib.cpp"
|
||||
#include "build_lib.cpp"
|
||||
|
||||
Strs cc = ON_WINDOWS("cl") ON_MAC("clang") ON_LINUX("gcc");
|
||||
|
||||
@@ -15,6 +15,7 @@ int CompileFiles(Strs files) {
|
||||
else {
|
||||
result = OS_SystemF("cl -Fe:%Q.exe %Q -Zi -WX -W3 -wd4200 -diagnostics:column -nologo -D_CRT_SECURE_NO_WARNINGS", exe, filestr);
|
||||
}
|
||||
if (result == 0) result = OS_SystemF(IF_WINDOWS_ELSE("", "./") "%Q.exe", exe);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
/*
|
||||
----------------- CL.EXE -----------------
|
||||
FLAGS = /MP /Zi /FC /WX /W3 /wd4200 /diagnostics:column /nologo -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi
|
||||
LINK = /link /incremental:no
|
||||
STD_OFF = /GR- /EHa-
|
||||
STD_ON = /EHsc
|
||||
DEBUG = -Od -D_DEBUG -MDd -fsanitize=address -RTC1
|
||||
DEBUG_LINK = -NODEFAULTLIB:LIBCMT
|
||||
RELEASE = -O2 -MT -DNDEBUG -GL
|
||||
RELEASE_LINK = -opt:ref -opt:icf
|
||||
----------------- CL.EXE -----------------
|
||||
/FC = Print full paths in diagnostics
|
||||
/Gm- = Old feature, 'minimal compilation', in case it's not off by default
|
||||
/GF = Pools strings as read-only. If you try to modify strings under /GF, an application error occurs.
|
||||
/Oi = Replaces some function calls with intrinsic
|
||||
/MP = Multithreaded compilation
|
||||
/GR- = Disable runtime type information
|
||||
/EHa- = Disable exceptions
|
||||
/EHsc = Enable exceptions
|
||||
/MT = Link static libc. The 'd' means debug version
|
||||
/MD = Link dynamic libc. The 'd' means debug version
|
||||
/GL = Whole program optimization
|
||||
/RTC1 = runtime error checks
|
||||
/opt:ref = eliminates functions and data that are never referenced
|
||||
/opt:icf = eliminates redundant 'COMDAT's
|
||||
*/
|
||||
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
@@ -294,49 +321,10 @@ Strs ListDir(char *dir) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void PrintCompilerFlagHelp(Strs cc) {
|
||||
if (cc == "cl") {
|
||||
IO_Printf("------- CL.EXE -------\n");
|
||||
IO_Printf("/FC = Print full paths in diagnostics\n");
|
||||
IO_Printf("/Gm- = Old feature, 'minimal compilation', in case it's not off by default\n");
|
||||
IO_Printf("/GF = Pools strings as read-only. If you try to modify strings under /GF, an application error occurs.\n");
|
||||
IO_Printf("/Oi = Replaces some function calls with intrinsic \n");
|
||||
IO_Printf("/MP = Multithreaded compilation\n");
|
||||
|
||||
IO_Printf("/GR- = Disable runtime type information\n");
|
||||
IO_Printf("/EHa- = Disable exceptions\n");
|
||||
IO_Printf("/EHsc = Enable exceptions\n");
|
||||
|
||||
IO_Printf("/MT = Link static libc. The 'd' means debug version \n");
|
||||
IO_Printf("/MD = Link dynamic libc. The 'd' means debug version\n");
|
||||
IO_Printf("/GL = Whole program optimization \n");
|
||||
IO_Printf("/RTC1 = runtime error checks \n");
|
||||
IO_Printf("/opt:ref = eliminates functions and data that are never referenced\n");
|
||||
IO_Printf("/opt:icf = eliminates redundant 'COMDAT's\n");
|
||||
|
||||
IO_Printf("----------------------\n");
|
||||
IO_Printf("FLAGS = /MP /Zi /FC /WX /W3 /wd4200 /diagnostics:column /nologo -D_CRT_SECURE_NO_WARNINGS /GF /Gm- /Oi\n");
|
||||
IO_Printf("LINK = /link /incremental:no\n");
|
||||
IO_Printf("STD_OFF = /GR- /EHa-\n");
|
||||
IO_Printf("STD_ON = /EHsc\n");
|
||||
IO_Printf("DEBUG = -Od -D_DEBUG -MDd -fsanitize=address -RTC1\n");
|
||||
// IO_Printf("LINK = -NODEFAULTLIB:LIBCMT\n");
|
||||
IO_Printf("RELEASE = -O2 -MT -DNDEBUG -GL\n");
|
||||
IO_Printf("LINK = -opt:ref -opt:icf\n");
|
||||
}
|
||||
else if (cc == "gcc") {
|
||||
}
|
||||
else if (cc == "clang") {
|
||||
}
|
||||
else {
|
||||
IO_FatalErrorf("Unhandled compiler");
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BLD_MAIN
|
||||
#ifndef BUILD_MAIN
|
||||
int Main();
|
||||
int main() {
|
||||
SRC_InitCache(Perm, S8_Lit("bld_file.cache"));
|
||||
SRC_InitCache(Perm, S8_Lit("build_file.cache"));
|
||||
int result = Main();
|
||||
if (result == 0) SRC_SaveCache();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#define BLD_MAIN
|
||||
#include "bld_lib.cpp"
|
||||
#define BUILD_MAIN
|
||||
#include "build_lib.cpp"
|
||||
|
||||
int main(int argument_count, char **arguments) {
|
||||
OS_MakeDir(S8_Lit("build"));
|
||||
@@ -10,17 +10,17 @@ int main(int argument_count, char **arguments) {
|
||||
|
||||
for (int i = 1; i < argument_count; i += 1) {
|
||||
S8_String arg = S8_MakeFromChar(arguments[i]);
|
||||
if (arg == "clear_cache"_s) OS_DeleteFile("bld_tool.cache"_s);
|
||||
if (arg == "clear_cache"_s) OS_DeleteFile("build_tool.cache"_s);
|
||||
}
|
||||
|
||||
SRC_InitCache(Perm, S8_Lit("bld.cache"));
|
||||
SRC_InitCache(Perm, S8_Lit("build_tool.cache"));
|
||||
|
||||
// Search for build file in the project directory
|
||||
S8_String build_file = {0};
|
||||
{
|
||||
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("bld_file.c"), S8_IGNORE_CASE, 0)) {
|
||||
if (S8_Find(it->string, S8_Lit("build_file.c"), S8_IGNORE_CASE, 0)) {
|
||||
build_file = it->string;
|
||||
}
|
||||
}
|
||||
@@ -290,21 +290,20 @@ static OS_Result OS__WriteFile(S8_String path, S8_String data, bool append) {
|
||||
IO_Assert(data.len == (DWORD)data.len); // @Todo: can only read 32 byte size files?
|
||||
BOOL error = WriteFile(handle, data.str, (DWORD)data.len, &bytes_written, NULL);
|
||||
if (error == TRUE) {
|
||||
if (bytes_written != data.len) {
|
||||
if (bytes_written == data.len) {
|
||||
result = OS_SUCCESS;
|
||||
}
|
||||
}
|
||||
CloseHandle(handle);
|
||||
}
|
||||
else
|
||||
result = OS_PATH_NOT_FOUND;
|
||||
else result = OS_PATH_NOT_FOUND;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
OS_API OS_Result OS_AppendFile(S8_String path, S8_String string) {
|
||||
return OS__WriteFile(path, string, true);
|
||||
} // @untested
|
||||
}
|
||||
|
||||
OS_API OS_Result OS_WriteFile(S8_String path, S8_String string) {
|
||||
return OS__WriteFile(path, string, false);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
// Quick and dirty filesystem operations
|
||||
|
||||
#ifndef OS_API
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user