CBuild wiki
Command runner
License: GPL-3.0-or-later.
Command structure - dynamic array of arguments.
dataconst char**
has same format as arg in execv except NULL
termination.
Convert command to string builder.
This function properly formats arguments with spaces by wrapping them
in ". This function additionally escape $,
\``,“and\` in all contexts.
struct cbuild_cmd_opts_t {
// Async
cbuild_proclist_t* procs; // Non-null implies async
cbuild_proc_t* proc; // Non-null implies async
// Redirect 'fdstd* ' and 'file_std*' is mutually exclusive.
const cbuild_fd_t* fdstdin;
const char* file_stdin;
const cbuild_fd_t* fdstdout;
const char* file_stdout;
const cbuild_fd_t* fdstderr;
const char* file_stderr;
// Async
int async_threads; // 0 means implementation-defined. -1 means unlimited. Expects 'procs' to be a valid empty array.
// Flags
union {
uint32_t flags;
struct {
uint32_t no_reset : 1;
uint32_t autokill : 1;
uint32_t no_print_cmd : 1;
uint32_t : 29;
};
};
};Configuration for command.
This structure consists of a few separate blocks:
cbuild_proclist_t*
procs Process list used for async
execution. Non-NULL value enables
async.cbuild_proc_t*
proc Process return value used for
async execution. Non-NULL value
enables async.int async_threads Control how many threads
async runner can spawn (works in conjunction with procscbuild_proclist_t*).
0 means implementation-defined. -1 means
unlimited.const cbuild_fd_t*
fdstdin Redirect stdin
to some file descriptor.const char*
file_stdin Redirect
stdin to some file.const cbuild_fd_t*
fdstdout Redirect
stdout to some file descriptor.const char*
file_stdout Redirect
stdout to some file.const cbuild_fd_t*
fdstderr Redirect
stderr to some file descriptor.const char*
file_stderr Redirect
stderr to some file.uint32_t:1
no_reset By default
size filed of command is reset. This flag disables this
feature.uint32_t:1
autokill Works only on Linux.
Automatically kills process if parent dies.uint32_t:1
no_print_cmd By default command is
printed as TRACE log. This flag disable this log
message.Run command. This function is semi-internal.
Run command.
cbuild_cmd_t*
cmd Command to execute....cbuild_cmd_opts_t
… Fields of configuration structure in
initializer-list form.