Cuilt is a build system for C that does not need installation. To see in-production usage, check out collaps.
Inspired by but not based on Tsoding's nobuild.
Cuilt is not yet crossplatform. Works on linux for now.
Place cuilt.c
in your project's root directory alongside with a custom c file, for example project.c
.
The most basic project.c
would be:
#include "cuilt.c"
CONFIG({ })
Then run to build your project:
cc project.c -o project
./project build
You don't have to build the project
tool ever again, if you change the configuration, it will automatically rebuild itself.
Note, that cuilt.c
contains the main function and other impementations too. Define _CUILT_NO_MAIN
or _CUILT_NO_IMPLEMENTATION
to disable them.
./project [OPTIONS] [COMMAND] [EXTRA-ARGS]
Commands:
build
- build the project - defaultrun
- run the executable withEXTRA-ARGS
if specifiedtest
- call the test function - setconfig.process.test
first (see below)deploy
- test the project than stage, commit, and push changes if test was successful.join(" ", EXTRA-ARGS)
becomes the commit messageclean
- clean - setconfig.process.clean
first (see below)
Options:
-cc <CC>
- overrideconfig.cc.command
withCC
-cflags <CFLAGS>
- overrideconfig.cc.flags
withsplit(" ", CFLAGS)
-log <LEVEL:debug|info|warn|error|fatal>
- overrideconfig.log_level
withLEVEL
-release|-debug
- build in release or debug mode - debug by default-force
- force build for each object file, even if it's up-to-date
Currently available config options are (with the default values):
#include "cuilt.c"
CONFIG({
.project = {
.name = basename(cwd()), // name of the project and the output executable
.source = "src", // source directory
.bin = "bin", // output directory
.test = "test", // test directory
},
.cc = {
.command = "cc",
.flags = LIST("-Wall", "-Wextra", "-Werror", "-std=c11"),
.debug_flags = LIST("-g", "-O0"),
.release_flags = LIST("-O3", "-dNDEBUG"),
.pp = "cpp" // preprocessor command
},
.process = { // can be set to customize commands
.init = NULL, // will be called before any command
.build = &__build, // default build function
.run = &__run, // default run function
.test = NULL,
.deploy = &__deploy, // default deploy function
.clean = NULL,
},
.log_level = LOG_INFO, // default log level
})