| 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 "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "tools/gn/args.h" | 9 #include "tools/gn/args.h" |
| 10 #include "tools/gn/commands.h" | 10 #include "tools/gn/commands.h" |
| 11 #include "tools/gn/err.h" | 11 #include "tools/gn/err.h" |
| 12 #include "tools/gn/functions.h" | 12 #include "tools/gn/functions.h" |
| 13 #include "tools/gn/input_conversion.h" | 13 #include "tools/gn/input_conversion.h" |
| 14 #include "tools/gn/label_pattern.h" | 14 #include "tools/gn/label_pattern.h" |
| 15 #include "tools/gn/parser.h" | 15 #include "tools/gn/parser.h" |
| 16 #include "tools/gn/runtime_deps.h" |
| 16 #include "tools/gn/setup.h" | 17 #include "tools/gn/setup.h" |
| 17 #include "tools/gn/standard_out.h" | 18 #include "tools/gn/standard_out.h" |
| 18 #include "tools/gn/substitution_writer.h" | 19 #include "tools/gn/substitution_writer.h" |
| 19 #include "tools/gn/switches.h" | 20 #include "tools/gn/switches.h" |
| 20 #include "tools/gn/variables.h" | 21 #include "tools/gn/variables.h" |
| 21 | 22 |
| 22 namespace commands { | 23 namespace commands { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " | 55 OutputString("\nVariables you set in targets (type \"gn help <variable>\" " |
| 55 "for more details):\n"); | 56 "for more details):\n"); |
| 56 for (const auto& target : variables::GetTargetVariables()) | 57 for (const auto& target : variables::GetTargetVariables()) |
| 57 PrintShortHelp(target.second.help_short); | 58 PrintShortHelp(target.second.help_short); |
| 58 | 59 |
| 59 OutputString("\nOther help topics:\n"); | 60 OutputString("\nOther help topics:\n"); |
| 60 PrintShortHelp("all: Print all the help at once"); | 61 PrintShortHelp("all: Print all the help at once"); |
| 61 PrintShortHelp("buildargs: How build arguments work."); | 62 PrintShortHelp("buildargs: How build arguments work."); |
| 62 PrintShortHelp("dotfile: Info about the toplevel .gn file."); | 63 PrintShortHelp("dotfile: Info about the toplevel .gn file."); |
| 63 PrintShortHelp("grammar: Formal grammar for GN build files."); | 64 PrintShortHelp("grammar: Formal grammar for GN build files."); |
| 64 PrintShortHelp("label_pattern: Matching more than one label."); | |
| 65 PrintShortHelp( | 65 PrintShortHelp( |
| 66 "input_conversion: Processing input from exec_script and read_file."); | 66 "input_conversion: Processing input from exec_script and read_file."); |
| 67 PrintShortHelp("label_pattern: Matching more than one label."); |
| 68 PrintShortHelp("runtime_deps: How runtime dependency computation works."); |
| 67 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); | 69 PrintShortHelp("source_expansion: Map sources to outputs for scripts."); |
| 68 PrintShortHelp("switches: Show available command-line switches."); | 70 PrintShortHelp("switches: Show available command-line switches."); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void PrintSwitchHelp() { | 73 void PrintSwitchHelp() { |
| 72 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 74 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 73 bool use_markdown = cmdline->HasSwitch(switches::kMarkdown); | 75 bool use_markdown = cmdline->HasSwitch(switches::kMarkdown); |
| 74 | 76 |
| 75 OutputString("Available global switches\n", DECORATION_YELLOW); | 77 OutputString("Available global switches\n", DECORATION_YELLOW); |
| 76 OutputString( | 78 OutputString( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 PrintLongHelp(v.second.help); | 118 PrintLongHelp(v.second.help); |
| 117 | 119 |
| 118 for (const auto& v: variables::GetTargetVariables()) | 120 for (const auto& v: variables::GetTargetVariables()) |
| 119 PrintLongHelp(v.second.help); | 121 PrintLongHelp(v.second.help); |
| 120 | 122 |
| 121 PrintLongHelp(kBuildArgs_Help); | 123 PrintLongHelp(kBuildArgs_Help); |
| 122 PrintLongHelp(kDotfile_Help); | 124 PrintLongHelp(kDotfile_Help); |
| 123 PrintLongHelp(kGrammar_Help); | 125 PrintLongHelp(kGrammar_Help); |
| 124 PrintLongHelp(kInputConversion_Help); | 126 PrintLongHelp(kInputConversion_Help); |
| 125 PrintLongHelp(kLabelPattern_Help); | 127 PrintLongHelp(kLabelPattern_Help); |
| 128 PrintLongHelp(kRuntimeDeps_Help); |
| 126 PrintLongHelp(kSourceExpansion_Help); | 129 PrintLongHelp(kSourceExpansion_Help); |
| 127 PrintSwitchHelp(); | 130 PrintSwitchHelp(); |
| 128 } | 131 } |
| 129 | 132 |
| 130 // Prints help on the given switch. There should be no leading hyphens. Returns | 133 // Prints help on the given switch. There should be no leading hyphens. Returns |
| 131 // true if the switch was found and help was printed. False means the switch is | 134 // true if the switch was found and help was printed. False means the switch is |
| 132 // unknown. | 135 // unknown. |
| 133 bool PrintHelpOnSwitch(const std::string& what) { | 136 bool PrintHelpOnSwitch(const std::string& what) { |
| 134 const switches::SwitchInfoMap& all = switches::GetSwitches(); | 137 const switches::SwitchInfoMap& all = switches::GetSwitches(); |
| 135 switches::SwitchInfoMap::const_iterator found = | 138 switches::SwitchInfoMap::const_iterator found = |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return 0; | 232 return 0; |
| 230 } | 233 } |
| 231 if (what == "input_conversion") { | 234 if (what == "input_conversion") { |
| 232 PrintLongHelp(kInputConversion_Help); | 235 PrintLongHelp(kInputConversion_Help); |
| 233 return 0; | 236 return 0; |
| 234 } | 237 } |
| 235 if (what == "label_pattern") { | 238 if (what == "label_pattern") { |
| 236 PrintLongHelp(kLabelPattern_Help); | 239 PrintLongHelp(kLabelPattern_Help); |
| 237 return 0; | 240 return 0; |
| 238 } | 241 } |
| 242 if (what == "runtime_deps") { |
| 243 PrintLongHelp(kRuntimeDeps_Help); |
| 244 return 0; |
| 245 } |
| 239 if (what == "source_expansion") { | 246 if (what == "source_expansion") { |
| 240 PrintLongHelp(kSourceExpansion_Help); | 247 PrintLongHelp(kSourceExpansion_Help); |
| 241 return 0; | 248 return 0; |
| 242 } | 249 } |
| 243 if (what == "switches") { | 250 if (what == "switches") { |
| 244 PrintSwitchHelp(); | 251 PrintSwitchHelp(); |
| 245 return 0; | 252 return 0; |
| 246 } | 253 } |
| 247 | 254 |
| 248 // No help on this. | 255 // No help on this. |
| 249 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); | 256 Err(Location(), "No help on \"" + what + "\".").PrintToStdout(); |
| 250 RunHelp(std::vector<std::string>()); | 257 RunHelp(std::vector<std::string>()); |
| 251 return 1; | 258 return 1; |
| 252 } | 259 } |
| 253 | 260 |
| 254 } // namespace commands | 261 } // namespace commands |
| OLD | NEW |