Index: tools/gn/target.cc |
diff --git a/tools/gn/target.cc b/tools/gn/target.cc |
index a83c60e4491f43f77b63a94a2e1130f75bda2116..1983374cf998084bc1a69c03066a86efe1f4da74 100644 |
--- a/tools/gn/target.cc |
+++ b/tools/gn/target.cc |
@@ -13,39 +13,25 @@ namespace { |
typedef std::set<const Config*> ConfigSet; |
// Merges the dependent configs from the given target to the given config list. |
-// The unique_configs list is used for de-duping so values already added will |
-// not be added again. |
void MergeDirectDependentConfigsFrom(const Target* from_target, |
- ConfigSet* unique_configs, |
- LabelConfigVector* dest) { |
- const LabelConfigVector& direct = from_target->direct_dependent_configs(); |
- for (size_t i = 0; i < direct.size(); i++) { |
- if (unique_configs->find(direct[i].ptr) == unique_configs->end()) { |
- unique_configs->insert(direct[i].ptr); |
- dest->push_back(direct[i]); |
- } |
- } |
+ UniqueVector<LabelConfigPair>* dest) { |
+ const UniqueVector<LabelConfigPair>& direct = |
+ from_target->direct_dependent_configs(); |
+ for (size_t i = 0; i < direct.size(); i++) |
+ dest->push_back(direct[i]); |
} |
// Like MergeDirectDependentConfigsFrom above except does the "all dependent" |
// ones. This additionally adds all configs to the all_dependent_configs_ of |
// the dest target given in *all_dest. |
void MergeAllDependentConfigsFrom(const Target* from_target, |
- ConfigSet* unique_configs, |
- LabelConfigVector* dest, |
- LabelConfigVector* all_dest) { |
- const LabelConfigVector& all = from_target->all_dependent_configs(); |
+ UniqueVector<LabelConfigPair>* dest, |
+ UniqueVector<LabelConfigPair>* all_dest) { |
+ const UniqueVector<LabelConfigPair>& all = |
+ from_target->all_dependent_configs(); |
for (size_t i = 0; i < all.size(); i++) { |
- // Always add it to all_dependent_configs_ since it might not be in that |
- // list even if we've seen it applied to this target before. This may |
- // introduce some duplicates in all_dependent_configs_, but those will |
- // we removed when they're actually applied to a target. |
all_dest->push_back(all[i]); |
- if (unique_configs->find(all[i].ptr) == unique_configs->end()) { |
- // One we haven't seen yet, also apply it to ourselves. |
- dest->push_back(all[i]); |
- unique_configs->insert(all[i].ptr); |
- } |
+ dest->push_back(all[i]); |
} |
} |
@@ -110,26 +96,10 @@ void Target::OnResolved() { |
} |
} |
- // Only add each config once. First remember the target's configs. |
- ConfigSet unique_configs; |
- for (size_t i = 0; i < configs_.size(); i++) |
- unique_configs.insert(configs_[i].ptr); |
- |
// Copy our own dependent configs to the list of configs applying to us. |
- for (size_t i = 0; i < all_dependent_configs_.size(); i++) { |
- if (unique_configs.find(all_dependent_configs_[i].ptr) == |
- unique_configs.end()) { |
- unique_configs.insert(all_dependent_configs_[i].ptr); |
- configs_.push_back(all_dependent_configs_[i]); |
- } |
- } |
- for (size_t i = 0; i < direct_dependent_configs_.size(); i++) { |
- if (unique_configs.find(direct_dependent_configs_[i].ptr) == |
- unique_configs.end()) { |
- unique_configs.insert(direct_dependent_configs_[i].ptr); |
- configs_.push_back(direct_dependent_configs_[i]); |
- } |
- } |
+ configs_.Append(all_dependent_configs_.begin(), all_dependent_configs_.end()); |
+ configs_.Append(direct_dependent_configs_.begin(), |
+ direct_dependent_configs_.end()); |
// Copy our own libs and lib_dirs to the final set. This will be from our |
// target and all of our configs. We do this specially since these must be |
@@ -146,7 +116,7 @@ void Target::OnResolved() { |
// be treated as direct dependencies of A, so this is unnecessary and will |
// actually result in duplicated settings (since settings will also be |
// pulled from G to A in case G has configs directly on it). |
- PullDependentTargetInfo(&unique_configs); |
+ PullDependentTargetInfo(); |
} |
PullForwardedDependentConfigs(); |
PullRecursiveHardDeps(); |
@@ -156,28 +126,25 @@ bool Target::IsLinkable() const { |
return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; |
} |
-void Target::PullDependentTargetInfo(std::set<const Config*>* unique_configs) { |
+void Target::PullDependentTargetInfo() { |
// Gather info from our dependents we need. |
for (size_t dep_i = 0; dep_i < deps_.size(); dep_i++) { |
const Target* dep = deps_[dep_i].ptr; |
- MergeAllDependentConfigsFrom(dep, unique_configs, &configs_, |
- &all_dependent_configs_); |
- MergeDirectDependentConfigsFrom(dep, unique_configs, &configs_); |
+ MergeAllDependentConfigsFrom(dep, &configs_, &all_dependent_configs_); |
+ MergeDirectDependentConfigsFrom(dep, &configs_); |
// Direct dependent libraries. |
if (dep->output_type() == STATIC_LIBRARY || |
dep->output_type() == SHARED_LIBRARY || |
dep->output_type() == SOURCE_SET) |
- inherited_libraries_.insert(dep); |
+ inherited_libraries_.push_back(dep); |
// Inherited libraries and flags are inherited across static library |
// boundaries. |
if (dep->output_type() != SHARED_LIBRARY && |
dep->output_type() != EXECUTABLE) { |
- const std::set<const Target*> inherited = dep->inherited_libraries(); |
- for (std::set<const Target*>::const_iterator i = inherited.begin(); |
- i != inherited.end(); ++i) |
- inherited_libraries_.insert(*i); |
+ inherited_libraries_.Append(dep->inherited_libraries().begin(), |
+ dep->inherited_libraries().end()); |
// Inherited library settings. |
all_lib_dirs_.append(dep->all_lib_dirs()); |
@@ -188,8 +155,10 @@ void Target::PullDependentTargetInfo(std::set<const Config*>* unique_configs) { |
void Target::PullForwardedDependentConfigs() { |
// Groups implicitly forward all if its dependency's configs. |
- if (output_type() == GROUP) |
- forward_dependent_configs_ = deps_; |
+ if (output_type() == GROUP) { |
+ for (size_t i = 0; i < deps_.size(); i++) |
+ forward_dependent_configs_.push_back(deps_[i]); |
+ } |
// Forward direct dependent configs if requested. |
for (size_t dep = 0; dep < forward_dependent_configs_.size(); dep++) { |
@@ -200,8 +169,7 @@ void Target::PullForwardedDependentConfigs() { |
DCHECK(std::find_if(deps_.begin(), deps_.end(), |
LabelPtrPtrEquals<Target>(from_target)) != |
deps_.end()); |
- direct_dependent_configs_.insert( |
- direct_dependent_configs_.end(), |
+ direct_dependent_configs_.Append( |
from_target->direct_dependent_configs().begin(), |
from_target->direct_dependent_configs().end()); |
} |