Crates.io | ninja_syntax |
lib.rs | ninja_syntax |
version | 0.1.1 |
source | src |
created_at | 2023-07-08 14:36:30.98578 |
updated_at | 2023-07-08 15:06:47.310578 |
description | A Rust port of ninja_syntax.py |
homepage | https://github.com/sztomi/ninja_syntax |
repository | https://github.com/sztomi/ninja_syntax |
max_upload_size | |
id | 911504 |
size | 19,260 |
This is a port of ninja_syntax.py to Rust. It allows you to easily emit ninja build files from Rust with a syntax that is pretty similar to the official python module from the ninja repo.
use ninja_syntax::*;
use std::path::Path;
fn main() {
let mut nw = NinjaWriter(Path::new("build.ninja"));
nw.comment("Hello this is a comment");
nw.newline();
let rule = NinjaRule::new("cc", "cc $in -o $out");
nw.rule(&rule);
let mut build = NinjaBuild::new(&["test.o"], "cc");
build.inputs(&["test.c"]);
nw.build(&build);
// write the file to disk
nw.close().unwrap();
}
Originally written by Tobias Hieta, forked and licensed under MIT (with permission from the
author) by Tamás Szelei. Most of the code is the same, but slight changes were made to make it more
ergonomic and to use textwrap
instead of a custom implementation of word wrapping. Finally, to
apply the correct indentation (which is two spaces). Originally part of sa_ninja_gen, now
being published as a separate crate.