Real-world builds
CLAP is a thin frontend over a real compiler toolchain, so it compiles real C/C++ codebases without project-specific porting. Every example below was run end to end on a clean checkout — no build system files, no configuration, no system compiler.
zstd 1.5.7 — assembly in the tree, one honest line
zstd is a harder case than lz4: the Huffman decoder ships hand-written x86-64 assembly (lib/decompress/huf_decompress_amd64.S) that the C side references — projects like this were unadoptable before assembly sources became first-class.
$ curl -sL https://github.com/facebook/zstd/archive/refs/tags/v1.5.7.tar.gz | tar xz
$ cd zstd-1.5.7 && clap init --adopt .
Created clap.toml adopting 57 existing source file(s)
…
derived include directories from the tree's headers: lib — written into includes so quoted includes across directories compile
$ echo 'exclude_sources = ["zlibWrapper/*.c"]' >> clap.toml
$ clap build
Built zstd-1.5.7 with zig (private)
$ cat lib/common/*.c lib/compress/*.c > big.bin && ./zstd-1.5.7 big.bin
big.bin : 21.56% ( 898 KiB => 193 KiB, big.bin.zst)
$ ./zstd-1.5.7 -q -d -f big.bin.zst -o out.bin; cmp big.bin out.bin && echo identical
identical
$ ./zstd-1.5.7 --version
*** Zstandard CLI (64-bit) v1.5.7, by Yann Collet ***The one line is honest boundary, not a hack: zlibWrapper/ is an optional shim that wraps external zlib — nothing in the zstd tree provides those symbols, because they are not zstd. The makefile links real zlib when building the gz-enabled CLI; adoption writes the baseline and one glob exclude drops the shim. Assembly needed zero configuration: the .S file was discovered, compiled without a language-standard flag and linked like any other unit.
lz4 1.10.0 — a multi-directory production tool, zero edits
lz4 is the canonical lib/programs-shaped C project: the library in lib/, the CLI in programs/, glued by a makefile passing -Ilib. Exactly the shape adoption used to miss.
$ curl -sL https://github.com/lz4/lz4/archive/refs/tags/v1.10.0.tar.gz | tar xz
$ cd lz4-1.10.0 && clap init --adopt .
Created clap.toml adopting 12 existing source file(s)
lib/lz4.c
programs/lz4cli.c
…
Review the list, then: clap build .
$ cat clap.toml | grep includes
includes = ["lib"]
$ clap build
Built lz4-1.10.0 with zig (private)
$ cat lib/*.c > bigfile.bin && ./lz4-1.10.0 -f bigfile.bin bigfile.lz4
Compressed 346375 bytes into 123772 bytes ==> 35.73%
$ ./lz4-1.10.0 -f -d bigfile.lz4 roundtrip.bin
bigfile.lz4 : decoded 346375 bytes
$ cmp bigfile.bin roundtrip.bin && echo identical
identicalNo Makefile reading, no -I flags, no source list by hand: adoption recursed the tree, skipped the tests/examples/bench directories that are not part of the artifact, resolved every quoted include against the tree's headers and derived includes = ["lib"] on its own.
SQLite — the most deployed database in the world
The SQLite amalgamation is a single translation unit of about 260,000 lines plus a shell. Zero build-system files, zero flags — clap init --adopt discovers both sources on its own:
$ unzip sqlite-amalgamation-3510100.zip && cd sqlite-amalgamation-3510100
$ clap init --adopt .
Created clap.toml adopting 2 existing source file(s)
shell.c
sqlite3.c
Review the list, then: clap build .
$ clap build
Checking and building 2 source file(s) with zig...
Built ./sqlite-amalgamation-3510100 with zig (private)About seven seconds for the debug build on an 8-core Linux VM. The result is a working database shell, verified against real SQL:
$ echo 'SELECT sqlite_version(); CREATE TABLE t(x); INSERT INTO t VALUES (42); SELECT x*2 FROM t;' | ./sqlite-amalgamation-3510100
3.51.1
84No configure, no Makefile, no Tcl — the pinned toolchain already provides everything the amalgamation needs. Explicit-file invocation works too when you do not want a project: clap build sqlite3.c shell.c -o sqlite3 --profile release.
Lua — a complete language interpreter
Lua ships as plain C89 sources with a hand-written Makefile. CLAP does not need the Makefile:
$ tar xzf lua-5.4.8.tar.gz && cd lua-5.4.8/src
$ clap build lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c \
ldebug.c ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c \
lmem.c loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c \
lstring.c lstrlib.c ltable.c ltablib.c ltm.c lua.c lundump.c lutf8lib.c \
lvm.c lzio.c -o lua --profile release
Checking and building 34 source file(s) with zig...
Built ./lua with zig (private)About 4 seconds, incremental rebuilds are near-instant thanks to the object cache. The interpreter runs immediately:
$ ./lua -e 'print("lua says: "..(2+3))'
lua says: 5The adoption path works too — point clap init --adopt at an unpacked release tree and it writes only clap.toml around the discovered sources. The Lua tree ships two entry points (lua.c for the interpreter, luac.c for the compiler), and one clap project links one executable: since 0.77 adopt keeps the likely primary entry point on its own and excludes the rest with exact instructions for swapping — no manual edit needed, the project builds green immediately. Verified against lua-5.4.7 end to end: 33 sources, zero flags, and the result runs real Lua:
$ clap init --adopt . # then remove src/luac.c from sources
$ clap build
Checking and building 33 source file(s) with zig...
Built ./lua-5.4.7 with zig (private)
$ ./lua-5.4.7 -e "print('hello from lua', 2^10, string.format('%.3f', math.pi))"
hello from lua 1024.0 3.142
$ ./lua-5.4.7 -v
Lua 5.4.7 Copyright (C) 1994-2024 Lua.org, PUC-RioWhat this demonstrates
- No per-project setup — if it is C or C++,
clap buildcompiles it. - Real optimization —
--profile releasepasses-O2class flags to the pinned Clang-based toolchain; these are production binaries, not toys. - Reproducibility — the same pinned Zig/Clang version builds these projects bit-for-bit the same way on Windows, Linux, and macOS hosts.
- Cross-compilation — add
--profile windows-x86_64and the same command produces a Windows.exeof SQLite or Lua from a Linux or macOS host.
Projects with their own generated build systems (autotools, CMake) can still be driven through clap build --backend cmake where a project ships a CMakeLists.txt — see the CMake examples.