diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2024-06-16 22:20:07 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2024-06-16 22:20:07 +0300 |
commit | 40fbb328150d853d0d7a83ce447c3f008de38822 (patch) | |
tree | 2a41218d92e94c360692ef39162ff2d5348c0e3a /b.c | |
parent | fb9a5b153f16d8c8fe961b6af0f54a7178e032a6 (diff) | |
download | cgame-40fbb328150d853d0d7a83ce447c3f008de38822.tar.gz cgame-40fbb328150d853d0d7a83ce447c3f008de38822.tar.bz2 cgame-40fbb328150d853d0d7a83ce447c3f008de38822.zip |
Start integrating pds, fix warnings and add new test build object
Diffstat (limited to 'b.c')
-rw-r--r-- | b.c | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -15,8 +15,10 @@ debug_or_release(B_Cmd* cmd) b_cmd_append(cmd, "-O2", "-ggdb", "-DVKDEBUG"); else if (debug_level == 2) b_cmd_append(cmd, "-O1", "-ggdb", "-DVKDEBUG"); - else + else { b_cmd_append(cmd, "-O0", "-ggdb", "-DVKDEBUG"); + b_cmd_append(cmd, "-fsanitize=address"); + } } void @@ -37,7 +39,6 @@ cflags(B_Cmd* cmd) b_cmd_append(cmd, "-march=native"); b_cmd_append(cmd, "-fno-math-errno", "-funroll-loops"); b_cmd_append(cmd, "-flto", "-pthread"); - b_cmd_append(cmd, "-fsanitize=address"); inlcude_dirs(cmd); } @@ -52,7 +53,6 @@ void cxxflags(B_Cmd *cmd) b_cmd_append(cmd, "-march=native"); b_cmd_append(cmd, "-fno-math-errno", "-funroll-loops"); b_cmd_append(cmd, "-flto", "-pthread"); - b_cmd_append(cmd, "-fsanitize=address"); inlcude_dirs(cmd); //b_cmd_append(cmd, "-O3"); @@ -125,7 +125,8 @@ build_objects(const char* lang, const char* object, const char* deps[], size_t deps_size, - const char* out[]) // deps_size + 1 + const char* out[], // deps_size + 1 + size_t * it) { char *tmpc, *tmpc2; char tmp[deps_size + 1][1000]; @@ -135,7 +136,10 @@ build_objects(const char* lang, strcpy(path, BUILD_DIR); //strcat(path, "/"); strcat(path, basename(tmp_obj)); - path[ strlen(path) - 4 ] = '\0'; + if (!strcmp(lang, "C++")) + path[ strlen(path) - 4 ] = '\0'; + else + path[ strlen(path) - 2 ] = '\0'; strcat(path, "/"); b_mkdir_if_not_exists(path); @@ -156,13 +160,19 @@ build_objects(const char* lang, } size_t s = strlen(tmp[i]); - tmp[i][s - 4] = '.'; - tmp[i][s - 3] = 'o'; - tmp[i][s - 2] = '\0'; - - out[i] = strdup(tmp[i]); + if (!strcmp(lang, "C++")) { + tmp[i][s - 4] = '.'; + tmp[i][s - 3] = 'o'; + tmp[i][s - 2] = '\0'; + } else { + tmp[i][s - 2] = '.'; + tmp[i][s - 1] = 'o'; + tmp[i][s ] = '\0'; + } + + out[*it] = strdup(tmp[i]); - int c = b_needs_rebuild1(out[i], i == deps_size ? object : deps[i]); + int c = b_needs_rebuild1(out[*it], i == deps_size ? object : deps[i]); if (c < 0) return false; rebuild += c; @@ -176,10 +186,11 @@ build_objects(const char* lang, b_cmd_append(&cmd, "-c"); b_cmd_append(&cmd, i == deps_size ? object : deps[i]); b_cmd_append(&cmd, "-o"); - b_cmd_append(&cmd, out[i]); + b_cmd_append(&cmd, out[*it]); bool rc = b_cmd_run_sync(cmd); if (!rc) return false; } + *it = *it + 1; } if (rebuild == 0) b_log(B_INFO, "%s* is up-to-date", path); @@ -254,12 +265,14 @@ main(int argc, char *argv[]) }; B_Cmd cmd = {0}; - const char* objects[B_ARRAY_LEN(cplusplus_deps) + 1]; + size_t it = 0; + const char* objects[B_ARRAY_LEN(cplusplus_deps) + 1 + 1]; b_mkdir_if_not_exists(BUILD_DIR); // TODO: make build_object func to build one by one, and add headers - if (!build_objects("C++", "src/cplusplus.cpp", cplusplus_deps, B_ARRAY_LEN(cplusplus_deps), objects)) return 1; + if (!build_objects("C", "src/test.c", NULL, 0, objects, &it)) return 1; + if (!build_objects("C++", "src/cplusplus.cpp", cplusplus_deps, B_ARRAY_LEN(cplusplus_deps), objects, &it)) return 1; if (!build_c(force, &cmd, render_paths, B_ARRAY_LEN(render_paths), render_deps, B_ARRAY_LEN(render_deps), objects, B_ARRAY_LEN(objects), BUILD_DIR"render")) return 1; return 0; |