Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1255)

Side by Side Diff: tools/gn/command_refs.cc

Issue 561273003: Add public deps to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/config_values_extractors_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/filesystem_utils.h" 11 #include "tools/gn/filesystem_utils.h"
11 #include "tools/gn/input_file.h" 12 #include "tools/gn/input_file.h"
12 #include "tools/gn/item.h" 13 #include "tools/gn/item.h"
13 #include "tools/gn/setup.h" 14 #include "tools/gn/setup.h"
14 #include "tools/gn/standard_out.h" 15 #include "tools/gn/standard_out.h"
15 #include "tools/gn/target.h" 16 #include "tools/gn/target.h"
16 17
17 namespace commands { 18 namespace commands {
18 19
19 namespace { 20 namespace {
20 21
21 typedef std::set<const Target*> TargetSet; 22 typedef std::set<const Target*> TargetSet;
22 typedef std::vector<const Target*> TargetVector; 23 typedef std::vector<const Target*> TargetVector;
23 24
24 // Maps targets to the list of targets that depend on them. 25 // Maps targets to the list of targets that depend on them.
25 typedef std::multimap<const Target*, const Target*> DepMap; 26 typedef std::multimap<const Target*, const Target*> DepMap;
26 27
27 // Populates the reverse dependency map for the targets in the Setup. 28 // Populates the reverse dependency map for the targets in the Setup.
28 void FillDepMap(Setup* setup, DepMap* dep_map) { 29 void FillDepMap(Setup* setup, DepMap* dep_map) {
29 std::vector<const Target*> targets = 30 std::vector<const Target*> targets =
30 setup->builder()->GetAllResolvedTargets(); 31 setup->builder()->GetAllResolvedTargets();
31 32
32 for (size_t target_i = 0; target_i < targets.size(); target_i++) { 33 for (size_t target_i = 0; target_i < targets.size(); target_i++) {
33 const Target* target = targets[target_i]; 34 for (DepsIterator iter(targets[target_i]); !iter.done(); iter.Advance())
34 35 dep_map->insert(std::make_pair(iter.target(), targets[target_i]));
35 // Add all deps to the map.
36 const LabelTargetVector& deps = target->deps();
37 for (size_t dep_i = 0; dep_i < deps.size(); dep_i++)
38 dep_map->insert(std::make_pair(deps[dep_i].ptr, target));
39
40 // Include data deps as well.
41 const LabelTargetVector& datadeps = target->datadeps();
42 for (size_t dep_i = 0; dep_i < datadeps.size(); dep_i++)
43 dep_map->insert(std::make_pair(datadeps[dep_i].ptr, target));
44 } 36 }
45 } 37 }
46 38
47 // Returns the file path generating this item. 39 // Returns the file path generating this item.
48 base::FilePath FilePathForItem(const Item* item) { 40 base::FilePath FilePathForItem(const Item* item) {
49 return item->defined_from()->GetRange().begin().file()->physical_name(); 41 return item->defined_from()->GetRange().begin().file()->physical_name();
50 } 42 }
51 43
52 // Prints the targets which are the result of a query. This list is sorted 44 // Prints the targets which are the result of a query. This list is sorted
53 // and, if as_files is set, the unique filenames matching those targets will 45 // 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
283 cur_dep != dep_end; cur_dep++) 275 cur_dep != dep_end; cur_dep++)
284 results.insert(cur_dep->second); 276 results.insert(cur_dep->second);
285 } 277 }
286 OutputResultSet(results, files); 278 OutputResultSet(results, files);
287 } 279 }
288 280
289 return 0; 281 return 0;
290 } 282 }
291 283
292 } // namespace commands 284 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_desc.cc ('k') | tools/gn/config_values_extractors_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698