From 0d06b8f9adce1f9fee6af5c28bba9a2e33d501b7 Mon Sep 17 00:00:00 2001 From: LeonardoBizzoni Date: Sun, 31 Aug 2025 14:30:24 +0200 Subject: [PATCH] `cb_run` -> `cb_cmd_run` --- .gitmodules | 2 +- cbuild.h | 18 +++++++++--------- examples/01-basics/build.c | 2 +- examples/02-async-commands/build.c | 6 +++--- examples/03-stream-redirection/build.c | 4 ++-- .../build.c | 2 +- .../build.c | 9 ++------- .../src/base | 0 .../src/main.c | 0 9 files changed, 19 insertions(+), 24 deletions(-) rename examples/{XX-codebase-build => XX-generic-codebase-build}/build.c (92%) rename examples/{XX-codebase-build => XX-generic-codebase-build}/src/base (100%) rename examples/{XX-codebase-build => XX-generic-codebase-build}/src/main.c (100%) diff --git a/.gitmodules b/.gitmodules index 1f7464e..ae00f0a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "examples/XX-codebase-build/src/base"] - path = examples/XX-codebase-build/src/base + path = examples/XX-generic-codebase-build/src/base url = git@github.com:LeonardoBizzoni/Codebase.git diff --git a/cbuild.h b/cbuild.h index e0b1212..ae0ad45 100755 --- a/cbuild.h +++ b/cbuild.h @@ -129,7 +129,7 @@ struct CB_PathList { }; typedef struct CB_PathList CB_Cmd; -struct CB_RunArgs { +struct Cb_Cmd_RunArgs { bool async; bool reset; @@ -191,10 +191,10 @@ enum { #define cb_println(Level, Fmt, ...) cb_print((Level), Fmt "\n", ##__VA_ARGS__) #define cb_rebuild_self(argc, argv) _cb_rebuild(argc, argv, __FILE__, 0) #define cb_rebuild_self_with(argc, argv, ...) _cb_rebuild(argc, argv, __FILE__, __VA_ARGS__, 0) -#define cb_run(Cmd, ...) _cb_run((Cmd), (struct CB_RunArgs) { \ - .async = false, \ - .reset = true, \ - __VA_ARGS__ \ +#define cb_cmd_run(Cmd, ...) _cb_cmd_run((Cmd), (struct Cb_Cmd_RunArgs) { \ + .async = false, \ + .reset = true, \ + __VA_ARGS__ \ }) #define cb_proclist_push(Dynarr, Value) cb_dyn_push(Dynarr, Value) @@ -255,7 +255,7 @@ internal void _cb_handle_write(CB_Handle fd, char *buffer, size_t buffsize); internal char* _cb_format(const char *format, va_list args); internal bool _cb_need_rebuild(char *output_path, struct CB_PathList sources); internal void _cb_rebuild(int argc, char **argv, char *cb_src, ...); -internal CB_Process _cb_run(CB_Cmd *cmd, struct CB_RunArgs args); +internal CB_Process _cb_cmd_run(CB_Cmd *cmd, struct Cb_Cmd_RunArgs args); internal size_t _last_occurance_of(char *string, char ch); internal bool _is_literal_f(char *str, size_t l); @@ -526,7 +526,7 @@ internal char* _cb_format(const char *format, va_list args) { return res; } -internal CB_Process _cb_run(CB_Cmd *cmd, struct CB_RunArgs args) { +internal CB_Process _cb_cmd_run(CB_Cmd *cmd, struct Cb_Cmd_RunArgs args) { CB_Process res = {}; #if OS_WINDOWS @@ -635,7 +635,7 @@ internal void _cb_rebuild(int argc, char **argv, char *builder_src, ...) { printf("%s ", cmd.values[i]); } printf("\b`\n"); - CB_Process recompiler = cb_run(&cmd); + CB_Process recompiler = cb_cmd_run(&cmd); if (recompiler.status_code) { #if OS_WINDOWS cb_file_rename(exe_name_old, exe_name); @@ -645,7 +645,7 @@ internal void _cb_rebuild(int argc, char **argv, char *builder_src, ...) { cb_cmd_push(&cmd, exe_name); cb_cmd_append_dyn(&cmd, argv, argc); - (void)cb_run(&cmd); + (void)cb_cmd_run(&cmd); exit(0); } diff --git a/examples/01-basics/build.c b/examples/01-basics/build.c index 31be747..7e7af6e 100755 --- a/examples/01-basics/build.c +++ b/examples/01-basics/build.c @@ -9,5 +9,5 @@ int main(int argc, char **argv) { #else cb_cmd_append(&cmd, "cc", "main.c", "-o", "main"); #endif - cb_run(&cmd); + cb_cmd_run(&cmd); } diff --git a/examples/02-async-commands/build.c b/examples/02-async-commands/build.c index 76824d7..2256e7f 100644 --- a/examples/02-async-commands/build.c +++ b/examples/02-async-commands/build.c @@ -6,11 +6,11 @@ int main(int argc, char **argv) { CB_Cmd cmd = {}; CB_ProcessList procs = {}; cb_cmd_append(&cmd, "ls", "-lah", "."); - cb_proclist_push(&procs, cb_run(&cmd, .async = true)); + cb_proclist_push(&procs, cb_cmd_run(&cmd, .async = true)); cb_cmd_append(&cmd, "ls", "-lah", "/"); - cb_proclist_push(&procs, cb_run(&cmd, .async = true)); + cb_proclist_push(&procs, cb_cmd_run(&cmd, .async = true)); cb_cmd_append(&cmd, "pwd"); - cb_proclist_push(&procs, cb_run(&cmd, .async = true)); + cb_proclist_push(&procs, cb_cmd_run(&cmd, .async = true)); cb_proclist_wait(&procs); } diff --git a/examples/03-stream-redirection/build.c b/examples/03-stream-redirection/build.c index 2ca8083..eca220c 100644 --- a/examples/03-stream-redirection/build.c +++ b/examples/03-stream-redirection/build.c @@ -8,10 +8,10 @@ int main(int argc, char **argv) { CB_Cmd cmd = {}; cb_cmd_append(&cmd, "ls", "-lah", "."); - cb_run(&cmd, .stdout = file); + cb_cmd_run(&cmd, .stdout = file); cb_cmd_append(&cmd, "cat"); - cb_run(&cmd, .stdin = file); + cb_cmd_run(&cmd, .stdin = file); cb_handle_close(file); } diff --git a/examples/04-multiple-build-files-and-rebuild-opt/build.c b/examples/04-multiple-build-files-and-rebuild-opt/build.c index 289c10c..8ba075d 100644 --- a/examples/04-multiple-build-files-and-rebuild-opt/build.c +++ b/examples/04-multiple-build-files-and-rebuild-opt/build.c @@ -26,5 +26,5 @@ int main(int argc, char **argv) { CB_Cmd cmd = {}; cb_cmd_append(&cmd, "cc", "-o", "main", "src/main.c"); - cb_run(&cmd); + cb_cmd_run(&cmd); } diff --git a/examples/XX-codebase-build/build.c b/examples/XX-generic-codebase-build/build.c similarity index 92% rename from examples/XX-codebase-build/build.c rename to examples/XX-generic-codebase-build/build.c index 26ca473..3a1dcb2 100644 --- a/examples/XX-codebase-build/build.c +++ b/examples/XX-generic-codebase-build/build.c @@ -18,7 +18,6 @@ # define CppFlags "/TP", "/std:c++latest" # define CAnnoyingWarnings "/wd4477", "/wd4996" # define CppAnnoyingWarnings -# define OPENGL "gdi32.lib", "opengl32.lib" # define Output "/Fe" Outfile ".exe" #else # define SystemSharedLibs "-lpthread", "-lm" @@ -43,7 +42,6 @@ "-Wno-nested-anon-types" # define Output "-o", Outfile -# define OPENGL "-lGL", "-lGLU", "-DUSING_OPENGL=1" # if OS_LINUX # define X11 "-DLNX_X11=1", "-lX11", "-lXext" # define Wayland "-DLNX_WAYLAND=1", "-lxkbcommon" @@ -80,7 +78,7 @@ int main(int argc, char **argv) { CB_Cmd cmd = {}; cb_cmd_append(&cmd, "git", "submodule", "update", "--recursive"); - CB_Process codebase_updater = cb_run(&cmd, .async = true); + CB_Process codebase_updater = cb_cmd_run(&cmd, .async = true); #if OS_WINDOWS cb_cmd_push(&cmd, "cl.exe"); @@ -116,11 +114,8 @@ int main(int argc, char **argv) { #endif } - // NOTE(lb): Windows requires dlls to be all specified - // after the `/link` flag from what i understood cb_cmd_append(&cmd, SystemSharedLibs); - if (gui) {cb_cmd_append(&cmd, OPENGL); } cb_process_wait(&codebase_updater); - cb_run(&cmd); + cb_cmd_run(&cmd); } diff --git a/examples/XX-codebase-build/src/base b/examples/XX-generic-codebase-build/src/base similarity index 100% rename from examples/XX-codebase-build/src/base rename to examples/XX-generic-codebase-build/src/base diff --git a/examples/XX-codebase-build/src/main.c b/examples/XX-generic-codebase-build/src/main.c similarity index 100% rename from examples/XX-codebase-build/src/main.c rename to examples/XX-generic-codebase-build/src/main.c -- 2.52.0