aboutsummaryrefslogtreecommitdiff
path: root/dep.h
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-08-09 16:51:34 -0700
committerDan Willemsen <dwillemsen@google.com>2017-08-09 17:21:43 -0700
commitb78d16f5c3f5cb2c5eb859ed4e14b54bbb02b7fc (patch)
treea8c1e341f40f0dd78ebccf1ca5f681154db6b508 /dep.h
parent18ff00f914e7058cd51b4de8480b4a1c5263a39d (diff)
downloadkati-b78d16f5c3f5cb2c5eb859ed4e14b54bbb02b7fc.tar.gz
Support Ninja implicit outputs
Add .KATI_IMPLICIT_OUTPUTS target-specific variable to add extra implicit outputs to the build line in the ninja file. This doesn't actually affect the node graph within Kati, but combined with --gen_all_targets should be usable. This allows us to properly define the build graph in ninja when one rule creates multiple files. There are a number of ways that people attempt to do this in make, all of which have problems: a b: touch a b Define multiple outputs with the same rule. This looks correct to most people, but actually runs the rule multiple times -- once for every output file. Most of the time this works, but runs into very strange concurrency issues when the two rules happen to run at the same time. a: touch a b Only define one of the files in the graph. Then users need to depend on a file that they don't use, and the unlisted file won't be noticed if it's updated separately (or even removed). b: a a: touch a b Define dependencies between the multiple files. This doesn't actually know how to update `b` if `b` is older than `a`, or doesn't exist. b: a touch b a: touch a b A variant of the previous approach, which can "fix" the timestamp if the original rule happened to create `b` before `a`. This can be even more dangerous, since it may create / update `b` improperly. But since ninja supports a graph where there can be multiple outputs from a single edge, with this patch we can write: a: .KATI_IMPLICIT_OUTPUTS := b a: touch a b which translates to: rule rule1 command = touch a b build a | b: rule1 This ninja will allow users to depend on either `a` or `b`, and the rule will be run (once) as appropriate. Change-Id: Ieb9ced7eb4d212b0aa4de5ceb1deb9ba48ada132
Diffstat (limited to 'dep.h')
-rw-r--r--dep.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/dep.h b/dep.h
index 5e879e3..b6f25e1 100644
--- a/dep.h
+++ b/dep.h
@@ -45,6 +45,7 @@ struct DepNode {
vector<Symbol> actual_order_only_inputs;
Vars* rule_vars;
Var* depfile_var;
+ Var* implicit_outputs_var;
Var* ninja_pool_var;
Symbol output_pattern;
Loc loc;