A make-like build tool written in Rust that provides dependency resolution and task execution capabilities.
BNAO is a simple yet powerful build automation tool that allows you to define tasks with dependencies and execute them in the correct order. It's similar to Make.
- Dependency Resolution: Automatically resolves task dependencies using topological sorting
- Cycle Detection: Prevents circular dependencies with built-in cycle detection
- Task Execution: Executes shell commands for each task
- Simple Syntax: Easy-to-read task definition format
- CLI Interface: Command-line interface for listing and building targets
- Rust 1.70+ (2024 edition)
- Cargo package manager
# Clone the repository
git clone <repository-url>
cd bnao-own
# Build the project
cargo build --release
# Install globally (optional)
cargo install --path .# List all available targets
bnao list
# Build a specific target
bnao build <target-name># List available targets
bnao list
# Build the 'link' target (which will also build its dependencies)
bnao build linkBNAO uses a simple text-based format for defining tasks. Create a file named bnao_dependency_file in your project root:
# Clean build artifacts
clean:
echo "Cleaning build directory..."
rm -rf build/
mkdir -p build/
echo "Build directory cleaned"
# Compile source files
compile: clean
echo "Compiling source files..."
gcc -c src/main.c -o build/main.o
gcc -c src/utils.c -o build/utils.o
echo "Compilation complete"
# Link object files into executable
link: compile
echo "Linking object files..."
gcc build/main.o build/utils.o -o build/myapp
echo "Linking complete"
# Run tests (depends on link)
test: link
echo "Running tests..."
./build/myapp --test
echo "All tests passed"- Target Definition: Targets are defined with a colon (
:) at the end of the line - Dependencies: Dependencies are listed after the colon, separated by spaces
- Commands: Commands are indented with tabs or 4 spaces
- Comments: Lines starting with
#are treated as comments - Empty Lines: Empty lines are ignored
bnao-own/
├── src/
│ ├── main.rs # CLI interface and main entry point
│ ├── bnao_parser.rs # Parser for BNAO files
│ ├── dependency_resolver.rs # Dependency resolution logic
│ └── bnao_executor.rs # Task execution engine
├── bnao_dependency_file # Example task definitions
├── sample_bnao_file # Simple example file
├── Cargo.toml # Rust project configuration
└── README.md # This file
- Parses BNAO files into structured task definitions
- Handles comments, empty lines, and command indentation
- Returns a HashMap of task names to BnaoTask structs
- Implements topological sorting for dependency resolution
- Detects circular dependencies
- Returns tasks in the correct execution order
- Executes shell commands for each task
- Handles command failures and error reporting
- Provides output from successful commands
BNAO provides comprehensive error handling for:
- Circular Dependencies: Detects and reports circular dependency chains
- Missing Tasks: Reports when referenced tasks don't exist
- Command Failures: Captures and displays command execution errors
- Parse Errors: Reports syntax errors in BNAO files
clean:
rm -rf build/
mkdir -p build/
compile: clean
gcc -c src/main.c -o build/main.o
gcc -c src/utils.c -o build/utils.o
link: compile
gcc build/main.o build/utils.o -o build/myapp
test: link
./build/myapp --test
install: link
cp build/myapp /usr/local/bin/install:
npm install
build: install
npm run build
test: build
npm test
deploy: test
npm run deploy- clap: Command-line argument parsing
- std: Standard library for file I/O, process execution, and collections
cargo testcargo buildcargo run -- list
cargo run -- build <target>- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source. Please check the license file for details.