summaryrefslogtreecommitdiffstats
path: root/src/manifest_parser.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-15 23:34:03 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-15 23:34:03 (GMT)
commit56e9d08c028d2c16f787041dc1f41271464a8bdc (patch)
tree7c666efb09121fba46787e3bd3b47bf28ddeb5f2 /src/manifest_parser.cc
parent51f06facf46e7a1a5338a4ca2ec9b8441c44c405 (diff)
downloadNinja-56e9d08c028d2c16f787041dc1f41271464a8bdc.zip
Ninja-56e9d08c028d2c16f787041dc1f41271464a8bdc.tar.gz
Ninja-56e9d08c028d2c16f787041dc1f41271464a8bdc.tar.bz2
Build self-consistent graphs for dupe edges with multiple outputs.
Fixes #867, both the crashes and "[stuck]" issues. The problem was that a duplicate edge would modify the in_edge of the outputs of the new build rule, but the edge corresponding to the old build rule would still think that the in_edge points to itself. `old_edge->outputs_[0]->in_edge()` would not return `old_edge`, which confused the scan logic. As fix, let `State::AddOut()` reject changing in_edge if it's already set. This changes behavior in a minor way: Previously, if there were multiple edges for a single output, the last edge would be kept. Now, the first edge is kept. This only had mostly-well-defined semantics if all duplicate edges are the same (which is the only case I've seen in practice), and for that case the behavior doesn't change. For testing, add a VerifyGraph() function and call that every time any test graph is parsed. That's a bit more code than just copying the test cases from the bug into build_test.cc, but it also yields better test coverage overall.
Diffstat (limited to 'src/manifest_parser.cc')
-rw-r--r--src/manifest_parser.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc
index 044b259..f0457dd 100644
--- a/src/manifest_parser.cc
+++ b/src/manifest_parser.cc
@@ -340,6 +340,14 @@ bool ManifestParser::ParseEdge(string* err) {
edge->implicit_deps_ = implicit;
edge->order_only_deps_ = order_only;
+ if (edge->outputs_.empty()) {
+ // All outputs of the edge are already created by other edges. Don't add
+ // this edge.
+ state_->edges_.pop_back();
+ delete edge;
+ return true;
+ }
+
// Multiple outputs aren't (yet?) supported with depslog.
string deps_type = edge->GetBinding("deps");
if (!deps_type.empty() && edge->outputs_.size() > 1) {