@suchipi/shinobi
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@suchipi/shinobi

generate ninja build files from js scripts

Usage

  • Install nodejs
  • Install shinobi:
npm install -D @suchipi/shinobi
// variables to be used in rules
declare("compiler", "gcc");
declareOrAppend("cflags", "-Wall");
declareOrAppend("cflags", "-g");

// rules for building things
rule("cc", {
  command: "$compiler $cflags $in -o $out", // $in and $out are builtin variables
  description: "CC $out",
});

// things to build
build({
  output: builddir("something.o"), // builddir defaults to `build/` but can be overridden
  inputs: [rel("something.c")], // rel resolves paths relative to the current file
  rule: "cc", // name of rule as defined above
});
  • Pass those scripts to the shinobi CLI (maybe using a glob). It will output the contents of a ninja file
shopt -s globstar

npx shinobi ./**/*.ninja.js > build.ninja

For instance, the example script from above outputs something like this:

# variable 'builddir' from builtin (override with env var BUILDDIR)
builddir = ./build
# variable 'compiler' from myscript.js
compiler = gcc
# variable 'cflags' from myscript.js
cflags = -Wall -g

# rule 'cc' from myscript.js
rule cc
  command = $compiler $cflags $in -o $out
  description = CC $out

# build for '$builddir/something.o' from myscript.js
build $builddir/something.o: cc /tmp/mycode/something.c

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @suchipi/shinobi

Weekly Downloads

9

Version

1.0.1

License

MIT

Unpacked Size

37.2 kB

Total Files

20

Last publish

Collaborators

  • suchipi