Ninjag
December 28, 2016 ยท View on GitHub
A python package for generating ninja build configuration files based on user input YAML files
Install
This is a python command line app.
After the input you will have ninjag command
available to you.
pip install ninjag
Dependency
Background knowledge
Usage
The first argument is the output file name,
The rest of the arguments are input files.
ninjag <output file> <input file 1> <input file 2> ...
The input configuration can span multiple yaml files,
but the combined content must have three required sections:
- const: a list of dictionaries of
ninjaconstant definitions - rules: a list of dictionaries of
ninjarule definitions - tasks: a list of dictionaries of
ninjabuild tasks.- rule: which
ninjarule to apply for this task - in: a
listof input file names - out: a
listof output file names - const: a dictionary of local constant definitions,
which have higher priority than the global constants Notes:
- rule: which
inandoutareninjabuilt-in keywords.
they must be written as the way they are.inandoutcan be either a string or a list of strings- the
rulesandtaskssections from multiple inputs
will be concatenated. Repeatedconstdefinitions will
be retained (no overridden).
The is an intentional design to avoid the confusion/bugs
caused by mutations (overwriting).
Examples
input1.yaml
const:
- cflags: -Wall -Wconversion -Wextra
- extra_dir: /home/include
- I:
- -I${extra_dir}
rules:
- cc: gcc $cflags $I $in -o $out
tasks:
- rule: cc
in:
- hello.c
- main.c
out: hello.exe
const:
- cflags: -Wall
Then type command:
ninjag build.ninja input1.yaml
The output is (build.ninja):
cflags = -Wall -Wconversion -Wextra
extra_dir = /home/include
I = -I${extra_dir}
rule cc
command = gcc $cflags $in -o $out
build hello.exe: cc hello.c main.c
cflags = -Wall
The const definition can have list as value:
const:
W:
- -Wall
- -Werror
- -Wconversion
I:
- -I/home/include1
- -I/home/include2
The above will be translated to:
W = -Wall -Werror -Wconversion
I = -I/home/include1 -I/home/include2
License
MIT/X11 Steven(Yuhang) Wang (c) 2016