Chromium Code Reviews| 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; |
| +} |