CBuild wiki
Some helpers specifically for a compilation
License: GPL-3.0-or-later.
CBUILD_CC Look
in source line 17This will hold compiler command for compiler that was used to compiler CBuild.
CC Look
in source line 27CBuild can provide bare define CC. Because it is not
prefixed it can be disabled. This defined will be an alias to
CBUILD_CC. If CBUILD_NO_CC is defined, CBuild
will not provide CC define.
Default warning options. Enables almost all warnings except
-Wcomments and -Woverride-init.
Promote all warnings to errors.
Setup profiles,
Add debug symbols,
Add debug symbols targeting gdb.
Enable multithreading (eg. add -pthread for POSIX).
Add a define based on compile-time literal.
Add a define based on runtime string. Uses cbuild_temp_malloc.
Add a define with a value. Both based on compile-time literal.
Add a define with a value. Both based on runtime string. Uses cbuild_temp_malloc.
Remove define based on compile-time literal.
Add include based on compile-time literal.
Add library include (-l) based on compile-time
literal.
Add library directories (-I and -L) based
on compile-time literal.
Set standard based on compile-time literal.
Simple wrapper for self-rebuild. Only argv[0]
is used. Other elements are used only to re-exec new binary with same
arguments.
Complex wrapper for self-rebuild. Only argv[0]
is used. This function allow to specify additional files to be checked
when decision is made to rebuild binary or not.
CBUILDDEF void __cbuild_selfrebuild(int argc, char** argv,
const char* argv0_path, cbuild_cmd_t files);Perms self-rebuild.
int argc ARGC of program.char**
argv ARGV of program.const char*
argv0_path Path to file specified by
argv[0].cbuild_cmd_t files Primary file as first element and
additional dependency files as other.If any of the files from filescbuild_cmd_t are newer
than argv[0].
If any of files in this array does not exist program will exit with
error.
CBUILD_CC is used as compiler.
CBUILD_CARGS_WARN is used as default set of arguments. cbuild_selfrebuild_hook
is called to resolve dynamic or user-provided arguments.
This function receives command before files are appended and can modify it.
This function is called by default __cbuild_selfrebuild
Compare mtime of 2 files. Same check as done by
make.
=0 - Output is newer
than input.<0 - Error.>0 - Output is
older than input.CBUILDDEF int cbuild_compare_mtime_many(const char* output, const char** inputs,
size_t num_inputs);Compare mtime of 1 output file and multiple input files. Same check
as done by make.
=0 - Output is newer
than input.<0 - Error.>0 - Output is
older than input. Number of files that are newer.