Include "Build.h"

rurban1 pts0 comments

IncludeBuild

A build system in one C header v3.0.0

IncludeBuild is a single-header build system for C and C++. Build<br>scripts are C programs. It supports parallel compilation,<br>incremental rebuilds, executable and library targets, and a<br>built-in command line.

Basic Usage

#define IB_IMPLEMENTATION<br>#include "build.h"

int main(int argc, char** argv) {<br>ib_init(argc, argv);<br>ib_sources(ib_executable("app"), "**.c");<br>return ib_build();

$ cc -o build build.c # bootstrap<br>$ ./build # debug build<br>$ ./build release # release build<br>$ ./build run # build and run<br>$ ./build clean<br>$ ./build compdb # create compile_commands.json<br>$ ./build help

Changes to build.c or build.h cause<br>./build to recompile itself. Header and flag changes<br>rebuild affected targets. Use ./build -v to see why<br>each command ran.

Features

Parallel compilation with -jN; the default is your CPU count.

Incremental rebuilds using compiler depfiles and stored command lines.

Executable, static library, and shared library targets.

Transitive library ordering, include propagation, and automatic -fPIC.

Source globs with *, ?, and **.

Configuration through the ib struct.

Self-rebuilding build scripts and automatic compile_commands.json updates.

Platform Support

GCC-compatible toolchains (gcc, clang, MinGW) on Linux, macOS, and<br>Windows. Defaults honor $CC, $CXX, and<br>$AR.

Get Started

Download build.h

View source<br>Download build.h

curl -O https://includebuild.com/build.h

Copy<br>build.h into your project, write<br>build.c, and compile it once.

build library include includebuild header targets

Related Articles