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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 | 7 |
8 #include "tools/gn/args.h" | 8 #include "tools/gn/args.h" |
9 #include "tools/gn/commands.h" | 9 #include "tools/gn/commands.h" |
10 #include "tools/gn/err.h" | 10 #include "tools/gn/err.h" |
11 #include "tools/gn/functions.h" | 11 #include "tools/gn/functions.h" |
12 #include "tools/gn/input_conversion.h" | 12 #include "tools/gn/input_conversion.h" |
13 #include "tools/gn/label_pattern.h" | 13 #include "tools/gn/label_pattern.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/substitution_writer.h" | 16 #include "tools/gn/substitution_writer.h" |
17 #include "tools/gn/variables.h" | 17 #include "tools/gn/variables.h" |
18 | 18 |
19 namespace commands { | 19 namespace commands { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 void PrintToplevelHelp() { | 23 void PrintToplevelHelp() { |
24 OutputString("Commands (type \"gn help <command>\" for more details):\n"); | 24 OutputString("Commands (type \"gn help <command>\" for more details):\n"); |
25 | 25 for (const auto& cmd : commands::GetCommands()) |
26 const commands::CommandInfoMap& command_map = commands::GetCommands(); | 26 PrintShortHelp(cmd.second.help_short); |
27 for (commands::CommandInfoMap::const_iterator i = command_map.begin(); | |
28 i != command_map.end(); ++i) | |
29 PrintShortHelp(i->second.help_short); | |
30 | 27 |
31 OutputString( | 28 OutputString( |
32 "\n" | 29 "\n" |
33 "Common switches:\n"); | 30 "Common switches:\n"); |
34 PrintShortHelp( | 31 PrintShortHelp( |
35 "--args: Specifies build arguments overrides. " | 32 "--args: Specifies build arguments overrides. " |
36 "See \"gn help buildargs\"."); | 33 "See \"gn help buildargs\"."); |
37 PrintShortHelp( | 34 PrintShortHelp( |
38 "--[no]color: Forces colored output on or off (rather than autodetect)."); | 35 "--[no]color: Forces colored output on or off (rather than autodetect)."); |
39 PrintShortHelp( | 36 PrintShortHelp( |
40 "--dotfile: Specifies an alternate .gn file. See \"gn help dotfile\"."); | 37 "--dotfile: Specifies an alternate .gn file. See \"gn help dotfile\"."); |
41 PrintShortHelp( | 38 PrintShortHelp( |
42 "--no-exec: Skips exec_script calls (for performance testing)."); | 39 "--no-exec: Skips exec_script calls (for performance testing)."); |
43 PrintShortHelp( | 40 PrintShortHelp( |
44 "-q: Quiet mode, don't print anything on success."); | 41 "-q: Quiet mode, don't print anything on success."); |
45 PrintShortHelp( | 42 PrintShortHelp( |
46 "--root: Specifies source root (overrides .gn file)."); | 43 "--root: Specifies source root (overrides .gn file)."); |
47 PrintShortHelp( | 44 PrintShortHelp( |
48 "--time: Outputs a summary of how long everything took."); | 45 "--time: Outputs a summary of how long everything took."); |
49 PrintShortHelp( | 46 PrintShortHelp( |
50 "--tracelog: Writes a Chrome-compatible trace log to the given file."); | 47 "--tracelog: Writes a Chrome-compatible trace log to the given file."); |
51 PrintShortHelp( | 48 PrintShortHelp( |
52 "-v: Verbose mode, print lots of logging."); | 49 "-v: Verbose mode, print lots of logging."); |
53 PrintShortHelp( | 50 PrintShortHelp( |
54 "--version: Print the GN binary's version and exit."); | 51 "--version: Print the GN binary's version and exit."); |
55 | 52 |
56 // Target declarations. | 53 // Target declarations. |
57 OutputString("\nTarget declarations (type \"gn help <function>\" for more " | 54 OutputString("\nTarget declarations (type \"gn help <function>\" for more " |
58 "details):\n"); | 55 "details):\n"); |
59 const functions::FunctionInfoMap& function_map = functions::GetFunctions(); | 56 for (const auto& func : functions::GetFunctions()) { |
60 for (functions::FunctionInfoMap::const_iterator i = function_map.begin(); | 57 if (func.second.is_target) |
61 i != function_map.end(); ++i) { | 58 PrintShortHelp(func.second.help_short); |
62 if (i->second.is_target) | |
63 PrintShortHelp(i->second.help_short); | |
64 } | 59 } |
65 | 60 |
66 // Functions. | 61 // Functions. |
67 OutputString("\nBuildfile functions (type \"gn help <function>\" for more " | 62 OutputString("\nBuildfile functions (type \"gn help <function>\" for more " |
68 "details):\n"); | 63 "details):\n"); |
69 for (functions::FunctionInfoMap::const_iterator i = function_map.begin(); | 64 for (const auto& func : functions::GetFunctions()) { |
70 i != function_map.end(); ++i) { | 65 if (!func.second.is_target) |
71 if (!i->second.is_target) | 66 PrintShortHelp(func.second.help_short); |
72 PrintShortHelp(i->second.help_short); | |
73 } | 67 } |
74 | 68 |
75 // Built-in variables. | 69 // Built-in variables. |
76 OutputString("\nBuilt-in predefined variables (type \"gn help <variable>\" " | 70 OutputString("\nBuilt-in predefined variables (type \"gn help <variable>\" " |
77 "for more details):\n"); | 71 "for more details):\n"); |
78 const variables::VariableInfoMap& builtin_vars = | 72 for (const auto& builtin : variables::GetBuiltinVariables()) |
79 variables::GetBuiltinVariables(); | 73 PrintShortHelp(builtin.second.help_short); |
80 for (variables::VariableInfoMap::const_iterator i = builtin_vars.begin(); | |
81 i != builtin_vars.end(); ++i) | |
82 PrintShortHelp(i->second.help_short); | |
83 | 74 |
84 // Target variables. | 75 // Target variables. |
85 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " | 76 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " |
86 "for more details):\n"); | 77 "for more details):\n"); |
87 const variables::VariableInfoMap& target_vars = | 78 for (const auto& target : variables::GetTargetVariables()) |
88 variables::GetTargetVariables(); | 79 PrintShortHelp(target.second.help_short); |
89 for (variables::VariableInfoMap::const_iterator i = target_vars.begin(); | |
90 i != target_vars.end(); ++i) | |
91 PrintShortHelp(i->second.help_short); | |
92 | 80 |
93 OutputString("\nOther help topics:\n"); | 81 OutputString("\nOther help topics:\n"); |
94 PrintShortHelp("buildargs: How build arguments work."); | 82 PrintShortHelp("buildargs: How build arguments work."); |
95 PrintShortHelp("dotfile: Info about the toplevel .gn file."); | 83 PrintShortHelp("dotfile: Info about the toplevel .gn file."); |
96 PrintShortHelp("label_pattern: Matching more than one label."); | 84 PrintShortHelp("label_pattern: Matching more than one label."); |
97 PrintShortHelp( | 85 PrintShortHelp( |
98 "input_conversion: Processing input from exec_script and read_file."); | 86 "input_conversion: Processing input from exec_script and read_file."); |
99 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); | 87 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); |
100 } | 88 } |
101 | 89 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return 0; | 163 return 0; |
176 } | 164 } |
177 | 165 |
178 // No help on this. | 166 // No help on this. |
179 Err(Location(), "No help on \"" + args[0] + "\".").PrintToStdout(); | 167 Err(Location(), "No help on \"" + args[0] + "\".").PrintToStdout(); |
180 RunHelp(std::vector<std::string>()); | 168 RunHelp(std::vector<std::string>()); |
181 return 1; | 169 return 1; |
182 } | 170 } |
183 | 171 |
184 } // namespace commands | 172 } // namespace commands |
OLD | NEW |