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

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: 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 | « no previous file | tools/gn/target.h » ('j') | tools/gn/target.cc » ('J')
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 88a6eb2d546ac6e025a52df9f1d322091a27b864..bf446b32ba7ebf67296a9c7802a25905bb98e9ff 100644
--- a/tools/gn/ninja_binary_target_writer.cc
+++ b/tools/gn/ninja_binary_target_writer.cc
@@ -409,7 +409,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, and complete static
// libraries). Intermediate static libraries and other source sets
@@ -428,13 +435,14 @@ void NinjaBinaryTargetWriter::ClassifyDependency(
}
}
}
-
// Add the source set itself as a non-linkable dependency on the current
// target. This will make sure that anything the source set's stamp file
// depends on (like data deps) are also built before the current target
// 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/target.h » ('j') | tools/gn/target.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698