summaryrefslogtreecommitdiffstats
path: root/src/graph.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-11-13 18:09:11 (GMT)
committerBrad King <brad.king@kitware.com>2017-06-19 15:08:26 (GMT)
commitb6f020d3640988824b1fe4355996ef0726a2c44c (patch)
tree761c78eeea9c16e4eaf28392b34dbb191a2e100b /src/graph.h
parenta8b5cdc4e9034f8823ee0cfa94ea49d7795698ab (diff)
downloadNinja-b6f020d3640988824b1fe4355996ef0726a2c44c.zip
Ninja-b6f020d3640988824b1fe4355996ef0726a2c44c.tar.gz
Ninja-b6f020d3640988824b1fe4355996ef0726a2c44c.tar.bz2
Teach RecomputeDirty to detect cycles in the build graph
RecomputeDirty is the earliest traversal of the build graph complete with depfile-loaded dependencies. Teach it to detect cycles and fail immediately. This avoids the need to tolerate cycles in RecomputeDirty only to diagnose them later. It also enables future simplification of Plan and Builder logic because they will be able to assume DAG input. When RecomputeDirty detects a cycle, reject it with an error message like that previously produced by Plan::CheckDependencyCycle. Previously we used the stat state of each node to determine whether we reached it earlier in the walk. Retain this approach for leaf nodes, but add an explicit walk state mark for each Edge so that we can have a temporary mark to aid cycle detection.
Diffstat (limited to 'src/graph.h')
-rw-r--r--src/graph.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/graph.h b/src/graph.h
index 1b30dee..586c588 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -277,6 +277,9 @@ struct DependencyScan {
}
private:
+ bool RecomputeDirty(Node* node, vector<Node*>* stack, string* err);
+ bool VerifyDAG(Node* node, vector<Node*>* stack, string* err);
+
/// Recompute whether a given single output should be marked dirty.
/// Returns true if so.
bool RecomputeOutputDirty(Edge* edge, Node* most_recent_input,