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

Side by Side Diff: tools/gn/target.cc

Issue 255603004: Forward dependent configs from groups properly in GN. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/target.h ('k') | tools/gn/target_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/target.h" 5 #include "tools/gn/target.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "tools/gn/config_values_extractors.h" 8 #include "tools/gn/config_values_extractors.h"
9 #include "tools/gn/scheduler.h" 9 #include "tools/gn/scheduler.h"
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 if (output_type_ != GROUP) { 142 if (output_type_ != GROUP) {
143 // Don't pull target info like libraries and configs from dependencies into 143 // Don't pull target info like libraries and configs from dependencies into
144 // a group target. When A depends on a group G, the G's dependents will 144 // a group target. When A depends on a group G, the G's dependents will
145 // be treated as direct dependencies of A, so this is unnecessary and will 145 // be treated as direct dependencies of A, so this is unnecessary and will
146 // actually result in duplicated settings (since settings will also be 146 // actually result in duplicated settings (since settings will also be
147 // pulled from G to A in case G has configs directly on it). 147 // pulled from G to A in case G has configs directly on it).
148 PullDependentTargetInfo(&unique_configs); 148 PullDependentTargetInfo(&unique_configs);
149 } 149 }
150 PullForwardedDependentConfigs();
150 } 151 }
151 152
152 bool Target::IsLinkable() const { 153 bool Target::IsLinkable() const {
153 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY; 154 return output_type_ == STATIC_LIBRARY || output_type_ == SHARED_LIBRARY;
154 } 155 }
155 156
156 void Target::PullDependentTargetInfo(std::set<const Config*>* unique_configs) { 157 void Target::PullDependentTargetInfo(std::set<const Config*>* unique_configs) {
157 // Gather info from our dependents we need. 158 // Gather info from our dependents we need.
158 for (size_t dep_i = 0; dep_i < deps_.size(); dep_i++) { 159 for (size_t dep_i = 0; dep_i < deps_.size(); dep_i++) {
159 const Target* dep = deps_[dep_i].ptr; 160 const Target* dep = deps_[dep_i].ptr;
(...skipping 14 matching lines...) Expand all
174 const std::set<const Target*> inherited = dep->inherited_libraries(); 175 const std::set<const Target*> inherited = dep->inherited_libraries();
175 for (std::set<const Target*>::const_iterator i = inherited.begin(); 176 for (std::set<const Target*>::const_iterator i = inherited.begin();
176 i != inherited.end(); ++i) 177 i != inherited.end(); ++i)
177 inherited_libraries_.insert(*i); 178 inherited_libraries_.insert(*i);
178 179
179 // Inherited library settings. 180 // Inherited library settings.
180 all_lib_dirs_.append(dep->all_lib_dirs()); 181 all_lib_dirs_.append(dep->all_lib_dirs());
181 all_libs_.append(dep->all_libs()); 182 all_libs_.append(dep->all_libs());
182 } 183 }
183 } 184 }
185 }
186
187 void Target::PullForwardedDependentConfigs() {
188 // Groups implicitly forward all if its dependency's configs.
189 if (output_type() == GROUP)
190 forward_dependent_configs_ = deps_;
184 191
185 // Forward direct dependent configs if requested. 192 // Forward direct dependent configs if requested.
186 for (size_t dep = 0; dep < forward_dependent_configs_.size(); dep++) { 193 for (size_t dep = 0; dep < forward_dependent_configs_.size(); dep++) {
187 const Target* from_target = forward_dependent_configs_[dep].ptr; 194 const Target* from_target = forward_dependent_configs_[dep].ptr;
188 195
189 // The forward_dependent_configs_ must be in the deps already, so we 196 // The forward_dependent_configs_ must be in the deps already, so we
190 // don't need to bother copying to our configs, only forwarding. 197 // don't need to bother copying to our configs, only forwarding.
191 DCHECK(std::find_if(deps_.begin(), deps_.end(), 198 DCHECK(std::find_if(deps_.begin(), deps_.end(),
192 LabelPtrPtrEquals<Target>(from_target)) != 199 LabelPtrPtrEquals<Target>(from_target)) !=
193 deps_.end()); 200 deps_.end());
194 direct_dependent_configs_.insert( 201 direct_dependent_configs_.insert(
195 direct_dependent_configs_.end(), 202 direct_dependent_configs_.end(),
196 from_target->direct_dependent_configs().begin(), 203 from_target->direct_dependent_configs().begin(),
197 from_target->direct_dependent_configs().end()); 204 from_target->direct_dependent_configs().end());
198 } 205 }
199 } 206 }
OLDNEW
« 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