/* * 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" #include "src/core/core.c" #define BUILD_TOOL_LIB #define S8_String s8_t #include "src/meta/build_tool.c" #include "src/meta/meta_format.c" #include "src/meta/meta_serialize_format.c" #include "src/meta/meta_table_format.c" #include "src/meta/meta_cfiles.c" #include "src/app/app.meta.c" #include "src/ui/ui.meta.c" #include "src/render/render.meta.c" #include "src/prototype/prototype.meta.c" #include "src/testing/testing.meta.c" void build_testing_target(void) { if (!cache_code_modified(s8("../src/testing/testing_main.c"), s8("testing.exe"))) { return; } if (PLATFORM_WINDOWS) { os_delete_file(s8("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); } else { 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("../src/app/app_win32_exe.c"), s8("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_prototype_dll_target(void) { if (!cache_code_modified(s8("../src/prototype/main.c"), s8("app.dll"))) { return; } int ok = os_systemf( "cl ../src/prototype/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("../src/app/app_wasm.html"), s8("../package/index.html")); b32 wasm_code_modified = cache_code_modified(s8("../src/prototype/main.c"), s8("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/prototype/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("../src/prototype/main.c"), s8("standalone_app.exe"))) { return; } int ok = os_systemf( "cl ../src/prototype/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("../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) { os_core_init(); int ok = 0; SRC_SearchPaths.include_path = (char*[]){OS_GetAbsolutePath(&Perm, s8("../src")).str}; SRC_SearchPaths.include_path_count = 1; cache_init(&Perm, s8("cache_build_file")); generate_math_code(&tcx->temp); generate_ui_code(&tcx->temp); generate_app_code(&tcx->temp); generate_prototype_code(&tcx->temp); generate_render_code(&tcx->temp); generate_testing_code(&tcx->temp); b32 run_win32_app_base_target = true; b32 run_testing_target = true; b32 run_prototype_dll_target = true; b32 run_prototype_wasm_target = false; b32 run_prototype_standalone_target = false; b32 run_server = false; if (run_server) { os_systemf("start /D ..\\package ..\\package\\run_server.bat"); } if (run_testing_target) { build_testing_target(); } if (run_prototype_standalone_target) { build_prototype_standalone_target(); } if (run_prototype_dll_target) { build_prototype_dll_target(); } if (run_win32_app_base_target) { build_win32_app_base_target(); } if (run_prototype_wasm_target) { build_prototype_wasm_target(); } cache_save(); return ok; }