Commit 4fab8a0b authored by Brett Wilson's avatar Brett Wilson

GN: Fix dependency output file handling.

A copy and paste error meant it used the link output file for dependency tracking. This is valid but inefficient, which was why it wasn't caught. Added a new test for this case

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/583363003

Cr-Commit-Position: refs/heads/master@{#295985}
parent 94885cc5
...@@ -91,6 +91,14 @@ bool SubstitutionPattern::Parse(const std::string& str, ...@@ -91,6 +91,14 @@ bool SubstitutionPattern::Parse(const std::string& str,
return true; return true;
} }
// static
SubstitutionPattern SubstitutionPattern::MakeForTest(const char* str) {
Err err;
SubstitutionPattern pattern;
CHECK(pattern.Parse(str, NULL, &err)) << err.message();
return pattern;
}
std::string SubstitutionPattern::AsString() const { std::string SubstitutionPattern::AsString() const {
std::string result; std::string result;
for (size_t i = 0; i < ranges_.size(); i++) { for (size_t i = 0; i < ranges_.size(); i++) {
......
...@@ -41,6 +41,10 @@ class SubstitutionPattern { ...@@ -41,6 +41,10 @@ class SubstitutionPattern {
bool Parse(const Value& value, Err* err); bool Parse(const Value& value, Err* err);
bool Parse(const std::string& str, const ParseNode* origin, Err* err); bool Parse(const std::string& str, const ParseNode* origin, Err* err);
// Makes a pattern given a hardcoded string. Will assert if the string is
// not a valid pattern.
static SubstitutionPattern MakeForTest(const char* str);
// Returns the pattern as a string with substitutions in them. // Returns the pattern as a string with substitutions in them.
std::string AsString() const; std::string AsString() const;
......
...@@ -322,7 +322,7 @@ void Target::FillOutputFiles() { ...@@ -322,7 +322,7 @@ void Target::FillOutputFiles() {
if (!tool->depend_output().empty()) { if (!tool->depend_output().empty()) {
dependency_output_file_ = dependency_output_file_ =
SubstitutionWriter::ApplyPatternToLinkerAsOutputFile( SubstitutionWriter::ApplyPatternToLinkerAsOutputFile(
this, tool, tool->link_output()); this, tool, tool->depend_output());
} }
} }
break; break;
......
...@@ -479,3 +479,40 @@ TEST(Target, PublicConfigs) { ...@@ -479,3 +479,40 @@ TEST(Target, PublicConfigs) {
ASSERT_EQ(1u, dep_on_forward.configs().size()); ASSERT_EQ(1u, dep_on_forward.configs().size());
EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr); EXPECT_EQ(&pub_config, dep_on_forward.configs()[0].ptr);
} }
// Tests that different link/depend outputs work for solink tools.
TEST(Target, LinkAndDepOutputs) {
TestWithScope setup;
Err err;
Toolchain toolchain(setup.settings(), Label(SourceDir("//tc/"), "tc"));
scoped_ptr<Tool> solink_tool(new Tool());
solink_tool->set_output_prefix("lib");
solink_tool->set_default_output_extension(".so");
const char kLinkPattern[] =
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}";
SubstitutionPattern link_output = SubstitutionPattern::MakeForTest(
kLinkPattern);
solink_tool->set_link_output(link_output);
const char kDependPattern[] =
"{{root_out_dir}}/{{target_output_name}}{{output_extension}}.TOC";
SubstitutionPattern depend_output = SubstitutionPattern::MakeForTest(
kDependPattern);
solink_tool->set_depend_output(depend_output);
solink_tool->set_outputs(SubstitutionList::MakeForTest(
kLinkPattern, kDependPattern));
toolchain.SetTool(Toolchain::TYPE_SOLINK, solink_tool.Pass());
Target target(setup.settings(), Label(SourceDir("//a/"), "a"));
target.set_output_type(Target::SHARED_LIBRARY);
target.SetToolchain(&toolchain);
ASSERT_TRUE(target.OnResolved(&err));
EXPECT_EQ("./liba.so", target.link_output_file().value());
EXPECT_EQ("./liba.so.TOC", target.dependency_output_file().value());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment