| 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());
|
| +}
|
|
|