CBuild wiki
--------------------------------------------
15.12.2024 v1.0 Initial release
Initial release [new]
--------------------------------------------
21.12.2024 v1.1 Few small additions
Proc.h [feature]
- Added 'cbuild_proc_start' function.
--------------------------------------------
27.12.2024 v1.2 Bugfix release
Compile.h [bugfix]
- Fixed typo ('CBUILD_CARG_WARN' -> 'CBUILD_CARGS_WARN').
Log.h [bugfix]
- Logger always use one output stream for its messages now.
General [bugfix]
- Added 'CBUILD_IMPL' macro to allow multiple includes in same
translation unit.
--------------------------------------------
10.01.2025 v1.3 New API features and bugfixes
common.h [bugfix]
- Fixed bug in macro (wrong variable name used).
- Switched 'CBuildFD' typedef from '__pid_t' to 'pid_t.
common.h [feature]
- Added 'cbuild_shift_expect' (allows to have error message on top of
'cbuild_shift').
- Added 'cbuild_assert'.
- Added 'noreturn' attribute to an assert function.
Command.h [bugfix]
- Added 'fd' prefix to 'stdin', 'stdout' and 'stderr' for compatibility
with libc that defines this names as a macro.
- Fixed typo in error message.
Log.h [feature]
- Logger now use 16-color ANSI mode.
- Added 'cbuild_vlog' that takes 'va_list' inserted of variadic
arguments.
General [bugfix]
- Added few 'const' annotations to pointers.
- Changed all asserts to 'cbuild_assert'.
--------------------------------------------
18.02.2025 v1.4 Small bugfix
common.h [bugfix]
- Wrong argument passed to '__CBUILD_ERR_PRINTF' in 'CBuild_UNREACHAGLE'.
--------------------------------------------
18.02.2025 v1.5 Bugfix release
impl.c [bugfix]
- Fixed buffer overflow in 'cbuild_dir_copy'.
- Improved 'cbuild_shift'.
General [change]
- Changed macro 'CBUILD_IMPL' to 'CBUILD_IMPLEMENTATION'.
--------------------------------------------
16.06.2025 v1.6 Full rewrite
Term.h [new]
- ANSI wrapper module.
Log.h [feature]
- Rely on 'Term.h' for colored output.
- Runtime configuration for minimum log level.
- Logger now support customizable formatting callbacks.
DynArray.h [new]
- Different implementation.
common.h [feature]
- Fixes for MacOS related to '__progname'.
- Better OS and API abstraction.
- Unified INIT_CAPACITY macro.
- Better IO abstraction.
- Assert now use proper IO abstractions.
- Types for WinAPI.
StringBuilder.h [new]
- Rely on new 'DynArray.h'.
- Few new operations.
Proc.h [feature]
- Better naming scheme.
- Added ability to allocate inter-process shared memory.
Command.h [feature]
- More consistent names.
Map.h [new]
- Hash-map implementation.
- Hash functions for string added.
Compile.h [change]
- Added consistent prefixes.
- Added output arg macro.
FS.h [change]
- Changes becouse of rewrite of other modules.
StringView.h [new]
- New implementation, better functionality.
- 'find', 'rfind' and 'contains' function.
- 'memrchr' is used on MacOS, *BSD and Glibc (if detected).
Compile.h [feature]
- Better naming.
- More macro.
Span.h [new]
- New module - array+size.
Stack.h [new]
- New module - basic re-sizable stack implementation.
DLload.h [new]
- Small wrapper for runtime loading of dynamic libraries, first code to
support 'WinAPI'.
FlagParse.h [new]
- CLI flag parser library.
- Supports long and short options.
- Support different flag arguments (but not support their types).
- Pre-parses positional arguments - collects them in separate buffer.
- Has build-in help and version flags and build-in help and version subs.
- Has function to print proper help for all defined flags.
- Allow overrides to help and version stubs using 'weak' linking.
General [feature]
- Better error handling.
- More integrated logging.
- Slight formatting change.
- Proper use of asserts in place of older 'exit(0);'.
--------------------------------------------
2025-07-01 v1.7 Fix in build script and few code fixes
General [bugfix]
- Add 'FlagParse.h' into a output library ;).
Compile.h [bugfix]
- New file now explicitly marked as executable.
- Allow adding compile argument for self-rebuild.
- Changed API of 'cbuild_cmd_to_sb' to match other 'cbuild_*_to_*'
functions.
FlagParse.h [bugfix]
- Fixed short flags for help and version.
- Fixed 'cbuild_flag_get_flag' to actually return NULL if flag was not
specified..
FS.h [change]
- Different implementation for 'cbuild_dir_list'.
- '.' and '..' now excluded.
- Entries now sorted alphabetically.
- Disable file descriptor auto inheritance on exec by default.
--------------------------------------------
2025-07-09 v1.8 Command updates
Command.h [feature]
- Allow to autokill child processes on exit on Linux.
Command.h [change]
- Changed cbuild_cmd_t format.
--------------------------------------------
2025-07-21 v1.9 Back to beginning
General
- Revert basic data types to be implemented as a raw macro.
Map is not rewritten because complexity is too high.
Map.h [bugfix]
- Fixed memory leak.
Span.h [remove]
- Removed because it is useless.
--------------------------------------------
2025-07-24 v1.10 API cleanup
Map.h [change]
- Rewrite with a new API. Same basic design, but now use void* and
elem_size to be type-agnostic. Should be much faster (less function
pointers) and have API more tailored to read-modify-write patter.
Map now access only a key (and only does 'read' access).
Compile.h [change]
- Now '-Wall', '-Wextra', '-Wno-comments', '-Wconversion' and
'-Wcast-align' is default set of compile args on selfrebuild.
FlagParse.h [change]
- 'cbuild_flag_flg_help' renamed to 'cbuild_flag_print_help'.
StringView.h [feature]
- Added compile-time constructor for string literals.
Stack.h [feature]
- Added 'cbuild_stack_top' to get top element in a read mode.
Proc.h [feature]
- Added 'cbuild_proc_is_running' to check process without blocking.
FS.h [feature]
- Added 'cbuild_fd_read' and 'cbuild_fd_write' to abstract POSIX 'read'
and 'write'.
FlagParse.h [feature]
- Added 'alias' command to DSL - allow to define long option aliases to
another option, used in help message and while parsing, but cannot be
targeted in 'cbuild_flag_get_flag'.
- Added flag groups. Added metadata key 'group' that allow to append flag
to a specific group. Added command 'group' that allow to add extended
description to a group. Groups will only be used during help generation
and flags from same group will be grouped under same heading.
Arena.h [new]
- Temporary allocated. Experimental module.
General [new]
- New allocator hook system.
DynArray.h [bugfix]
- If 'cbuild_da_resize' shrinks array and size becomes invalid it is
decrement.
StringView.h [bugfix]
- Function that can return '-1' now returns 'ssize_t' not 'size_t'.
--------------------------------------------
2025-08-05 v1.11 Cleanup and utf8
FS.h [feature]
- 'cbuild_fs_move' and 'cbuild_fs_remove' now try 'rename' before
copying.
Log.h [change]
- Renamed types.
Compile.h [bugfix]
- Now default warn flags include VLA warnings.
- Now if compilation failed in selfrebuild, old version will be run.
FlagParse.h [change]
- Short flag for version option is more more conventional 'V'.
StringView.h [feature]
- Optional utf8 supports.
StringBuilder.h [feature]
- Optional utf8 support.
General [bugfix]
- Now functions that takes no arguments properly have 'void' as
arguments.
--------------------------------------------
2025-08-18 v0.12 Switch to zero-ver
Compile.h [feature]
- New 'cbuild_selfrebuild_ex' allow to check more files before rebuild.
Command.h [change]
- Added new API, 'cbuild_cmd_run'.
Command.h [feature]
- Improved output of 'cbuild_cmd_to_sb'.
Proc.h [feature]
- Added ability to wait for multiple processes.
DynArray.h [feature]
- Added 'cbuild_da_remove_unordered'.
Compile.h [bugfix]
- Fixed 'CBUILD_CARGS_INCLUDE'.
FS.h [feature]
- Now 'cbuild_dir_create' will create all needed dirs recursively.
- Added 'cbuild_symlink', which forces symlink at destination.
- Added 'cbuild_path_normalize' to normalize paths without FS lookup.
Strips "<dir>/../: pairs, removes ".", remove trailing slashes
and collapse slash sequences.
FS.h [bugfix]
- 'cbuild_path_filetype' now use 'lstat'.
General [new]
- Now test on 'musl' libc too.
- Now test on strict POSIX.1-2001.
- Now I use zero-ver. This will fully break all version checks.
The only change is that leading '1' will be '0'.
"Real" version number will be monotonically incremented as always.
General [bugfix]
- Better OS-detect logic.
- First deprecated APIs.
- Added CBDEF for all functions (user-overridable).
- Fixed macro to document when they evaluate args multiple times.
--------------------------------------------
2025-09-02 v0.13
common.h [change]
- Better platform detection logic.
common.h [feature]
- New timing function.
- CBUILD_MAX and CBUILD_MIN macro.
Commang.h [feature]
- Added 'file_std*' as optional args that can be used to redirect
directly.
to a file.
- Added ability to control how many async workers can be spawned.
Command.h [remove]
- Few small changes to an API. Removed few useless args.
FS.h [feature]
- Added 'cbuild_dir_current' and 'cbuild_dir_set_current'.
- Now cbuild_path_normalize respect POSIX network paths stating from '//'
- Added 'CBUILD_FTYPE_MISSING'
FS.h [change]
- Now 'cbuild_path_filetype' return 'CBUILD_FTYPE_MISSING' on invalid
files.
Proc.h [feature]
- Ability to get amount of CPU cores.
- Ability to wait for any process from a list.
Log.h [feature]
- Added shortcuts for built-in log levels.
- Made CBUILD_LOG_PRINT print always (except if
CBUILD_LOG_NO_LOGS is enabled).
- Made enum for print levels not sparse. Extension of log level was not really
a useful feature.
- Removed cbuild_log_fmt.
- Exported few internal function to allow easier extension of logger
Arena.h [feature]
- Added ability to do checkpoint and rewind allocator to that checkpoint.
To reset allocator you should use '0' in place of a checkpoint.
StringView.h [bugfix]
- Fixed bug in rfind for strict POSIX
- Added early return for both find and rfind
StringView.h [change]
- Deprecated cbuild_sv_utf8cmp. cbuild_sv_cmp is enough.
StringBuilder.h [change]
- Deprecated cbuild_sb_utf8cmp. cbuild_sb_cmp is enough.
Compile.h [feature]
- Added 'CBUILD_CARGS_DEFINE_TEMP' and 'CBUILD_CARGS_DEFINE_VAL_TEMP'
that use 'cbuild_temp_sprintf' to support runtime values or names
for defines.
- Added 'CBUILD_CARGS_DEBUG_GDB' that expands to '-ggdb'. It will be fine
if you use gdb debugger or your debugger support all of gdb extensions.
- Added __cbuild_selfrebuild_ex_argv to allow having self-rebuilding
binaries in PATH. For normal binaries can be 'argv[0]'.
General [change]
- Changed CBDEF to CBUILDDEF.
- Remove build stage for a header.
--------------------------------------------
2025-01-12 v0.14
DynArray.h [feature]
- Add macro to allow easy creation of required structures.
Proc.h [bugfix]
- Handle EINTR in cbuild_proc_wait_code
Compile.h [bugfix]
- Selfrebuild now will not abort if argv0 binary not found
StringView.h [feature]
- Added cbuild_sv_chop_right* functions to chop from the end of string view
General [bugfix]
- Added some 'const' annotations
- Moved few functions to take parameters by value and not by pointer