| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 typedef std::set<const Target*> TargetSet; | 27 typedef std::set<const Target*> TargetSet; |
| 28 typedef std::vector<const Target*> TargetVector; | 28 typedef std::vector<const Target*> TargetVector; |
| 29 | 29 |
| 30 // Maps targets to the list of targets that depend on them. | 30 // Maps targets to the list of targets that depend on them. |
| 31 typedef std::multimap<const Target*, const Target*> DepMap; | 31 typedef std::multimap<const Target*, const Target*> DepMap; |
| 32 | 32 |
| 33 // Populates the reverse dependency map for the targets in the Setup. | 33 // Populates the reverse dependency map for the targets in the Setup. |
| 34 void FillDepMap(Setup* setup, DepMap* dep_map) { | 34 void FillDepMap(Setup* setup, DepMap* dep_map) { |
| 35 for (auto* target : setup->builder()->GetAllResolvedTargets()) { | 35 for (auto* target : setup->builder().GetAllResolvedTargets()) { |
| 36 for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL)) | 36 for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL)) |
| 37 dep_map->insert(std::make_pair(dep_pair.ptr, target)); | 37 dep_map->insert(std::make_pair(dep_pair.ptr, target)); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Forward declaration for function below. | 41 // Forward declaration for function below. |
| 42 size_t RecursivePrintTargetDeps(const DepMap& dep_map, | 42 size_t RecursivePrintTargetDeps(const DepMap& dep_map, |
| 43 const Target* target, | 43 const Target* target, |
| 44 TargetSet* seen_targets, | 44 TargetSet* seen_targets, |
| 45 int indent_level); | 45 int indent_level); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 &target_matches, &config_matches, | 429 &target_matches, &config_matches, |
| 430 &toolchain_matches, &file_matches)) | 430 &toolchain_matches, &file_matches)) |
| 431 return 1; | 431 return 1; |
| 432 | 432 |
| 433 // When you give a file or config as an input, you want the targets that are | 433 // When you give a file or config as an input, you want the targets that are |
| 434 // associated with it. We don't want to just append this to the | 434 // associated with it. We don't want to just append this to the |
| 435 // target_matches, however, since these targets should actually be listed in | 435 // target_matches, however, since these targets should actually be listed in |
| 436 // the output, while for normal targets you don't want to see the inputs, | 436 // the output, while for normal targets you don't want to see the inputs, |
| 437 // only what refers to them. | 437 // only what refers to them. |
| 438 std::vector<const Target*> all_targets = | 438 std::vector<const Target*> all_targets = |
| 439 setup->builder()->GetAllResolvedTargets(); | 439 setup->builder().GetAllResolvedTargets(); |
| 440 UniqueVector<const Target*> explicit_target_matches; | 440 UniqueVector<const Target*> explicit_target_matches; |
| 441 for (const auto& file : file_matches) { | 441 for (const auto& file : file_matches) { |
| 442 GetTargetsContainingFile(setup, all_targets, file, all_toolchains, | 442 GetTargetsContainingFile(setup, all_targets, file, all_toolchains, |
| 443 &explicit_target_matches); | 443 &explicit_target_matches); |
| 444 } | 444 } |
| 445 for (auto* config : config_matches) { | 445 for (auto* config : config_matches) { |
| 446 GetTargetsReferencingConfig(setup, all_targets, config, all_toolchains, | 446 GetTargetsReferencingConfig(setup, all_targets, config, all_toolchains, |
| 447 &explicit_target_matches); | 447 &explicit_target_matches); |
| 448 } | 448 } |
| 449 | 449 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 474 | 474 |
| 475 // If you ask for the references of a valid target, but that target has | 475 // If you ask for the references of a valid target, but that target has |
| 476 // nothing referencing it, we'll get here without having printed anything. | 476 // nothing referencing it, we'll get here without having printed anything. |
| 477 if (!quiet && cnt == 0) | 477 if (!quiet && cnt == 0) |
| 478 OutputString("Nothing references this.\n", DECORATION_YELLOW); | 478 OutputString("Nothing references this.\n", DECORATION_YELLOW); |
| 479 | 479 |
| 480 return 0; | 480 return 0; |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace commands | 483 } // namespace commands |
| OLD | NEW |