Chromium Code Reviews| 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" |
| 11 #include "tools/gn/deps_iterator.h" | 11 #include "tools/gn/deps_iterator.h" |
| 12 #include "tools/gn/filesystem_utils.h" | 12 #include "tools/gn/filesystem_utils.h" |
| 13 #include "tools/gn/pointer_set.h" | |
| 13 #include "tools/gn/scheduler.h" | 14 #include "tools/gn/scheduler.h" |
| 14 #include "tools/gn/substitution_writer.h" | 15 #include "tools/gn/substitution_writer.h" |
| 15 #include "tools/gn/trace.h" | 16 #include "tools/gn/trace.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 typedef std::set<const Config*> ConfigSet; | 20 typedef std::set<const Config*> ConfigSet; |
| 20 | 21 |
| 21 // Merges the public configs from the given target to the given config list. | 22 // Merges the public configs from the given target to the given config list. |
| 22 void MergePublicConfigsFrom(const Target* from_target, | 23 void MergePublicConfigsFrom(const Target* from_target, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 | 64 |
| 64 // Set check_private_deps to true for the first invocation since a target | 65 // Set check_private_deps to true for the first invocation since a target |
| 65 // can see all of its dependencies. For recursive invocations this will be set | 66 // can see all of its dependencies. For recursive invocations this will be set |
| 66 // to false to follow only public dependency paths. | 67 // to false to follow only public dependency paths. |
| 67 // | 68 // |
| 68 // Pass a pointer to an empty set for the first invocation. This will be used | 69 // Pass a pointer to an empty set for the first invocation. This will be used |
| 69 // to avoid duplicate checking. | 70 // to avoid duplicate checking. |
| 70 bool EnsureFileIsGeneratedByDependency(const Target* target, | 71 bool EnsureFileIsGeneratedByDependency(const Target* target, |
| 71 const OutputFile& file, | 72 const OutputFile& file, |
| 72 bool check_private_deps, | 73 bool check_private_deps, |
| 73 std::set<const Target*>* seen_targets) { | 74 PointerSet<const Target>* seen_targets) { |
| 74 if (seen_targets->find(target) != seen_targets->end()) | 75 if (seen_targets->find(target) != seen_targets->end()) |
| 75 return false; // Already checked this one and it's not found. | 76 return false; // Already checked this one and it's not found. |
| 76 seen_targets->insert(target); | 77 seen_targets->insert(target); |
| 77 | 78 |
| 78 // Assume that we have relatively few generated inputs so brute-force | 79 // Assume that we have relatively few generated inputs so brute-force |
| 79 // searching here is OK. If this becomes a bottleneck, consider storing | 80 // searching here is OK. If this becomes a bottleneck, consider storing |
| 80 // computed_outputs as a hash set. | 81 // computed_outputs as a hash set. |
| 81 for (const OutputFile& cur : target->computed_outputs()) { | 82 for (const OutputFile& cur : target->computed_outputs()) { |
| 82 if (file == cur) | 83 if (file == cur) |
| 83 return true; | 84 return true; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 | 542 |
| 542 void Target::CheckSourceGenerated(const SourceFile& source) const { | 543 void Target::CheckSourceGenerated(const SourceFile& source) const { |
| 543 if (!IsStringInOutputDir(settings()->build_settings()->build_dir(), | 544 if (!IsStringInOutputDir(settings()->build_settings()->build_dir(), |
| 544 source.value())) | 545 source.value())) |
| 545 return; // Not in output dir, this is OK. | 546 return; // Not in output dir, this is OK. |
| 546 | 547 |
| 547 // Tell the scheduler about unknown files. This will be noted for later so | 548 // Tell the scheduler about unknown files. This will be noted for later so |
| 548 // the list of files written by the GN build itself (often response files) | 549 // the list of files written by the GN build itself (often response files) |
| 549 // can be filtered out of this list. | 550 // can be filtered out of this list. |
| 550 OutputFile out_file(settings()->build_settings(), source); | 551 OutputFile out_file(settings()->build_settings(), source); |
| 551 std::set<const Target*> seen_targets; | 552 PointerSet<const Target> seen_targets; |
| 552 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) | 553 if (!EnsureFileIsGeneratedByDependency(this, out_file, true, &seen_targets)) |
| 553 g_scheduler->AddUnknownGeneratedInput(this, source); | 554 g_scheduler->AddUnknownGeneratedInput(this, source); |
| 554 } | 555 } |
| 556 | |
| 557 bool Target::operator<(const Target& other) const { | |
|
mithro-old
2015/12/03 05:20:31
I'm unsure if we want an implicit less than operat
Zachary Forman
2015/12/03 07:27:02
Acknowledged.
I'll leave this for the GN develope
| |
| 558 return label() < other.label(); | |
| 559 } | |
| OLD | NEW |