duncan­lock­.net

Ninja is a surprisingly nice build system for tiny projects

Ninja is a surprisingly nice build system for tiny projects. That’s more or less the opposite of what it’s designed for, but it works really well for tiny things – things that are small enough that you can just create the little build file by hand. You just need to install it (you can just put the binary on the $PATH somewhere), then create a ninja.build file in your folder. Here’s an example that published a couple of AsciiDoc files and re-built the index if any of the pages changed:

opts = -a source-highlighter=rouge -a rouge-style=monokai -r asciidoctor-html5s -b html5s

rule adoc
  command = asciidoctor $opts $in -o $out

build out/page1.html: adoc src/page1.adoc
build out/page2.html: adoc src/page2.adoc
build out/index.html: adoc src/index.adoc | src/page1.adoc src/page2.adoc

It’s super fast, incremental & idempotent – just re-run it and it’ll just redo anything that needs doing – and nothing that doesn’t.

References


Related Posts