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