Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: tools/gn/target_unittest.cc

Issue 301243002: Don't inherit source sets across static libs in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/target_unittest.cc
diff --git a/tools/gn/target_unittest.cc b/tools/gn/target_unittest.cc
index 860dcaf1b0d4e36550c9dae7cd17775f20a8a064..6219374c947ad75c1dc2e39cab26b6a1dc3d673d 100644
--- a/tools/gn/target_unittest.cc
+++ b/tools/gn/target_unittest.cc
@@ -199,3 +199,42 @@ TEST_F(TargetTest, ForwardDependentConfigsFromGroups) {
ASSERT_EQ(1u, a.direct_dependent_configs().size());
ASSERT_EQ(&direct, a.direct_dependent_configs()[0].ptr);
}
+
+TEST_F(TargetTest, InheritLibs) {
+ // Create a dependency chain:
+ // A (executable) -> B (shared lib) -> C (static lib) -> D (source set)
+ Target a(&settings_, Label(SourceDir("//foo/"), "a"));
+ a.set_output_type(Target::EXECUTABLE);
+ Target b(&settings_, Label(SourceDir("//foo/"), "b"));
+ b.set_output_type(Target::SHARED_LIBRARY);
+ Target c(&settings_, Label(SourceDir("//foo/"), "c"));
+ c.set_output_type(Target::STATIC_LIBRARY);
+ Target d(&settings_, Label(SourceDir("//foo/"), "d"));
+ d.set_output_type(Target::SOURCE_SET);
+ a.deps().push_back(LabelTargetPair(&b));
+ b.deps().push_back(LabelTargetPair(&c));
+ c.deps().push_back(LabelTargetPair(&d));
+
+ d.OnResolved();
+ c.OnResolved();
+ b.OnResolved();
+ a.OnResolved();
+
+ // C should have D in its inherited libs.
+ const std::set<const Target*>& c_inherited = c.inherited_libraries();
+ EXPECT_EQ(1u, c_inherited.size());
+ EXPECT_TRUE(c_inherited.find(&d) != c_inherited.end());
+
+ // B should have C in its inherited libs, but not D (the static library will
+ // include the source sets's code).
+ const std::set<const Target*>& b_inherited = b.inherited_libraries();
+ EXPECT_EQ(1u, b_inherited.size());
+ EXPECT_TRUE(b_inherited.find(&c) != b_inherited.end());
+
+ // A should have B in its inherited libs, but not any others (the shared
+ // library will include the static library, which will include the source
+ // set).
+ const std::set<const Target*>& a_inherited = a.inherited_libraries();
+ EXPECT_EQ(1u, a_inherited.size());
+ EXPECT_TRUE(a_inherited.find(&b) != a_inherited.end());
+}
« no previous file with comments | « tools/gn/target.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698