| OLD | NEW |
| 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 "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "tools/gn/config_values_extractors.h" | 10 #include "tools/gn/config_values_extractors.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // Copy our own libs and lib_dirs to the final set. This will be from our | 161 // Copy our own libs and lib_dirs to the final set. This will be from our |
| 162 // target and all of our configs. We do this specially since these must be | 162 // target and all of our configs. We do this specially since these must be |
| 163 // inherited through the dependency tree (other flags don't work this way). | 163 // inherited through the dependency tree (other flags don't work this way). |
| 164 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { | 164 for (ConfigValuesIterator iter(this); !iter.done(); iter.Next()) { |
| 165 const ConfigValues& cur = iter.cur(); | 165 const ConfigValues& cur = iter.cur(); |
| 166 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); | 166 all_lib_dirs_.append(cur.lib_dirs().begin(), cur.lib_dirs().end()); |
| 167 all_libs_.append(cur.libs().begin(), cur.libs().end()); | 167 all_libs_.append(cur.libs().begin(), cur.libs().end()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 PullDependentTargets(); | 170 PullDependentTargets(); |
| 171 PullForwardedDependentConfigs(); | 171 PullPublicConfigs(); |
| 172 PullRecursiveHardDeps(); | 172 PullRecursiveHardDeps(); |
| 173 if (!ResolvePrecompiledHeaders(err)) | 173 if (!ResolvePrecompiledHeaders(err)) |
| 174 return false; | 174 return false; |
| 175 | 175 |
| 176 FillOutputFiles(); | 176 FillOutputFiles(); |
| 177 | 177 |
| 178 if (settings()->build_settings()->check_for_bad_items()) { | 178 if (settings()->build_settings()->check_for_bad_items()) { |
| 179 if (!CheckVisibility(err)) | 179 if (!CheckVisibility(err)) |
| 180 return false; | 180 return false; |
| 181 if (!CheckTestonly(err)) | 181 if (!CheckTestonly(err)) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 void Target::PullDependentTargets() { | 301 void Target::PullDependentTargets() { |
| 302 for (const auto& dep : public_deps_) | 302 for (const auto& dep : public_deps_) |
| 303 PullDependentTarget(dep.ptr, true); | 303 PullDependentTarget(dep.ptr, true); |
| 304 for (const auto& dep : private_deps_) | 304 for (const auto& dep : private_deps_) |
| 305 PullDependentTarget(dep.ptr, false); | 305 PullDependentTarget(dep.ptr, false); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void Target::PullForwardedDependentConfigs() { | 308 void Target::PullPublicConfigs() { |
| 309 // Pull public configs from each of our dependency's public deps. | 309 // Pull public configs from each of our dependency's public deps. |
| 310 for (const auto& dep : public_deps_) | 310 for (const auto& dep : public_deps_) |
| 311 PullForwardedDependentConfigsFrom(dep.ptr); | 311 PullPublicConfigsFrom(dep.ptr); |
| 312 | |
| 313 // Forward public configs if explicitly requested. | |
| 314 for (const auto& dep : forward_dependent_configs_) { | |
| 315 const Target* from_target = dep.ptr; | |
| 316 | |
| 317 // The forward_dependent_configs_ must be in the deps (public or private) | |
| 318 // already, so we don't need to bother copying to our configs, only | |
| 319 // forwarding. | |
| 320 DCHECK(std::find_if(private_deps_.begin(), private_deps_.end(), | |
| 321 LabelPtrPtrEquals<Target>(from_target)) != | |
| 322 private_deps_.end() || | |
| 323 std::find_if(public_deps_.begin(), public_deps_.end(), | |
| 324 LabelPtrPtrEquals<Target>(from_target)) != | |
| 325 public_deps_.end()); | |
| 326 | |
| 327 PullForwardedDependentConfigsFrom(from_target); | |
| 328 } | |
| 329 } | 312 } |
| 330 | 313 |
| 331 void Target::PullForwardedDependentConfigsFrom(const Target* from) { | 314 void Target::PullPublicConfigsFrom(const Target* from) { |
| 332 public_configs_.Append(from->public_configs().begin(), | 315 public_configs_.Append(from->public_configs().begin(), |
| 333 from->public_configs().end()); | 316 from->public_configs().end()); |
| 334 } | 317 } |
| 335 | 318 |
| 336 void Target::PullRecursiveHardDeps() { | 319 void Target::PullRecursiveHardDeps() { |
| 337 for (const auto& pair : GetDeps(DEPS_LINKED)) { | 320 for (const auto& pair : GetDeps(DEPS_LINKED)) { |
| 338 if (pair.ptr->hard_dep()) | 321 if (pair.ptr->hard_dep()) |
| 339 recursive_hard_deps_.insert(pair.ptr); | 322 recursive_hard_deps_.insert(pair.ptr); |
| 340 | 323 |
| 341 // Android STL doesn't like insert(begin, end) so do it manually. | 324 // Android STL doesn't like insert(begin, end) so do it manually. |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 return; // Not in output dir, this is OK. | 537 return; // Not in output dir, this is OK. |
| 555 | 538 |
| 556 // Tell the scheduler about unknown files. This will be noted for later so | 539 // Tell the scheduler about unknown files. This will be noted for later so |
| 557 // the list of files written by the GN build itself (often response files) | 540 // the list of files written by the GN build itself (often response files) |
| 558 // can be filtered out of this list. | 541 // can be filtered out of this list. |
| 559 OutputFile out_file(settings()->build_settings(), source); | 542 OutputFile out_file(settings()->build_settings(), source); |
| 560 std::set<const Target*> seen_targets; | 543 std::set<const Target*> seen_targets; |
| 561 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) | 544 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) |
| 562 g_scheduler->AddUnknownGeneratedInput(this, source); | 545 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 563 } | 546 } |
| OLD | NEW |