| Did you know ... | Search Documentation: |
| Pack ninja -- prolog/ninja.pl |
This module contains helper dcg predicates to generate ninja build files akin to the ninja_syntax.py python module distributed by ninja.
You can use these predicates if you want to generate your own build.ninja build file.
Example usage:
build_graph -->
rule(cp, "cp $in $out"),
build(["input.txt"], cp, ["output.txt"]).
main -->
phrase(build_graph, L),
open("build.ninja", write, Stream),
string_codes(S, L),
write(Stream, S),
close(Stream).
Then build.ninja contains the following build specification:
rule cp command = cp $in $out build input.txt: cp output.txt
See the ninja build format documentation for generating more complex build files.
?- phrase(variable(name-"Value"), L), format("~s", [L]).
name = Value
L = [110, 97, 109, 101, 32, 61, 32, 86, 97|...].
?- phrase(variable(name, "Value"), L), format("~s", [L]).
name = Value
L = [110, 97, 109, 101, 32, 61, 32, 86, 97|...].
?- phrase(rule(cp, "cp $in $out"), L), format("~s", [L]).
rule cp
command = cp $in $out
L = [114, 117, 108, 101, 32, 99, 112, 10, 32|...].
?- phrase(rule(cp, "cp $in $out"), L), format("~s", [L]).
rule cp
command = cp $in $out
L = [114, 117, 108, 101, 32, 99, 112, 10, 32|...].
?- phrase(build(["input.txt"], cp, ["output.txt"]), L), format("~s", [L]).
build input.txt: cp output.txt
L = [98, 117, 105, 108, 100, 32, 105, 110, 112|...].
?- phrase(build(["input.txt"], cp, ["output.txt"],
[implicit_outs(["implicit_out.txt"]),
implicit_ins(["implicit_in.txt"]),
orderonly_ins(["orderonly_in.txt"]),
validations(["validation.txt"]),
variables([name-"value"])]), L), format("~s", [L]).
build input.txt | implicit_out.txt: cp output.txt | implicit_in.txt || orderonly_in.txt |@ validation.txt
name = value
L = `build input.txt | implici...alue\n`.
?- phrase(deps("ninja.pl"), L), format("~s", [L]).
ninja.pl /usr/lib64/swipl-9.0.4/library/dcg/basics.pl /usr/lib64/swipl-9.0.4/library/dcg/high_order.pl /usr/lib64/swipl-9.0.4/library/option.pl /usr/lib64/swipl-9.0.4/library/error.pl
L = `ninja.pl /usr/lib64/swipl...or.pl`.