Turtle
Clone of the Ninja build system written in Rust
Goals
- Safe (no
unsafe
) and fast implementation of the Ninja build system in Rust - Frontend support for high-level programming languages
- Full output from build rules and no output from Turtle by default
- More customizable build/rule/progress/error output
Turtle is originally written for the Pen programming language. Therefore, we support only dynamic dependencies but not C/C++ header dependencies currently. Your contribution is welcome!
Install
cargo install turtle-build
Usage
turtle
For more information, see turtle --help
.
Compatibility
Turtle aims to support full syntax of the Ninja build files. It also supports basic command line arguments but is not going to implement all the original options (e.g. -t
option.)
Syntax
-
build
statement- Explicit outputs
- Explicit inputs
- Implicit outputs
- Implicit inputs
- Order-only inputs
-
phony
rule
-
rule
statement -
default
statement -
include
statement -
subninja
statement -
pool
statement - Global variables
- Build-local variables
-
in
andout
special variable
Command line arguments
-
-f
custom build file option -
-j
job limit option -
-k
keep-going option -
-C
change-directory option
Others
- Circular build dependency detection
- Circular build file dependency detection
-
builddir
special variable - Dynamic dependencies
- Implicit inputs
- Implicit outputs
- Circular build dependency detection
- C/C++ header dependencies
-
depfile
option -
deps
option
-
- Windows support
Technical notes
Something different from the traditional build systems and notable in Turtle is that it solves parallel builds similar to parallel graph reduction naturally, where you modify graph structures in parallel and reduce it into a solution, thanks to an ecosystem of futures and stackless coroutines in Rust.
Here is how parallel builds work in Turtle:
- Turtle spawns futures for all builds of default targets.
- Depending on builds' configuration, they spawn more futures or resolve their futures.
- If they require some input targets to be built first, they spawn those builds for input targets all in parallel.
- Those futures are scheduled and run in parallel by an asynchronous runtime in Rust.
- Builds complete when all the futures are resolved.
Currently, Turtle uses a topological sort algorithm only to detect dependency cycles but not for scheduling of build jobs.
Turtle is powered by the following neat projects and others!
- tokio: Asynchronous runtime for Rust
- sled: Embedded database in Rust
- petgraph: Graph algorithms in Rust
Similar projects
License
Dual-licensed under MIT and Apache 2.0.