Development Setup¶
Set up your environment for rninja development.
Prerequisites¶
Required¶
- Rust: 1.70 or later
- Git: For version control
- Ninja: For comparison testing
Optional¶
- Docker: For containerized builds
- Python 3: For test scripts
- CMake/Meson: For integration tests
Quick Setup¶
# Clone repository
git clone https://github.com/anthropics/rninja
cd rninja
# Build
cargo build
# Run tests
cargo test
# Run rninja
cargo run -- --version
Detailed Setup¶
Install Rust¶
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install stable toolchain
rustup default stable
# Add components
rustup component add rustfmt clippy
Clone Repository¶
# Clone your fork
git clone https://github.com/YOUR-USERNAME/rninja
cd rninja
# Add upstream
git remote add upstream https://github.com/anthropics/rninja
# Keep in sync
git fetch upstream
git merge upstream/main
Build¶
# Debug build (fast compile, slow run)
cargo build
# Release build (slow compile, fast run)
cargo build --release
# Build all binaries
cargo build --all
Binaries are in target/debug/ or target/release/.
Run¶
Project Structure¶
rninja/
├── src/
│ ├── main.rs # CLI entry point
│ ├── cli.rs # Argument parsing
│ ├── config.rs # Configuration
│ ├── build/ # Build execution
│ ├── cache/ # Caching subsystem
│ ├── daemon/ # Daemon process
│ ├── server/ # Remote cache server
│ └── ...
├── tests/ # Integration tests
├── benches/ # Benchmarks
├── docs/ # Internal docs
├── documentation/ # User docs (MkDocs)
├── Cargo.toml # Dependencies
└── README.md
IDE Setup¶
VS Code¶
Install extensions: - rust-analyzer - CodeLLDB (debugging) - Even Better TOML
Settings (.vscode/settings.json):
IntelliJ/CLion¶
- Install Rust plugin
- Open
Cargo.tomlas project - Enable clippy in settings
Vim/Neovim¶
With rust-analyzer LSP:
Environment Variables¶
For development:
# Enable debug logging
export RUST_LOG=rninja=debug
# Use local cache dir
export RNINJA_CACHE_DIR=/tmp/rninja-dev-cache
# Disable daemon for testing
export RNINJA_DAEMON_MODE=off
Test Data¶
Create test fixtures:
# Generate test project
./scripts/generate-test-project.sh large /tmp/test-project
# Create build.ninja
cd /tmp/test-project
cmake -G Ninja .
Debugging¶
VS Code¶
Launch config (.vscode/launch.json):
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug rninja",
"cargo": {
"args": ["build", "--bin=rninja"]
},
"args": ["-C", "/path/to/project"],
"cwd": "${workspaceFolder}"
}
]
}
Command Line¶
Logging¶
# Verbose logging
RUST_LOG=trace cargo run -- -C /project
# Specific module
RUST_LOG=rninja::cache=debug cargo run
Building Documentation¶
cd documentation
# Install dependencies
pip install -r requirements.txt
# Serve locally
mkdocs serve
# Build static site
mkdocs build
Benchmarking¶
# Run benchmarks
cargo bench
# Specific benchmark
cargo bench cache_lookup
# Compare with baseline
cargo bench -- --save-baseline before
# Make changes
cargo bench -- --baseline before
Common Tasks¶
Update Dependencies¶
Format Code¶
Lint¶
Generate Docs¶
Troubleshooting¶
Build Errors¶
Test Failures¶
Linker Errors¶
On Linux, ensure you have:
On macOS:
Next Steps¶
- Code Style: Coding conventions
- Testing: How to write tests
- Contributing Guide: Contribution process