CLI Reference¶
Complete reference for the rninja command-line interface.
Synopsis¶
Description¶
rninja is a drop-in replacement for Ninja with built-in caching. It reads build.ninja files and executes build commands, using a content-addressed cache to skip redundant work.
Options¶
Build Control¶
-j, --jobs <N>¶
Run N jobs in parallel.
0= use all available CPU cores (default)- Any positive integer limits parallelism
-k, --keep-going <N>¶
Keep going until N jobs fail.
1= stop on first failure (default)0= keep going indefinitely- Any positive integer sets the failure limit
-l, --load-average <N>¶
Do not start new jobs if the system load average is greater than N.
-n, --dry-run¶
Dry run mode. Print commands that would be executed but don't run them.
File Selection¶
-f, --file <FILE>¶
Specify input build file. Default is build.ninja.
-C, --dir <DIR>¶
Change to DIR before doing anything else.
Output Control¶
-v, --verbose¶
Show all command lines while building.
--json¶
Output in JSON format for machine consumption. Useful for scripts and AI agents.
Debugging¶
-d, --debug <MODE>¶
Enable a debugging mode. Available modes:
| Mode | Description |
|---|---|
explain |
Explain why targets are being rebuilt |
keepdepfile |
Don't delete depfiles after processing |
stats |
Show execution statistics |
--trace <FILE>¶
Write Chrome trace output to FILE. Open with chrome://tracing.
Subtools¶
-t, --tool <TOOL>¶
Run a subtool instead of building. See Subtools for details.
Daemon Control¶
--no-daemon¶
Disable daemon mode. Run in single-shot mode without connecting to or spawning a daemon.
--daemon-socket <PATH>¶
Use a custom daemon socket path.
Other Options¶
-w, --log <FILE>¶
Write build log to FILE. (Experimental)
--version¶
Print version information.
--help¶
Print help information.
Arguments¶
[TARGETS...]¶
Targets to build. If not specified, builds the default targets defined in the build file.
rninja # default targets
rninja target1 target2 # specific targets
rninja all # 'all' target if defined
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Build failed |
| 2 | Invalid arguments |
Environment Variables¶
rninja respects these environment variables:
| Variable | Description |
|---|---|
RNINJA_CACHE_ENABLED |
Enable/disable caching (0 or 1) |
RNINJA_CACHE_DIR |
Cache directory location |
RNINJA_CACHE_MODE |
Cache mode (local, remote, auto) |
RNINJA_CACHE_REMOTE_SERVER |
Remote cache server URL |
RNINJA_CACHE_TOKEN |
Remote cache authentication token |
See Environment Variables for complete list.
Configuration Files¶
rninja loads configuration from these locations (in order):
.rninjarc(project directory)~/.rninjarc(home directory)~/.config/rninja/config.toml(XDG config)
See Config Files for format details.
Examples¶
Basic Builds¶
# Build default targets
rninja
# Build specific target
rninja my_target
# Build multiple targets
rninja target1 target2
Build Configuration¶
# Use 4 parallel jobs
rninja -j4
# Build in different directory
rninja -C out/Release
# Use different build file
rninja -f release.ninja
Debugging¶
# See why targets rebuild
rninja -d explain
# Verbose output
rninja -v
# Dry run
rninja -n
# Generate trace
rninja --trace trace.json
Automation¶
Subtools¶
# Clean build outputs
rninja -t clean
# Show dependencies
rninja -t deps target
# Generate compile_commands.json
rninja -t compdb > compile_commands.json
# Check cache
rninja -t cache-stats
Ninja Compatibility¶
rninja supports all standard Ninja flags:
| Ninja Flag | rninja Support |
|---|---|
-C DIR |
Yes |
-f FILE |
Yes |
-j N |
Yes |
-k N |
Yes |
-l N |
Yes |
-n |
Yes |
-t TOOL |
Yes |
-d MODE |
Yes |
-v |
Yes |
-w |
Yes (experimental) |
Additional rninja Flags¶
These flags are rninja extensions:
| Flag | Description |
|---|---|
--json |
Machine-readable JSON output |
--trace FILE |
Chrome trace output |
--no-daemon |
Disable daemon mode |
--daemon-socket PATH |
Custom daemon socket |
See Also¶
- Basic Usage - Common usage patterns
- Subtools - All available subtools
- Configuration - Configuration options