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

Unified Diff: tools/gn/ninja_binary_target_writer.cc

Issue 572893002: GN: Refine 'complete' static library handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve complete_static_lib help; other style nitpicks Created 4 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 | « no previous file | tools/gn/ninja_binary_target_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_binary_target_writer.cc
diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc
index cb486880fd521a4910d78bf29fde934038508644..30658f21ed155973a44be8c8bced91044a185c2e 100644
--- a/tools/gn/ninja_binary_target_writer.cc
+++ b/tools/gn/ninja_binary_target_writer.cc
@@ -938,7 +938,14 @@ void NinjaBinaryTargetWriter::ClassifyDependency(
// don't link at all.
bool can_link_libs = target_->IsFinal();
- if (dep->output_type() == Target::SOURCE_SET) {
+ if (dep->output_type() == Target::SOURCE_SET ||
+ // If a complete static library depends on an incomplete static library,
+ // manually link in the object files of the dependent library as if it
+ // were a source set. This avoids problems with braindead tools such as
+ // ar which don't properly link dependent static libraries.
+ (target_->complete_static_lib() &&
+ dep->output_type() == Target::STATIC_LIBRARY &&
+ !dep->complete_static_lib())) {
// Source sets have their object files linked into final targets
// (shared libraries, executables, loadable modules, and complete static
// libraries). Intermediate static libraries and other source sets
@@ -954,6 +961,8 @@ void NinjaBinaryTargetWriter::ClassifyDependency(
// can be complete. Otherwise, these will be skipped since this target
// will depend only on the source set's object files.
non_linkable_deps->push_back(dep);
+ } else if (target_->complete_static_lib() && dep->IsFinal()) {
+ non_linkable_deps->push_back(dep);
} else if (can_link_libs && dep->IsLinkable()) {
linkable_deps->push_back(dep);
} else {
« no previous file with comments | « no previous file | tools/gn/ninja_binary_target_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698