depgraph
Makefile-style build of native stuff, for use in build.rs. Checks modified
times on output and input files, and then runs operation if there are changes
to input files.
Example
This example builds object files from assembly using yasm when the assembly
files change.
extern crate depgraph;
use depgraph;
fn build_assembly(out: &str, deps: &[&str]) -> Result<(), String> {
let out_dir = Path::new(out).parent().unwrap();
fs::create_dir_all(out_dir).unwrap();
Command.new("yasm").args(&["-f", "elf64", "-o"]).arg(out).args(deps)
.status().unwrap();
Ok(())
}
fn main() {
let out_dir = Path::new(env::var("OUT_DIR").unwrap());
let mut graph = depgraph::DepGraphBuilder::new();
graph.add_rule(out_dir.join("out/path/file.o").to_str().unwrap(),
&["src/input_file.asm"],
build_assembly);
let graph = graph.build().unwrap();
graph.make(false).unwrap();
}
TODO
- Preserve dependency order
- Automated tests
- More generics (not sure if this would add anything)
- Optimizations (again not sure this would add anything)