A simple C build system.
- Find all .c files recursively starting from project root.
- Parse
#includelines and figure out which.cfiles depend on which.hfiles. - Recompile the
.ofile if either.cfile or any of the header files it depends on is newer than the.ofile. - Link all the
.ofiles into the binary.
- Copy
cbuild.pyto your project root. - Run
./cbuild.py configto see the default config. - Create
cbuild.jsonif you want to override any of the config values. - Run
./cbuild.py runto build and run your project. - See the output of
./cbuild.py helpfor more info.
Why? Easier to update, get bug fixes faster.
This shouldn't be necessary as time goes on and cbuild.py becomes more and more complete.
git submodule add https://github.com/itsfarseen/cbuild.py
ln -s cbuild.py/cbuild.py cbuildCommit the changes:
git add .gitmodules cbuild.py cbuild
git commitNow you can run cbuild using ./cbuild
Create a cbuild.json file in the project root.
{ // Scan only files under this folder. // Files outside this folder (eg. system libraries) are assumed to never change. "project_root": ".", // C compiler executable. "cc": "gcc", // Flags to pass in during compiling "cflags": "", // Flags to pass in during linking "ldflags": "", // Ignore .c files in these folders. "ignore_dirs": [ ".git", ".ccls-cache" ], // Put build artifacts in this folder. "build_dir": "build", // Path to the final binary, relative to the build folder. "binary": "main", // List of dependencies. // For each entry in this list, // `pkg-config --cflags {lib}` will be invoked to get the cflags and // `pkg-config --libs {lib}` will be invoked to get the ldflags. // Run `pkg-config --list-all` to see libraries available to in your system. "dependencies": [] }