Skip to content

Commit

Permalink
dyndep: reconcile relative and absolute paths with build manifest
Browse files Browse the repository at this point in the history
A dyndep file may contain relative and/or absolute paths generated by
external tooling just as a depfile might.  Apply the same lookup rules
we use for depfile paths to dyndep file paths too.

Fixes: #1251
  • Loading branch information
bradking committed Mar 5, 2021
1 parent d8d6206 commit c01bd4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/dyndep_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool DyndepParser::ParseEdge(string* err) {
uint64_t slash_bits;
if (!CanonicalizePath(&path, &slash_bits, &path_err))
return lexer_.Error(path_err, err);
Node* node = state_->LookupNode(path);
Node* node = state_->LookupNodeForDepfile(path);
if (!node || !node->in_edge())
return lexer_.Error("no build statement exists for '" + path + "'", err);
Edge* edge = node->in_edge();
Expand Down Expand Up @@ -210,7 +210,7 @@ bool DyndepParser::ParseEdge(string* err) {
uint64_t slash_bits;
if (!CanonicalizePath(&path, &slash_bits, &path_err))
return lexer_.Error(path_err, err);
Node* n = state_->GetNode(path, slash_bits);
Node* n = state_->GetNodeForDepfile(path, slash_bits);
dyndeps->implicit_inputs_.push_back(n);
}

Expand All @@ -221,7 +221,7 @@ bool DyndepParser::ParseEdge(string* err) {
uint64_t slash_bits;
if (!CanonicalizePath(&path, &slash_bits, &path_err))
return lexer_.Error(path_err, err);
Node* n = state_->GetNode(path, slash_bits);
Node* n = state_->GetNodeForDepfile(path, slash_bits);
dyndeps->implicit_outputs_.push_back(n);
}

Expand Down
13 changes: 9 additions & 4 deletions src/graph_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,18 @@ TEST_F(GraphTest, DyndepLoadTrivial) {

TEST_F(GraphTest, DyndepLoadImplicit) {
AssertParse(&state_,
"ninja_workdir = /path/to\n"
"rule r\n"
" command = unused\n"
"build out1: r in || dd\n"
" dyndep = dd\n"
"build out2: r in\n"
"build out3: r in\n"
"build /path/to/out4: r in\n"
);
fs_.Create("dd",
"ninja_dyndep_version = 1\n"
"build out1: dyndep | out2\n"
"build /path/to/out1: dyndep | out2 /path/to/out3 out4\n"
);

string err;
Expand All @@ -579,11 +582,13 @@ TEST_F(GraphTest, DyndepLoadImplicit) {
Edge* edge = GetNode("out1")->in_edge();
ASSERT_EQ(1u, edge->outputs_.size());
EXPECT_EQ("out1", edge->outputs_[0]->path());
ASSERT_EQ(3u, edge->inputs_.size());
ASSERT_EQ(5u, edge->inputs_.size());
EXPECT_EQ("in", edge->inputs_[0]->path());
EXPECT_EQ("out2", edge->inputs_[1]->path());
EXPECT_EQ("dd", edge->inputs_[2]->path());
EXPECT_EQ(1u, edge->implicit_deps_);
EXPECT_EQ("out3", edge->inputs_[2]->path());
EXPECT_EQ("/path/to/out4", edge->inputs_[3]->path());
EXPECT_EQ("dd", edge->inputs_[4]->path());
EXPECT_EQ(3u, edge->implicit_deps_);
EXPECT_EQ(1u, edge->order_only_deps_);
EXPECT_FALSE(edge->GetBindingBool("restat"));
}
Expand Down

0 comments on commit c01bd4e

Please sign in to comment.