Simplify logic that updates an edge from dyndep and depfile bindings

RecomputeNodeDirty checks both dyndep and depfile bindings when an edge
is first encountered.  Consolidate them into a single conditional block.
This simplification was missed in commit 0f0fb3275d (Teach RecomputeDirty
to load dyndep files that are ready, 2015-11-05, v1.10.0~1^2~53^2~7).
This commit is contained in:
Brad King
2026-03-20 22:33:21 -04:00
parent 882af5e362
commit f42b614284
2 changed files with 18 additions and 18 deletions

View File

@@ -343,10 +343,10 @@ TEST_F(StatTest, TwoStep) {
scan_.RecomputeDirty(out, NULL, NULL);
ASSERT_EQ(3u, stats_.size());
ASSERT_EQ("out", stats_[0]);
ASSERT_EQ("in", stats_[1]);
ASSERT_EQ("mid", stats_[2]);
ASSERT_TRUE(GetNode("out")->dirty());
ASSERT_EQ("mid", stats_[1]);
ASSERT_TRUE(GetNode("mid")->dirty());
ASSERT_EQ("in", stats_[2]);
}
TEST_F(StatTest, Tree) {
@@ -362,9 +362,10 @@ TEST_F(StatTest, Tree) {
ASSERT_EQ(1u, stats_.size());
scan_.RecomputeDirty(out, NULL, NULL);
ASSERT_EQ(1u + 6u, stats_.size());
ASSERT_EQ("mid1", stats_[1]);
ASSERT_EQ("in11", stats_[1]);
ASSERT_EQ("in12", stats_[2]);
ASSERT_EQ("mid1", stats_[3]);
ASSERT_TRUE(GetNode("mid1")->dirty());
ASSERT_EQ("in11", stats_[2]);
}
TEST_F(StatTest, Middle) {

View File

@@ -123,6 +123,8 @@ bool DependencyScan::RecomputeNodeDirty(Node* node, std::vector<Node*>* stack,
if (!edge->deps_loaded_) {
// This is our first encounter with this edge.
edge->deps_loaded_ = true;
// If there is a pending dyndep file, visit it now:
// * If the dyndep file is ready then load it now to get any
// additional inputs and outputs for this and other edges.
@@ -144,21 +146,8 @@ bool DependencyScan::RecomputeNodeDirty(Node* node, std::vector<Node*>* stack,
return false;
}
}
}
// Load output mtimes so we can compare them to the most recent input below.
for (vector<Node*>::iterator o = edge->outputs_.begin();
o != edge->outputs_.end(); ++o) {
if (err) {
*err = "";
}
if (!(*o)->StatIfNecessary(disk_interface_, err))
return false;
}
if (!edge->deps_loaded_) {
// This is our first encounter with this edge. Load discovered deps.
edge->deps_loaded_ = true;
// Load discovered deps.
if (!dep_loader_.LoadDeps(edge, err)) {
if (!err->empty())
return false;
@@ -176,6 +165,16 @@ bool DependencyScan::RecomputeNodeDirty(Node* node, std::vector<Node*>* stack,
return false;
}
// Load output mtimes so we can compare them to the most recent input below.
for (Node* o : edge->outputs_) {
if (err) {
*err = "";
}
if (!o->StatIfNecessary(disk_interface_, err)) {
return false;
}
}
// We're dirty if any of the inputs is dirty.
Node* most_recent_input = NULL;
for (vector<Node*>::iterator i = edge->inputs_.begin();