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

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: 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
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/filesystem_utils.h" 10 #include "tools/gn/filesystem_utils.h"
(...skipping 12 matching lines...) Expand all
23 23
24 // Maps targets to the list of targets that depend on them. 24 // Maps targets to the list of targets that depend on them.
25 typedef std::multimap<const Target*, const Target*> DepMap; 25 typedef std::multimap<const Target*, const Target*> DepMap;
26 26
27 // Populates the reverse dependency map for the targets in the Setup. 27 // Populates the reverse dependency map for the targets in the Setup.
28 void FillDepMap(Setup* setup, DepMap* dep_map) { 28 void FillDepMap(Setup* setup, DepMap* dep_map) {
29 std::vector<const Target*> targets = 29 std::vector<const Target*> targets =
30 setup->builder()->GetAllResolvedTargets(); 30 setup->builder()->GetAllResolvedTargets();
31 31
32 for (size_t target_i = 0; target_i < targets.size(); target_i++) { 32 for (size_t target_i = 0; target_i < targets.size(); target_i++) {
33 const Target* target = targets[target_i]; 33 for (DepsIterator iter(targets[target_i]); !iter.done(); iter.Advance())
34 34 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 } 35 }
45 } 36 }
46 37
47 // Returns the file path generating this item. 38 // Returns the file path generating this item.
48 base::FilePath FilePathForItem(const Item* item) { 39 base::FilePath FilePathForItem(const Item* item) {
49 return item->defined_from()->GetRange().begin().file()->physical_name(); 40 return item->defined_from()->GetRange().begin().file()->physical_name();
50 } 41 }
51 42
52 // Prints the targets which are the result of a query. This list is sorted 43 // 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 44 // 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++) 274 cur_dep != dep_end; cur_dep++)
284 results.insert(cur_dep->second); 275 results.insert(cur_dep->second);
285 } 276 }
286 OutputResultSet(results, files); 277 OutputResultSet(results, files);
287 } 278 }
288 279
289 return 0; 280 return 0;
290 } 281 }
291 282
292 } // namespace commands 283 } // namespace commands
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698