summaryrefslogtreecommitdiffstats
path: root/src/graph.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-13 19:25:50 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-03 14:37:17 (GMT)
commitcc39240a10fb040fca80bf3669245f2f2d5736c5 (patch)
tree0b26230a0dd1dde9514dbbe7d6f06a3402c6e8b3 /src/graph.h
parentf1f3f494f5f67a4cd64b0cddaad472b070f6db07 (diff)
downloadNinja-cc39240a10fb040fca80bf3669245f2f2d5736c5.zip
Ninja-cc39240a10fb040fca80bf3669245f2f2d5736c5.tar.gz
Ninja-cc39240a10fb040fca80bf3669245f2f2d5736c5.tar.bz2
Add support for build statement implicit outputs
Some build rules produce outputs that are not mentioned on the command line but that should be part of the build graph. Such outputs should not be named in the `$out` variable. Extend the build statement syntax to support specification of implicit outputs using the syntax `| out1 out2` after the explicit outputs and before the `:`. For example, compilation of a Fortran source file `foo.f90` that defines `MODULE FOO` may now be specified as: rule fc command = f95 -c $in -o $out build foo.o | foo.mod: fc foo.f90 The `foo.mod` file is an implicit output generated by the compiler based on the content of the source file and not mentioned on the command line.
Diffstat (limited to 'src/graph.h')
-rw-r--r--src/graph.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/graph.h b/src/graph.h
index cf15123..add8d3d 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -129,7 +129,7 @@ private:
struct Edge {
Edge() : rule_(NULL), pool_(NULL), env_(NULL),
outputs_ready_(false), deps_missing_(false),
- implicit_deps_(0), order_only_deps_(0) {}
+ implicit_deps_(0), order_only_deps_(0), implicit_outs_(0) {}
/// Return true if all inputs' in-edges are ready.
bool AllInputsReady() const;
@@ -181,6 +181,16 @@ struct Edge {
return index >= inputs_.size() - order_only_deps_;
}
+ // There are two types of outputs.
+ // 1) explicit outs, which show up as $out on the command line;
+ // 2) implicit outs, which the target generates but are not part of $out.
+ // These are stored in outputs_ in that order, and we keep a count of
+ // #2 to use when we need to access the various subsets.
+ int implicit_outs_;
+ bool is_implicit_out(size_t index) const {
+ return index >= outputs_.size() - implicit_outs_;
+ }
+
bool is_phony() const;
bool use_console() const;
};