summaryrefslogtreecommitdiffstats
path: root/tools/gn
diff options
context:
space:
mode:
authorBrett Wilson <brettw@chromium.org>2014-09-22 09:31:07 -0700
committerBrett Wilson <brettw@chromium.org>2014-09-22 16:31:52 +0000
commit4fab8a0b3d7e2ae3db541795783b41911ad8c711 (patch)
treec8bbbfad8117fcaaa6132d44702f59029844a815 /tools/gn
parent94885cc5e87d88ef1373b6e35716a072b90009ad (diff)
downloadchromium_src-4fab8a0b3d7e2ae3db541795783b41911ad8c711.zip
chromium_src-4fab8a0b3d7e2ae3db541795783b41911ad8c711.tar.gz
chromium_src-4fab8a0b3d7e2ae3db541795783b41911ad8c711.tar.bz2
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}
Diffstat (limited to 'tools/gn')
-rw-r--r--tools/gn/substitution_pattern.cc8
-rw-r--r--tools/gn/substitution_pattern.h4
-rw-r--r--tools/gn/target.cc2
-rw-r--r--tools/gn/target_unittest.cc37
4 files changed, 50 insertions, 1 deletions
diff --git a/tools/gn/substitution_pattern.cc b/tools/gn/substitution_pattern.cc
index 6a4d0c5..cb1bd24 100644
--- a/tools/gn/substitution_pattern.cc
+++ b/tools/gn/substitution_pattern.cc
@@ -91,6 +91,14 @@ bool SubstitutionPattern::Parse(const std::string& str,
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 result;
for (size_t i = 0; i < ranges_.size(); i++) {
diff --git a/tools/gn/substitution_pattern.h b/tools/gn/substitution_pattern.h
index 7e6c662..a3d6f7e 100644
--- a/tools/gn/substitution_pattern.h
+++ b/tools/gn/substitution_pattern.h
@@ -41,6 +41,10 @@ class SubstitutionPattern {
bool Parse(const Value& value, 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.
std::string AsString() const;
diff --git a/tools/gn/target.cc b/tools/gn/target.cc
index d512894..9368749 100644
--- a/tools/gn/target.cc
+++ b/tools/gn/target.cc
@@ -322,7 +322,7 @@ void Target::FillOutputFiles() {
if (!tool->depend_output().empty()) {
dependency_output_file_ =
SubstitutionWriter::ApplyPatternToLinkerAsOutputFile(
- this, tool, tool->link_output());
+ this, tool, tool->depend_output());
}
}
break;
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc
index 6f1a5cf..8cc29e1 100644
--- a/tools/gn/target_unittest.cc
+++ b/tools/gn/target_unittest.cc
@@ -479,3 +479,40 @@ TEST(Target, PublicConfigs) {
ASSERT_EQ(1u, dep_on_forward.configs().size());
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());
+}