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

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

Issue 22290010: Add support for data deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove switch Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/command_gen.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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "tools/gn/commands.h" 10 #include "tools/gn/commands.h"
(...skipping 17 matching lines...) Expand all
28 }; 28 };
29 29
30 void RecursiveCollectDeps(const Target* target, std::set<Label>* result) { 30 void RecursiveCollectDeps(const Target* target, std::set<Label>* result) {
31 if (result->find(target->label()) != result->end()) 31 if (result->find(target->label()) != result->end())
32 return; // Already did this target. 32 return; // Already did this target.
33 result->insert(target->label()); 33 result->insert(target->label());
34 34
35 const std::vector<const Target*>& deps = target->deps(); 35 const std::vector<const Target*>& deps = target->deps();
36 for (size_t i = 0; i < deps.size(); i++) 36 for (size_t i = 0; i < deps.size(); i++)
37 RecursiveCollectDeps(deps[i], result); 37 RecursiveCollectDeps(deps[i], result);
38
39 const std::vector<const Target*>& datadeps = target->datadeps();
40 for (size_t i = 0; i < datadeps.size(); i++)
41 RecursiveCollectDeps(datadeps[i], result);
38 } 42 }
39 43
40 // Prints dependencies of the given target (not the target itself). 44 // Prints dependencies of the given target (not the target itself).
41 void RecursivePrintDeps(const Target* target, 45 void RecursivePrintDeps(const Target* target,
42 const Label& default_toolchain, 46 const Label& default_toolchain,
43 int indent_level) { 47 int indent_level) {
44 std::vector<const Target*> sorted_deps = target->deps(); 48 std::vector<const Target*> sorted_deps = target->deps();
49 const std::vector<const Target*> datadeps = target->datadeps();
50 for (size_t i = 0; i < datadeps.size(); i++)
51 sorted_deps.push_back(datadeps[i]);
45 std::sort(sorted_deps.begin(), sorted_deps.end(), CompareTargetLabel()); 52 std::sort(sorted_deps.begin(), sorted_deps.end(), CompareTargetLabel());
46 53
47 std::string indent(indent_level * 2, ' '); 54 std::string indent(indent_level * 2, ' ');
48 for (size_t i = 0; i < sorted_deps.size(); i++) { 55 for (size_t i = 0; i < sorted_deps.size(); i++) {
49 OutputString(indent + 56 OutputString(indent +
50 sorted_deps[i]->label().GetUserVisibleName(default_toolchain) + "\n"); 57 sorted_deps[i]->label().GetUserVisibleName(default_toolchain) + "\n");
51 RecursivePrintDeps(sorted_deps[i], default_toolchain, indent_level + 1); 58 RecursivePrintDeps(sorted_deps[i], default_toolchain, indent_level + 1);
52 } 59 }
53 } 60 }
54 61
55 void PrintDeps(const Target* target, bool display_header) { 62 void PrintDeps(const Target* target, bool display_header) {
63 const CommandLine* cmdline = CommandLine::ForCurrentProcess();
56 Label toolchain_label = target->label().GetToolchainLabel(); 64 Label toolchain_label = target->label().GetToolchainLabel();
57 65
58 // Tree mode is separate. 66 // Tree mode is separate.
59 if (CommandLine::ForCurrentProcess()->HasSwitch("tree")) { 67 if (cmdline->HasSwitch("tree")) {
60 if (display_header) 68 if (display_header)
61 OutputString("\nDependency tree:\n"); 69 OutputString("\nDependency tree:\n");
62 RecursivePrintDeps(target, toolchain_label, 1); 70 RecursivePrintDeps(target, toolchain_label, 1);
63 return; 71 return;
64 } 72 }
65 73
66 // Collect the deps to display. 74 // Collect the deps to display.
67 std::vector<Label> deps; 75 std::vector<Label> deps;
68 if (CommandLine::ForCurrentProcess()->HasSwitch("all")) { 76 if (cmdline->HasSwitch("all")) {
69 if (display_header) 77 if (display_header)
70 OutputString("\nAll recursive dependencies:\n"); 78 OutputString("\nAll recursive dependencies:\n");
71 79
72 std::set<Label> all_deps; 80 std::set<Label> all_deps;
73 RecursiveCollectDeps(target, &all_deps); 81 RecursiveCollectDeps(target, &all_deps);
74 for (std::set<Label>::iterator i = all_deps.begin(); 82 for (std::set<Label>::iterator i = all_deps.begin();
75 i != all_deps.end(); ++i) 83 i != all_deps.end(); ++i)
76 deps.push_back(*i); 84 deps.push_back(*i);
77 } else { 85 } else {
78 if (display_header) { 86 if (display_header) {
79 OutputString("\nDirect dependencies " 87 OutputString("\nDirect dependencies "
80 "(try also \"--all\" and \"--tree\"):\n"); 88 "(try also \"--all\" and \"--tree\"):\n");
81 } 89 }
82 90
83 const std::vector<const Target*>& target_deps = target->deps(); 91 const std::vector<const Target*>& target_deps = target->deps();
84 for (size_t i = 0; i < target_deps.size(); i++) 92 for (size_t i = 0; i < target_deps.size(); i++)
85 deps.push_back(target_deps[i]->label()); 93 deps.push_back(target_deps[i]->label());
94
95 const std::vector<const Target*>& target_datadeps = target->datadeps();
96 for (size_t i = 0; i < target_datadeps.size(); i++)
97 deps.push_back(target_datadeps[i]->label());
86 } 98 }
87 99
88 std::sort(deps.begin(), deps.end()); 100 std::sort(deps.begin(), deps.end());
89 for (size_t i = 0; i < deps.size(); i++) 101 for (size_t i = 0; i < deps.size(); i++)
90 OutputString(" " + deps[i].GetUserVisibleName(toolchain_label) + "\n"); 102 OutputString(" " + deps[i].GetUserVisibleName(toolchain_label) + "\n");
91 } 103 }
92 104
93 void PrintConfigs(const Target* target, bool display_header) { 105 void PrintConfigs(const Target* target, bool display_header) {
94 // Configs (don't sort since the order determines how things are processed). 106 // Configs (don't sort since the order determines how things are processed).
95 if (display_header) 107 if (display_header)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 " configs\n" 231 " configs\n"
220 " Shows configs applied to the given target, sorted in the order\n" 232 " Shows configs applied to the given target, sorted in the order\n"
221 " they're specified. This includes both configs specified in the\n" 233 " they're specified. This includes both configs specified in the\n"
222 " \"configs\" variable, as well as configs pushed onto this target\n" 234 " \"configs\" variable, as well as configs pushed onto this target\n"
223 " via dependencies specifying \"all\" or \"direct\" dependent\n" 235 " via dependencies specifying \"all\" or \"direct\" dependent\n"
224 " configs.\n" 236 " configs.\n"
225 "\n" 237 "\n"
226 " deps [--all | --tree]\n" 238 " deps [--all | --tree]\n"
227 " Show immediate (or, when \"--all\" or \"--tree\" is specified,\n" 239 " Show immediate (or, when \"--all\" or \"--tree\" is specified,\n"
228 " recursive) dependencies of the given target. \"--tree\" shows them\n" 240 " recursive) dependencies of the given target. \"--tree\" shows them\n"
229 " in a tree format. Otherwise, they will be sorted alphabetically.\n" 241 " in a tree format. Otherwise, they will be sorted alphabetically.\n"
242 " Both \"deps\" and \"datadeps\" will be included.\n"
230 "\n" 243 "\n"
231 " defines [--blame]\n" 244 " defines [--blame]\n"
232 " includes [--blame]\n" 245 " includes [--blame]\n"
233 " cflags [--blame]\n" 246 " cflags [--blame]\n"
234 " cflags_cc [--blame]\n" 247 " cflags_cc [--blame]\n"
235 " cflags_cxx [--blame]\n" 248 " cflags_cxx [--blame]\n"
236 " ldflags [--blame]\n" 249 " ldflags [--blame]\n"
237 " Shows the given values taken from the target and all configs\n" 250 " Shows the given values taken from the target and all configs\n"
238 " applying. See \"--blame\" below.\n" 251 " applying. See \"--blame\" below.\n"
239 "\n" 252 "\n"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 PrintConfigs(target, true); 335 PrintConfigs(target, true);
323 OutputString("\n (Use \"gn desc <label> <thing you want to see>\" to show " 336 OutputString("\n (Use \"gn desc <label> <thing you want to see>\" to show "
324 "the actual values\n applied by the different configs. " 337 "the actual values\n applied by the different configs. "
325 "See \"gn help desc\" for more.)\n"); 338 "See \"gn help desc\" for more.)\n");
326 PrintDeps(target, true); 339 PrintDeps(target, true);
327 340
328 return 0; 341 return 0;
329 } 342 }
330 343
331 } // namespace commands 344 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/command_gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698