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

Unified Diff: tools/gn/target.cc

Issue 582863002: GN: Complete static libs can't depend on static libs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/target_unittest.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 9e693b12d02845537a6e6c7448fd42af9df20136..a0e5fefdea0df4dcf46e46432868264118ead05d 100644
--- a/tools/gn/target.cc
+++ b/tools/gn/target.cc
@@ -49,6 +49,19 @@ 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)
@@ -126,6 +139,8 @@ bool Target::OnResolved(Err* err) {
return false;
if (!CheckTestonly(err))
return false;
+ if (!CheckNoNestedStaticLibs(err))
+ return false;
return true;
}
@@ -326,7 +341,7 @@ bool Target::CheckVisibility(Err* err) const {
}
bool Target::CheckTestonly(Err* err) const {
- // If there current target is marked testonly, it can include both testonly
+ // If the current target is marked testonly, it can include both testonly
// and non-testonly targets, so there's nothing to check.
if (testonly())
return true;
@@ -341,3 +356,19 @@ 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 (DepsIterator iter(this); !iter.done(); iter.Advance()) {
brettw 2014/09/18 19:51:24 I think you'll also need to check inherited_librar
Chris Masone 2014/09/18 20:32:42 Done.
+ if (iter.target()->output_type() == Target::STATIC_LIBRARY) {
+ *err = MakeStaticLibDepsError(this, iter.target());
+ return false;
+ }
+ }
+ return true;
+}
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/target_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698