]> git.leonardobizzoni.com Git - CBuild/commitdiff
Updated `ProcessList` api & examples
authorLeonardoBizzoni <leo2002714@gmail.com>
Thu, 21 Aug 2025 13:56:58 +0000 (15:56 +0200)
committerLeonardoBizzoni <leo2002714@gmail.com>
Thu, 21 Aug 2025 13:56:58 +0000 (15:56 +0200)
cbuild.h
examples/02-async-commands/build.c
examples/03-stream-redirection/build.c
examples/XX-codebase-build/build.c

index 9664087f1f28b900de41f57df99205b971cdaad7..73a9f53e866ca8134b9148f786007d4e6c5b7a48 100755 (executable)
--- a/cbuild.h
+++ b/cbuild.h
@@ -189,7 +189,7 @@ enum {
                                            .reset = true,      \
                                            __VA_ARGS__         \
                                         })
-#define cb_processesslist_push(Dynarr, Value) cb_dyn_push(Dynarr, Value)
+#define cb_proclist_push(Dynarr, Value) cb_dyn_push(Dynarr, Value)
 
 #define cb_dyn_free_custom(Dynarr, Values, Count) \
   do {                                            \
@@ -227,7 +227,7 @@ static void cb_print(CB_LogLevel level, const char *fmt, ...);
 static char* cb_getenv(char *varname);
 static bool cb_setenv(char *varname, char *value);
 static void cb_process_wait(CB_Process *handle);
-static void cb_processesslist_wait(CB_ProcessList *procs);
+static void cb_proclist_wait(CB_ProcessList *procs);
 static CB_Handle cb_handle_open(char *path, CB_AccessFlag permission);
 static void cb_handle_close(CB_Handle fd);
 static char* cb_handle_read(CB_Handle fd);
@@ -334,7 +334,7 @@ static void cb_process_wait(CB_Process *proc) {
 #endif
 }
 
-static void cb_processesslist_wait(CB_ProcessList *procs) {
+static void cb_proclist_wait(CB_ProcessList *procs) {
   for (size_t i = 0; i < procs->count; ++i) {
     cb_process_wait(&procs->values[i]);
   }
index f93fac3082c28bd421bfc3a2647d982f981ecbd1..5cfe60dad8428b0119d944aadd49b7e10763c802 100644 (file)
@@ -4,13 +4,13 @@ int main(int argc, char **argv) {
   cb_rebuild_self(argc, argv);
 
   cb_cmd cmd = {};
-  cb_procs procs = {};
+  CB_ProcessList procs = {};
   cb_cmd_append(&cmd, "ls", "-lah", ".");
-  cb_procs_push(&procs, cb_run(&cmd, .async = true));
+  cb_proclist_push(&procs, cb_run(&cmd, .async = true));
   cb_cmd_append(&cmd, "ls", "-lah", "/");
-  cb_procs_push(&procs, cb_run(&cmd, .async = true));
+  cb_proclist_push(&procs, cb_run(&cmd, .async = true));
   cb_cmd_append(&cmd, "pwd");
-  cb_procs_push(&procs, cb_run(&cmd, .async = true));
+  cb_proclist_push(&procs, cb_run(&cmd, .async = true));
 
-  cb_procs_wait(&procs);
+  cb_proclist_wait(&procs);
 }
index 6e024c943b7b3ba205ee000aed80d96b7f54465d..82c39eec469eb2c289c5d07372b816cad73b2684 100644 (file)
@@ -3,7 +3,8 @@
 int main(int argc, char **argv) {
   cb_rebuild_self(argc, argv);
 
-  cb_fd file = cb_open("ls-curdir-log", CB_ACF_READ | CB_ACF_WRITE);
+  CB_Handle file = cb_handle_open("ls-curdir-log", CB_AccessFlag_Read |
+                                                  CB_AccessFlag_Write);
 
   cb_cmd cmd = {};
   cb_cmd_append(&cmd, "ls", "-lah", ".");
@@ -12,5 +13,5 @@ int main(int argc, char **argv) {
   cb_cmd_append(&cmd, "cat");
   cb_run(&cmd, .stdin = file);
 
-  cb_close(file);
+  cb_handle_close(file);
 }
index c1eb124fd828a45cb2c7662a53914102e048466d..ab655c7184fd6a3d101414f3cb236df42e9d74b1 100644 (file)
@@ -18,6 +18,7 @@
 #  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"
@@ -38,7 +39,6 @@
                             "-Wno-sign-conversion",                   \
                             "-Wno-unused-parameter"
 #  define CppAnnoyingWarnings CAnnoyingWarnings            \
-                              "-Wno-gnu-anonymous-struct", \
                               "-Wno-gnu-anonymous-struct", \
                               "-Wno-nested-anon-types"
 #  define Output "-o", Outfile
@@ -80,7 +80,7 @@ int main(int argc, char **argv) {
 
   cb_cmd cmd = {};
   cb_cmd_append(&cmd, "git", "submodule", "update", "--recursive");
-  cb_proc_handle codebase_updater = cb_run(&cmd, .async = true);
+  CB_Process codebase_updater = cb_run(&cmd, .async = true);
 
 #if OS_WINDOWS
   cb_cmd_push(&cmd, "cl.exe");
@@ -93,8 +93,7 @@ int main(int argc, char **argv) {
 #endif
 
   cb_cmd_append(&cmd, Output);
-  cb_cmd_append(&cmd, Infile, Codebase_Path);
-  cb_cmd_append(&cmd, GenericFlags, SystemSharedLibs);
+  cb_cmd_append(&cmd, Infile, Codebase_Path, GenericFlags);
 
   if (cpp) {
     cb_cmd_append(&cmd, CppFlags, CppAnnoyingWarnings);
@@ -108,19 +107,20 @@ int main(int argc, char **argv) {
     cb_cmd_append(&cmd, ReleaseFlags);
   }
 
+  if (sound) { cb_cmd_append(&cmd, Codebase_Module_Sound); }
   if (gui) {
     cb_cmd_append(&cmd, Codebase_Module_Gui);
-    cb_cmd_append(&cmd, OPENGL);
 #if OS_LINUX || OS_BSD
     cb_cmd_append(&cmd, !strcmp(cb_getenv("XDG_SESSION_TYPE"), "x11")
                         ? X11 : Wayland);
 #endif
   }
 
-  if (sound) {
-    cb_cmd_append(&cmd, Codebase_Module_Sound);
-  }
+  // 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_proc_wait(codebase_updater);
+  cb_process_wait(&codebase_updater);
   cb_run(&cmd);
 }