r/cprogramming • u/sisoyeliot • Apr 13 '26
I built a zero-dependency, self-hosting C/C++ build system configured entirely in C (Loom)
Hey r/cprogramming!
I've been working on a project called Loom, and I'd love to share it and get some feedback from the community. Basically it's a cross-platform C/C++ build system that is fully self-hosting, requires zero external dependencies, and uses pure C11 for its build configurations (build.c).
I built this because I was frustrated with CMake's bizarre syntax and having to learn complex new Domain Specific Languages (DSLs) or wrestling with Makefiles just to compile my C projects. I figured: if I'm writing C code, why not configure the build pipeline dynamically using a clean C API?
Here's the repository link, feel free to contribute, I'll be looking for more ways to improve the project.
Key Features
- "Configuration as code" (inspired by build.zig): You define your build targets using a clean, readable API in a
build.cfile. You get all the benefits of C (macros, variables, logic) with none of the typical CMake friction. - Zero-dependency and self-hosting: Written in strictly standard C11. Loom is capable of fully compiling and rebuilding itself perfectly.
- Truly cross-platform (native windows): It runs natively on macOS, Linux, FreeBSD, and Windows. I recently finished a complete Windows port where it leverages raw Win32 APIs (like CreateProcessA, FindFirstFileA) instead of relying on slow POSIX emulation layers like Cygwin or MSYS2.
- Fast and incremental: Features intelligent dependency tracking (parsing depfiles and using file hashes) so it only recompiles what actually changed. It also auto-detects your logical CPU cores and compiles asynchronously in parallel.
Batteries included:
- Build Executables, Static Libraries (
.a/.lib), and Shared Libraries (.so/.dll). - Built-in wildcard/recursive globbing (
add_glob) to just throw a directory of sources at it. - Direct
pkg-configintegration (link_system_library). - Instant project scaffolding (
loom init).
- Build Executables, Static Libraries (
Example build.c
Here is what it looks like to configure a modern C project:
#include <loom.h>
void build(loom_build_t *b) {
loom_target_t *exe = add_executable(b, "my_awesome_app");
add_glob(exe, "src/*.c");
add_include_dir(exe, "include");
set_standard(exe, LOOM_C11);
set_optimization(exe, LOOM_OPT_RELEASE_FAST);
link_system_library(exe, "raylib");
}Building this project from scratch has taught me an incredible amount about platform-specific process abstractions, caching logic, and avoiding standard POSIX traps on Windows.
I would love to hear your thoughts, feedback, or any critique on the codebase architecture! Let me know what you think.
5
u/The_Northern_Light Apr 13 '26
You might enjoy https://github.com/tsoding/nob.h
4
u/imagineAnEpicUsrname Apr 13 '26
Just wanted to say that no dependency approach is not necessarily a good thing. If its a small project, whatever works, but there is rarely a need to re-implement sha256 or whatever when every unix and BSD machine has libopenssl
3
u/Thesk790 Apr 13 '26
Man, this is incredible, I love the use of the functions, could you consider to add a
add_sourcesmacro (which takes anchar *array as argument)? Man, this is really fantastic! Congratulations! I will start to use it now if you don't care about3
u/zhivago Apr 13 '26
If you're going to do that, why not just make it a library which you can call normally?
2
u/rphii_ Apr 13 '26 edited Apr 13 '26
I also built some build system a while ago (https://github.com/rphii/bd) when I was just transitioning from IDEs on windows to not-IDEs linux but whatever that's another story.
I stopped fighting with build systems once I found meson. I never heard anyone say that it's frustrating, only that it lacks some things that Makefiles offer lol. if I didn't like meson as much as I did, I'd probably use nob.h
1
u/markand67 Apr 13 '26
When you use -std=c11 you hide POSIX functions.
And you make CFLAGS a requirement (it should not) meaning that
make CFLAGS=-std=gnu11break yours. Either use GNU extensionoverride CFLAGS += your_internal_flagsor use other variables names for non-user modifiable make variables.2
u/[deleted] Apr 13 '26
[removed] — view removed comment