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

Unified Diff: tools/gn/target.cc

Issue 572893002: GN: Refine 'complete' static library handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync patches to recent GN changes Created 5 years, 8 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.h ('k') | tools/gn/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/target.cc
diff --git a/tools/gn/target.cc b/tools/gn/target.cc
index 40c8a21e2adf743d0b0de24edcfee564f6559b3e..47780b153356b8ec597509414e0d2393ef252573 100644
--- a/tools/gn/target.cc
+++ b/tools/gn/target.cc
@@ -47,19 +47,6 @@ Err MakeTestOnlyError(const Target* from, const Target* to) {
"Either mark it test-only or don't do this dependency.");
}
-Err MakeStaticLibDepsError(const Target* from, const Target* to) {
- return Err(from->defined_from(),
- "Complete static libraries can't depend on static libraries.",
- from->label().GetUserVisibleName(false) +
- "\n"
- "which is a complete static library can't depend on\n" +
- to->label().GetUserVisibleName(false) +
- "\n"
- "which is a static library.\n"
- "\n"
- "Use source sets for intermediate targets instead.");
-}
-
} // namespace
Target::Target(const Settings* settings, const Label& label)
@@ -136,8 +123,6 @@ bool Target::OnResolved(Err* err) {
return false;
if (!CheckTestonly(err))
return false;
- if (!CheckNoNestedStaticLibs(err))
- return false;
return true;
}
@@ -244,8 +229,23 @@ void Target::PullDependentTarget(const Target* dep, bool is_public) {
// The current target isn't linked, so propogate linked deps and
// libraries up the dependency tree.
inherited_libraries_.AppendInherited(dep->inherited_libraries(), is_public);
+ } else if (dep->complete_static_lib()) {
+ // Inherit only final targets through _complete_ static libraries.
+ //
+ // Inherited final libraries aren't linked into complete static libraries.
+ // They are forwarded here so that targets that depend on complete
+ // static libraries can link them in. Conversely, since complete static
+ // libraries link in non-final targets they shouldn't be inherited.
+ for (const auto& inherited :
+ dep->inherited_libraries().GetOrderedAndPublicFlag()) {
+ if (inherited.first->IsFinal())
+ inherited_libraries_.Append(inherited.first,
+ is_public && inherited.second);
kal 2015/04/27 21:10:34 Does the is_public handling here make sense?
+ }
+ }
- // Inherited library settings.
+ // Library settings are always inherited across static library boundaries.
+ if (!dep->IsFinal() || dep->output_type() == STATIC_LIBRARY) {
all_lib_dirs_.append(dep->all_lib_dirs());
all_libs_.append(dep->all_libs());
}
@@ -385,27 +385,3 @@ bool Target::CheckTestonly(Err* err) const {
return true;
}
-
-bool Target::CheckNoNestedStaticLibs(Err* err) const {
- // If the current target is not a complete static library, it can depend on
- // static library targets with no problem.
- if (!(output_type() == Target::STATIC_LIBRARY && complete_static_lib()))
- return true;
-
- // Verify no deps are static libraries.
- for (const auto& pair : GetDeps(DEPS_ALL)) {
- if (pair.ptr->output_type() == Target::STATIC_LIBRARY) {
- *err = MakeStaticLibDepsError(this, pair.ptr);
- return false;
- }
- }
-
- // Verify no inherited libraries are static libraries.
- for (const auto& lib : inherited_libraries().GetOrdered()) {
- if (lib->output_type() == Target::STATIC_LIBRARY) {
- *err = MakeStaticLibDepsError(this, lib);
- return false;
- }
- }
- return true;
-}
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698