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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "tools/gn/commands.h" | 9 #include "tools/gn/commands.h" |
10 #include "tools/gn/deps_iterator.h" | 10 #include "tools/gn/deps_iterator.h" |
11 #include "tools/gn/filesystem_utils.h" | 11 #include "tools/gn/filesystem_utils.h" |
12 #include "tools/gn/input_file.h" | 12 #include "tools/gn/input_file.h" |
13 #include "tools/gn/item.h" | 13 #include "tools/gn/item.h" |
14 #include "tools/gn/setup.h" | 14 #include "tools/gn/setup.h" |
15 #include "tools/gn/standard_out.h" | 15 #include "tools/gn/standard_out.h" |
16 #include "tools/gn/target.h" | 16 #include "tools/gn/target.h" |
17 | 17 |
18 namespace commands { | 18 namespace commands { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 typedef std::set<const Target*> TargetSet; | 22 typedef std::set<const Target*> TargetSet; |
23 typedef std::vector<const Target*> TargetVector; | 23 typedef std::vector<const Target*> TargetVector; |
tfarina
2014/09/27 00:33:56
you can remove this, it is unused.
brettw
2014/09/27 22:23:03
Thanks, will pick this up in the next pass if that
| |
24 | 24 |
25 // Maps targets to the list of targets that depend on them. | 25 // Maps targets to the list of targets that depend on them. |
26 typedef std::multimap<const Target*, const Target*> DepMap; | 26 typedef std::multimap<const Target*, const Target*> DepMap; |
27 | 27 |
28 // Populates the reverse dependency map for the targets in the Setup. | 28 // Populates the reverse dependency map for the targets in the Setup. |
29 void FillDepMap(Setup* setup, DepMap* dep_map) { | 29 void FillDepMap(Setup* setup, DepMap* dep_map) { |
30 std::vector<const Target*> targets = | 30 for (const auto& target : setup->builder()->GetAllResolvedTargets()) { |
31 setup->builder()->GetAllResolvedTargets(); | 31 for (const auto& dep_pair : target->GetDeps(Target::DEPS_ALL)) |
32 | 32 dep_map->insert(std::make_pair(dep_pair.ptr, target)); |
33 for (size_t target_i = 0; target_i < targets.size(); target_i++) { | |
34 for (DepsIterator iter(targets[target_i]); !iter.done(); iter.Advance()) | |
35 dep_map->insert(std::make_pair(iter.target(), targets[target_i])); | |
36 } | 33 } |
37 } | 34 } |
38 | 35 |
39 // Returns the file path generating this item. | 36 // Returns the file path generating this item. |
40 base::FilePath FilePathForItem(const Item* item) { | 37 base::FilePath FilePathForItem(const Item* item) { |
41 return item->defined_from()->GetRange().begin().file()->physical_name(); | 38 return item->defined_from()->GetRange().begin().file()->physical_name(); |
42 } | 39 } |
43 | 40 |
44 // Prints the targets which are the result of a query. This list is sorted | 41 // Prints the targets which are the result of a query. This list is sorted |
45 // and, if as_files is set, the unique filenames matching those targets will | 42 // and, if as_files is set, the unique filenames matching those targets will |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 cur_dep != dep_end; cur_dep++) | 272 cur_dep != dep_end; cur_dep++) |
276 results.insert(cur_dep->second); | 273 results.insert(cur_dep->second); |
277 } | 274 } |
278 OutputResultSet(results, files); | 275 OutputResultSet(results, files); |
279 } | 276 } |
280 | 277 |
281 return 0; | 278 return 0; |
282 } | 279 } |
283 | 280 |
284 } // namespace commands | 281 } // namespace commands |
OLD | NEW |