diff options
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; |