Exit Codes¶
rninja exit codes and their meanings.
Standard Exit Codes¶
rninja uses the same exit codes as Ninja for compatibility:
| Code | Meaning | Description |
|---|---|---|
0 |
Success | Build completed successfully |
1 |
Build failure | One or more targets failed to build |
2 |
Invalid arguments | Command-line argument error |
Extended Exit Codes¶
rninja adds additional codes for specific scenarios:
| Code | Meaning | Description |
|---|---|---|
3 |
Configuration error | Invalid configuration file |
4 |
Cache error | Cache operation failed |
5 |
Daemon error | Daemon communication failed |
6 |
Internal error | Unexpected internal error |
Build Failure Details¶
Exit code 1 indicates build failure. Check output for details:
rninja
echo $? # 1 = build failed
# Get more details
rninja -v # Verbose shows failed commands
rninja -d explain # Explains rebuild reasons
Usage in Scripts¶
Basic Error Handling¶
Detailed Error Handling¶
#!/bin/bash
rninja
status=$?
case $status in
0)
echo "Build succeeded"
;;
1)
echo "Build failed - check compiler errors"
exit 1
;;
2)
echo "Invalid arguments - check command"
exit 2
;;
3)
echo "Configuration error - check config files"
exit 1
;;
4)
echo "Cache error - try --no-cache"
# Retry without cache
rninja --no-cache
;;
5)
echo "Daemon error - try --no-daemon"
rninja --no-daemon
;;
*)
echo "Unknown error: $status"
exit 1
;;
esac
CI/CD Usage¶
Subtool Exit Codes¶
Subtools use the same convention:
| Command | Success | Failure |
|---|---|---|
rninja -t clean |
0 | 1 |
rninja -t compdb |
0 | 1 |
rninja -t query TARGET |
0 | 1 (not found) |
rninja -t cache-stats |
0 | 4 (cache error) |
Dry Run¶
Dry run (-n) returns success if the build would succeed:
JSON Output¶
With --json, exit codes are included in output:
{
"success": false,
"exit_code": 1,
"failed_targets": ["src/foo.o"],
"error": "compilation failed"
}
Ninja Compatibility¶
rninja maintains Ninja exit code compatibility:
| Ninja | rninja | Meaning |
|---|---|---|
| 0 | 0 | Success |
| 1 | 1 | Build failure |
| 2 | 2 | Invalid args |
Scripts written for Ninja work unchanged with rninja.
Common Scenarios¶
Build Succeeded¶
Compilation Error¶
Invalid Flag¶
Config Error¶
Signaling¶
If rninja receives a signal:
| Signal | Exit Code |
|---|---|
| SIGINT (Ctrl+C) | 130 |
| SIGTERM | 143 |
| SIGKILL | 137 |