DEV Community

Cover image for Example Project with rbot: A Simple, Fast, and Modern C/C++ Build System
Aidomx Dev
Aidomx Dev

Posted on AI-assisted

Example Project with rbot: A Simple, Fast, and Modern C/C++ Build System

If you are a C or C++ developer, chances are you have experienced "CMake fatigue." You just want to compile a few source files, but suddenly you are writing 50 lines of boilerplate, dealing with CMakeLists.txt quirks, or wrestling with Ninja's rigid DAG (Directed Acyclic Graph) requirements.

What if building your project could be as simple as writing a 2-line configuration file?

Meet rbot (Rupa Builder Of Target). It is a modern, declarative build system designed with one core philosophy: "A simple builder for you."

In this article, we will walk through how to build C and C++ projects using rbot, from a simple single project to a complex workspace with circular dependencies.


1. The Single Project (Zero Boilerplate)

Let's start with the absolute basics. You have a standard C project with a src/ folder.

With rbot, you don't need a massive configuration file. You just initialize it:

$ rbot init
> Created   : Buildfile
Enter fullscreen mode Exit fullscreen mode

If you open the generated Buildfile, you will see something beautifully minimal:

use project
Enter fullscreen mode Exit fullscreen mode

That's it. rbot relies on Convention over Configuration. It automatically looks into the src/ directory, finds your .c files, picks the best available compiler (GCC or Clang), and builds your project.

$ rbot
> Build with gcc -std=gnu11
[  1/  2] OK    0.05s  src/main.c
[  2/  2] OK    0.04s  src/utils.c
> Linking   : bin/my_app

> Summary
Target   : bin/my_app
Status   : Success
Enter fullscreen mode Exit fullscreen mode

What about C++?

rbot v0.2.2 introduces interactive initialization and first-class C++ support. Run rbot init -p, and it will ask for your language:

$ rbot init -p
| Project name? [my_cpp_app]: 
| language? [c, cpp]: cpp
Enter fullscreen mode Exit fullscreen mode

It automatically generates a src/main.cpp and writes the appropriate C++ configuration:

use project
std = c++17
Enter fullscreen mode Exit fullscreen mode

You can even override the compiler effortlessly: compiler = clang++. rbot handles the rest, including generating a valid compile_commands.json for your LSP (clangd/ccls) automatically.


2. The Workspace (Solving Circular Dependencies Natively)

Here is where rbot truly shines and separates itself from low-level executors like Ninja.

In a real-world monorepo or workspace, it is very common for modules to have circular dependencies (e.g., Module A needs Module B, and Module B needs Module A).

If you try to model this in Ninja, it will throw a dependency cycle error. To fix it, you are forced to manually flatten your graph to the object file (.o) level or rely on linker tricks like --start-group.

rbot understands the concept of a Workspace. It doesn't force you to flatten your graph. You just declare your intent:

# Buildfile.ws
use workspace
projects = alpha, beta

# Alpha depends on Beta
alib.linux = beta
# Beta depends on Alpha
blib.linux = alpha
Enter fullscreen mode Exit fullscreen mode

When you run rbot -w, it uses a Two-Phase Build architecture:

  1. Library Pass: It compiles all objects and packages them into static/shared libraries for all projects simultaneously.
  2. Binary Pass: It links the final binaries once all libraries are ready.

You get a clean, logical build without ever touching a linker flag or flattening your directory structure.


3. Under the Hood: Why is it so fast?

rbot isn't just simple; it is aggressively optimized.

Content-Based Fingerprinting

Traditional build systems rely on file timestamps. If you touch a file, they rebuild it, even if the content hasn't changed. rbot uses content-based fingerprinting. It hashes the file contents. If the hash hasn't changed, rbot skips the compilation entirely.

In our benchmarks, this makes rbot up to 60x faster than standard Make/Ninja setups in "touch" scenarios.

Memory-First Serialization

Generating compile_commands.json can be slow if done via thousands of tiny fprintf calls. rbot uses a memory-first approach: it serializes the entire JSON structure into a pre-allocated memory buffer and writes it to disk in a single fwrite syscall. This reduces I/O overhead drastically, especially in containerized or emulated environments (like proot-distro).


4. Honest Benchmarking

I believe in intellectual honesty. rbot is not a silver bullet that beats Ninja at everything. Ninja is a low-level DAG executor and is incredibly fast at noop (no-operation) builds.

However, rbot excels where it matters most to developers: Cold builds, touch builds, and workspace orchestration.

Instead of hiding its weaknesses, rbot includes a built-in compare.sh script to benchmark itself against Make, Ninja, and CMake. If rbot loses in a specific scenario, it's a signal to optimize the core, not to make excuses.


Conclusion

rbot is built for developers who want to spend their time writing code, not debugging build scripts. It provides a modern, polyglot-ready (C/C++ currently, with more to come), and blazing-fast environment without the bloat.

If you are looking for a breath of fresh air in your C/C++ workflow, give rbot a try.

"A simple builder for you."

📂 GitHub Repository
📄 Documentation

Have you tried rbot? Let me know your thoughts in the comments below!

Top comments (0)