text editor target, refactor build_file.c
This commit is contained in:
246
build_file.c
246
build_file.c
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* need a way to specify build targets from cmd line
|
||||
|
||||
*/
|
||||
|
||||
// don't ever include stuff that build_file will generate code for!
|
||||
#define DONT_INCLUDE_GENERATED_MATH
|
||||
#include "src/core/core.h"
|
||||
@@ -15,13 +20,134 @@
|
||||
#include "src/ui/ui.meta.c"
|
||||
#include "src/render/render.meta.c"
|
||||
#include "src/wasm_app/wasm_app.meta.c"
|
||||
#include "src/text_editor/text_editor.meta.c"
|
||||
#include "src/testing/testing.meta.c"
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#define py "py "
|
||||
#else
|
||||
#define py "python3 "
|
||||
#endif
|
||||
void build_testing_target(void) {
|
||||
if (!cache_code_modified(s8_lit("../src/testing/testing_main.c"), s8_lit("testing.exe"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PLATFORM_WINDOWS) {
|
||||
os_delete_file(s8_lit("testing.pdb"));
|
||||
int ok = os_systemf(
|
||||
"cl ../src/testing/testing_main.c -Fe:testing.exe -Fd:testing.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
|
||||
ok = os_systemf("testing.exe");
|
||||
if (ok != 0) exit(ok);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int ok = os_systemf(
|
||||
"clang ../src/testing/testing_main.c -o testing.exe -g -I ../src"
|
||||
" -fdiagnostics-absolute-paths -Wno-unsequenced -Wno-single-bit-bitfield-constant-conversion"
|
||||
" -lm -ldl"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
|
||||
ok = os_systemf("./testing.exe");
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
|
||||
void build_win32_app_base_target(void) {
|
||||
if (!cache_code_modified(s8_lit("../src/app/app_win32_exe.c"), s8_lit("app_win32.exe"))) {
|
||||
return;
|
||||
}
|
||||
int ok = os_systemf(
|
||||
"cl ../src/app/app_win32_exe.c -Fe:app_win32.exe -Fd:app_win32.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
|
||||
void build_text_editor_dll_target(void) {
|
||||
if (!cache_code_modified(s8_lit("../src/text_editor/text_editor_main.c"), s8_lit("app.dll"))) {
|
||||
return;
|
||||
}
|
||||
int ok = os_systemf(
|
||||
"cl ../src/text_editor/text_editor_main.c -Fe:app.dll -Fd:app.pdb"
|
||||
" -I ../src /DAPP_IS_DLL"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL /DLL"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
|
||||
void build_prototype_dll_target(void) {
|
||||
if (!cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("app.dll"))) {
|
||||
return;
|
||||
}
|
||||
int ok = os_systemf(
|
||||
"cl ../src/wasm_app/main.c -Fe:app.dll -Fd:app.pdb"
|
||||
" -I ../src /DAPP_IS_DLL"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL /DLL"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
|
||||
void build_prototype_wasm_target(void) {
|
||||
b32 html_code_modified = cache_code_modified(s8_lit("../src/app/app_wasm.html"), s8_lit("../package/index.html"));
|
||||
b32 wasm_code_modified = cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("main.wasm"));
|
||||
if (html_code_modified) {
|
||||
os_copy("../src/app/app_wasm.html", "../package/index.html", os_copy_overwrite);
|
||||
}
|
||||
if (wasm_code_modified) {
|
||||
int ok = os_systemf(
|
||||
"clang ../src/wasm_app/main.c -o main.wasm"
|
||||
" -Oz -g -I../src"
|
||||
" -Wall -Wno-missing-braces -Wno-single-bit-bitfield-constant-conversion -Wno-unsequenced -Wno-initializer-overrides"
|
||||
" -fdiagnostics-absolute-paths -fdiagnostics-format=msvc"
|
||||
" --target=wasm32 -nostdlib -mbulk-memory -msimd128"
|
||||
" -Wl,-export-dynamic,--allow-undefined,--import-memory,--no-entry,--initial-memory=131072000,--max-memory=4294967296"
|
||||
);
|
||||
os_copy("main.wasm", "../package/main.wasm", os_copy_overwrite);
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
}
|
||||
|
||||
void build_prototype_standalone_target(void) {
|
||||
if (!cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("standalone_app.exe"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ok = os_systemf(
|
||||
"cl ../src/wasm_app/main.c -Fe:standalone_app.exe -Fd:standalone_app.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (ok != 0) exit(ok);
|
||||
}
|
||||
|
||||
void generate_math_code(ma_arena_t *arena) {
|
||||
if (!cache_code_modified(s8_lit("../src/core/core_math_gen.py"), s8_null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#define py "py "
|
||||
#else
|
||||
#define py "python3 "
|
||||
#endif
|
||||
|
||||
os_set_working_dir("../src/core");
|
||||
os_systemf(py "core_math_gen.py");
|
||||
os_set_working_dir("../../build");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
core_init();
|
||||
@@ -31,106 +157,48 @@ int main(int argc, char **argv) {
|
||||
SRC_SearchPaths.include_path_count = 1;
|
||||
cache_init(&Perm, s8_lit("cache_build_file"));
|
||||
|
||||
b32 generate_math = true;
|
||||
if (generate_math && cache_code_modified(s8_lit("../src/core/core_math_gen.py"), s8_null)) {
|
||||
os_set_working_dir("../src/core");
|
||||
os_systemf(py "core_math_gen.py");
|
||||
os_set_working_dir("../../build");
|
||||
}
|
||||
mt_ui(tcx->temp);
|
||||
mt_app(tcx->temp);
|
||||
mt_wasm_app(tcx->temp);
|
||||
mt_render(tcx->temp);
|
||||
mt_testing(tcx->temp);
|
||||
generate_math_code(tcx->temp);
|
||||
generate_ui_code(tcx->temp);
|
||||
generate_app_code(tcx->temp);
|
||||
generate_wasm_app_code(tcx->temp);
|
||||
generate_render_code(tcx->temp);
|
||||
generate_testing_code(tcx->temp);
|
||||
generate_text_editor_code(tcx->temp);
|
||||
|
||||
b32 run_server = false;
|
||||
b32 core_test_target = true;
|
||||
b32 win32_target = false;
|
||||
b32 standalone_w32_target = false;
|
||||
b32 wasm_target = false;
|
||||
b32 run_win32_app_base_target = true;
|
||||
b32 run_testing_target = true;
|
||||
b32 run_text_editor_dll_target = false;
|
||||
b32 run_prototype_dll_target = false;
|
||||
b32 run_prototype_wasm_target = false;
|
||||
b32 run_prototype_standalone_target = false;
|
||||
|
||||
if (run_server) {
|
||||
os_systemf("start /D ..\\package ..\\package\\run_server.bat");
|
||||
}
|
||||
|
||||
if (standalone_w32_target && cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("standalone_app.exe"))) {
|
||||
ok = os_systemf(
|
||||
"cl ../src/wasm_app/main.c -Fe:standalone_app.exe -Fd:standalone_app.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (ok != 0) return ok;
|
||||
if (run_prototype_standalone_target) {
|
||||
build_prototype_standalone_target();
|
||||
}
|
||||
|
||||
if (win32_target && cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("app.dll"))) {
|
||||
ok = os_systemf(
|
||||
"cl ../src/wasm_app/main.c -Fe:app.dll -Fd:app.pdb"
|
||||
" -I ../src /DAPP_IS_DLL"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL /DLL"
|
||||
);
|
||||
if (ok != 0) return ok;
|
||||
if (run_prototype_dll_target) {
|
||||
build_prototype_dll_target();
|
||||
}
|
||||
|
||||
if (win32_target && cache_code_modified(s8_lit("../src/app/app_win32_exe.c"), s8_lit("app_win32.exe"))) {
|
||||
ok = os_systemf(
|
||||
"cl ../src/app/app_win32_exe.c -Fe:app_win32.exe -Fd:app_win32.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (run_win32_app_base_target) {
|
||||
build_win32_app_base_target();
|
||||
}
|
||||
|
||||
if (core_test_target && cache_code_modified(s8_lit("../src/testing/testing_main.c"), s8_lit("testing.exe"))) {
|
||||
if (PLATFORM_WINDOWS) {
|
||||
os_delete_file(s8_lit("testing.pdb"));
|
||||
ok = os_systemf(
|
||||
"cl ../src/testing/testing_main.c -Fe:testing.exe -Fd:testing.pdb"
|
||||
" -I ../src"
|
||||
" /Zi /FC /nologo /Oi"
|
||||
" /WX /W3 /wd4200 /diagnostics:column"
|
||||
" /link /incremental:no /DEBUG:FULL"
|
||||
);
|
||||
if (ok != 0) return ok;
|
||||
|
||||
ok = os_systemf("testing.exe");
|
||||
if (ok != 0) return ok;
|
||||
} else {
|
||||
ok = os_systemf(
|
||||
"clang ../src/testing/testing_main.c -o testing.exe -g -I ../src"
|
||||
" -fdiagnostics-absolute-paths -Wno-unsequenced -Wno-single-bit-bitfield-constant-conversion"
|
||||
" -lm -ldl"
|
||||
);
|
||||
if (ok != 0) return ok;
|
||||
|
||||
ok = os_systemf("./testing.exe");
|
||||
if (ok != 0) return ok;
|
||||
}
|
||||
if (run_text_editor_dll_target) {
|
||||
build_text_editor_dll_target();
|
||||
}
|
||||
|
||||
if (run_testing_target) {
|
||||
build_testing_target();
|
||||
}
|
||||
|
||||
if (wasm_target) {
|
||||
b32 html_code_modified = cache_code_modified(s8_lit("../src/app/app_wasm.html"), s8_lit("../package/index.html"));
|
||||
b32 wasm_code_modified = cache_code_modified(s8_lit("../src/wasm_app/main.c"), s8_lit("main.wasm"));
|
||||
if (html_code_modified) {
|
||||
os_copy("../src/app/app_wasm.html", "../package/index.html", os_copy_overwrite);
|
||||
}
|
||||
if (wasm_code_modified) {
|
||||
ok = os_systemf(
|
||||
"clang ../src/wasm_app/main.c -o main.wasm"
|
||||
" -Oz -g -I../src"
|
||||
" -Wall -Wno-missing-braces -Wno-single-bit-bitfield-constant-conversion -Wno-unsequenced -Wno-initializer-overrides"
|
||||
" -fdiagnostics-absolute-paths -fdiagnostics-format=msvc"
|
||||
" --target=wasm32 -nostdlib -mbulk-memory -msimd128"
|
||||
" -Wl,-export-dynamic,--allow-undefined,--import-memory,--no-entry,--initial-memory=131072000,--max-memory=4294967296"
|
||||
);
|
||||
os_copy("main.wasm", "../package/main.wasm", os_copy_overwrite);
|
||||
if (ok != 0) return ok;
|
||||
}
|
||||
if (run_prototype_wasm_target) {
|
||||
build_prototype_wasm_target();
|
||||
}
|
||||
|
||||
cache_save();
|
||||
|
||||
Reference in New Issue
Block a user