Commit 8499f51f authored by brettw@chromium.org's avatar brettw@chromium.org

Forward dependent configs from groups properly in GN.

Depending on a group is like depending on that group's dependants. This wasn't working for forwarding dependent configs.

BUG=366814
R=scottmg@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266049 0039d316-1c4b-4281-b951-d872f2087c98
parent 1dc3796b
......@@ -147,6 +147,7 @@ void Target::OnResolved() {
// pulled from G to A in case G has configs directly on it).
PullDependentTargetInfo(&unique_configs);
}
PullForwardedDependentConfigs();
}
bool Target::IsLinkable() const {
......@@ -181,6 +182,12 @@ void Target::PullDependentTargetInfo(std::set<const Config*>* unique_configs) {
all_libs_.append(dep->all_libs());
}
}
}
void Target::PullForwardedDependentConfigs() {
// Groups implicitly forward all if its dependency's configs.
if (output_type() == GROUP)
forward_dependent_configs_ = deps_;
// Forward direct dependent configs if requested.
for (size_t dep = 0; dep < forward_dependent_configs_.size(); dep++) {
......
......@@ -150,6 +150,9 @@ class Target : public Item {
// dependencies have been resolved.
void PullDependentTargetInfo(std::set<const Config*>* unique_configs);
// Pulls dependent configs that need forwarding.
void PullForwardedDependentConfigs();
OutputType output_type_;
std::string output_name_;
std::string output_extension_;
......
......@@ -169,3 +169,33 @@ TEST_F(TargetTest, DependentConfigs) {
ASSERT_EQ(1u, a_fwd.all_dependent_configs().size());
EXPECT_EQ(&all, a_fwd.all_dependent_configs()[0].ptr);
}
// Tests that forward_dependent_configs_from works for groups, forwarding the
// group's deps' dependent configs.
TEST_F(TargetTest, ForwardDependentConfigsFromGroups) {
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::GROUP);
Target c(&settings_, Label(SourceDir("//foo/"), "c"));
c.set_output_type(Target::STATIC_LIBRARY);
a.deps().push_back(LabelTargetPair(&b));
b.deps().push_back(LabelTargetPair(&c));
// Direct dependent config on C.
Config direct(&settings_, Label(SourceDir("//foo/"), "direct"));
c.direct_dependent_configs().push_back(LabelConfigPair(&direct));
// A forwards the dependent configs from B.
a.forward_dependent_configs().push_back(LabelTargetPair(&b));
c.OnResolved();
b.OnResolved();
a.OnResolved();
// The config should now be on A, and in A's direct dependent configs.
ASSERT_EQ(1u, a.configs().size());
ASSERT_EQ(&direct, a.configs()[0].ptr);
ASSERT_EQ(1u, a.direct_dependent_configs().size());
ASSERT_EQ(&direct, a.direct_dependent_configs()[0].ptr);
}
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