summaryrefslogtreecommitdiffstats
path: root/b.c
diff options
context:
space:
mode:
Diffstat (limited to 'b.c')
-rw-r--r--b.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/b.c b/b.c
index 89ea2ce..b22b330 100644
--- a/b.c
+++ b/b.c
@@ -7,7 +7,7 @@
int debug_level = 1;
void
-debug_or_release(B_Cmd* cmd)
+debug_or_release(b_cmd* cmd)
{
if (debug_level == 0)
b_cmd_append(cmd, "-O3", "-s", "-DNDEBUG");
@@ -22,7 +22,7 @@ debug_or_release(B_Cmd* cmd)
}
void
-inlcude_dirs(B_Cmd* cmd)
+inlcude_dirs(b_cmd* cmd)
{
b_cmd_append(cmd, "-I./src/");
b_cmd_append(cmd, "-I./lib");
@@ -30,27 +30,27 @@ inlcude_dirs(B_Cmd* cmd)
}
void
-cflags(B_Cmd* cmd)
+cflags(b_cmd* cmd)
{
b_cmd_append(cmd, "-Wall", "-Wextra");
debug_or_release(cmd);
- b_cmd_append(cmd, "-march=native");
+ //b_cmd_append(cmd, "-march=native");
b_cmd_append(cmd, "-fno-math-errno", "-funroll-loops");
b_cmd_append(cmd, "-flto", "-pthread");
inlcude_dirs(cmd);
}
-void cxxflags(B_Cmd *cmd)
+void cxxflags(b_cmd *cmd)
{
b_cmd_append(cmd, "-Wall", "-Wextra");
b_cmd_append(cmd, "-Wno-string-plus-int", "-Wno-nullability-completeness", "-Wno-unused-function", "-Wno-missing-field-initializers", "-Wno-unused-parameter", "-Wno-unused-variable");
debug_or_release(cmd);
- b_cmd_append(cmd, "-march=native");
+ //b_cmd_append(cmd, "-march=native");
b_cmd_append(cmd, "-fno-math-errno", "-funroll-loops");
b_cmd_append(cmd, "-flto", "-pthread");
@@ -58,26 +58,26 @@ void cxxflags(B_Cmd *cmd)
//b_cmd_append(cmd, "-O3");
}
-void cxx(B_Cmd *cmd)
+void cxx(b_cmd *cmd)
{
b_cmd_append(cmd, "clang");
cxxflags(cmd);
}
-void cc(B_Cmd *cmd)
+void cc(b_cmd *cmd)
{
b_cmd_append(cmd, "clang");
cflags(cmd);
}
-void libs(B_Cmd *cmd)
+void libs(b_cmd *cmd)
{
b_cmd_append(cmd, "-lSDL2", "-lm", "-lvulkan", "-lshaderc_shared", "-lstdc++");
}
bool
build_c(bool force,
- B_Cmd* cmd,
+ b_cmd* cmd,
const char** input_paths,
size_t input_paths_len,
const char** dep_paths,
@@ -111,9 +111,9 @@ build_c(bool force,
cmd->count = 0;
cc(cmd);
b_cmd_append(cmd, "-o", output_path);
- b_da_append_many(cmd, new_array, size);
+ array_append_many(cmd, new_array, size);
libs(cmd);
- return b_cmd_run_sync(*cmd);
+ return b_cmd_run(cmd);
}
b_log(B_INFO, "%s is up-to-date", output_path);
@@ -142,7 +142,7 @@ build_objects(const char* lang,
path[ strlen(path) - 2 ] = '\0';
strcat(path, "/");
- b_mkdir_if_not_exists(path);
+ b_mkdir(path);
int rebuild = 0;
@@ -177,7 +177,7 @@ build_objects(const char* lang,
rebuild += c;
if (c != 0) {
- B_Cmd cmd = { 0 };
+ b_cmd cmd = { 0 };
if (!strcmp(lang, "C++"))
cxx(&cmd);
@@ -187,7 +187,7 @@ build_objects(const char* lang,
b_cmd_append(&cmd, i == deps_size ? object : deps[i]);
b_cmd_append(&cmd, "-o");
b_cmd_append(&cmd, out[*it]);
- bool rc = b_cmd_run_sync(cmd);
+ bool rc = b_cmd_run(&cmd);
if (!rc) return false;
}
*it = *it + 1;
@@ -284,16 +284,16 @@ main(int argc, char *argv[])
"src/render.c",
};
- B_Cmd cmd = {0};
+ b_cmd cmd = {0};
size_t it = 0;
- const char* objects[B_ARRAY_LEN(cplusplus_deps) + 1 + 1];
+ const char* objects[ARRAY_LENGTH(cplusplus_deps) + 1 + 1];
- b_mkdir_if_not_exists(BUILD_DIR);
+ b_mkdir(BUILD_DIR);
// TODO: make build_object func to build one by one, and add headers
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;
+ if (!build_objects("C++", "src/cplusplus.cpp", cplusplus_deps, ARRAY_LENGTH(cplusplus_deps), objects, &it)) return 1;
+ if (!build_c(force, &cmd, render_paths, ARRAY_LENGTH(render_paths), render_deps, ARRAY_LENGTH(render_deps), objects, ARRAY_LENGTH(objects), BUILD_DIR"render")) return 1;
b_log(B_INFO, "Build time: %.3f seconds", current_time() - before_build);