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.
Append new argument to a command.
cbuild_cmd_t*
cmd Command object.const char*
val Element to append.Append new arguments to a command.
cbuild_cmd_t*
cmd Command object.const char**
vals Elements to append.size_t vals_cnt Number of elements to append.Append new arguments to a command.
cbuild_cmd_t*
cmd Command object.const char*
… Elements to append.Free command.
This should be used only if you want to free underlying memory, if
you just want to clear array and reuse it, setting size to
0 would be much faster.
cbuild_cmd_t*
cmd Dynamic array object.Convert command to string builder.
This function properly formats arguments with spaces by wrapping them
in '. But arguments that has both spaces and '
are not handler properly.
Convert command to string builder.
This function properly formats arguments with spaces by wrapping them
in '. But arguments that has both spaces and '
are not handler properly.
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.