| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "tools/gn/switches.h" | 5 #include "tools/gn/switches.h" |
| 6 | 6 |
| 7 namespace switches { | 7 namespace switches { |
| 8 | 8 |
| 9 const char kArgs[] = "args"; | 9 const char kArgs[] = "args"; |
| 10 const char kArgs_HelpShort[] = | 10 const char kArgs_HelpShort[] = |
| 11 "--args: Specifies build arguments overrides."; | 11 "--args: Specifies build arguments overrides."; |
| 12 const char kArgs_Help[] = | 12 const char kArgs_Help[] = |
| 13 "--args: Specifies build arguments overrides.\n" | 13 R"(--args: Specifies build arguments overrides. |
| 14 "\n" | 14 |
| 15 " See \"gn help buildargs\" for an overview of how build arguments work.\n" | 15 See "gn help buildargs" for an overview of how build arguments work. |
| 16 "\n" | 16 |
| 17 " Most operations take a build directory. The build arguments are taken\n" | 17 Most operations take a build directory. The build arguments are taken from |
| 18 " from the previous build done in that directory. If a command specifies\n" | 18 the previous build done in that directory. If a command specifies --args, it |
| 19 " --args, it will override the previous arguments stored in the build\n" | 19 will override the previous arguments stored in the build directory, and use |
| 20 " directory, and use the specified ones.\n" | 20 the specified ones. |
| 21 "\n" | 21 |
| 22 " The args specified will be saved to the build directory for subsequent\n" | 22 The args specified will be saved to the build directory for subsequent |
| 23 " commands. Specifying --args=\"\" will clear all build arguments.\n" | 23 commands. Specifying --args="" will clear all build arguments. |
| 24 "\n" | 24 |
| 25 "Formatting\n" | 25 Formatting |
| 26 "\n" | 26 |
| 27 " The value of the switch is interpreted in GN syntax. For typical usage\n" | 27 The value of the switch is interpreted in GN syntax. For typical usage of |
| 28 " of string arguments, you will need to be careful about escaping of\n" | 28 string arguments, you will need to be careful about escaping of quotes. |
| 29 " quotes.\n" | 29 |
| 30 "\n" | 30 Examples |
| 31 "Examples\n" | 31 |
| 32 "\n" | 32 gn gen out/Default --args="foo=\"bar\"" |
| 33 " gn gen out/Default --args=\"foo=\\\"bar\\\"\"\n" | 33 |
| 34 "\n" | 34 gn gen out/Default --args='foo="bar" enable=true blah=7' |
| 35 " gn gen out/Default --args='foo=\"bar\" enable=true blah=7'\n" | 35 |
| 36 "\n" | 36 gn check out/Default --args="" |
| 37 " gn check out/Default --args=\"\"\n" | 37 Clears existing build args from the directory. |
| 38 " Clears existing build args from the directory.\n" | 38 |
| 39 "\n" | 39 gn desc out/Default --args="some_list=[1, false, \"foo\"]")"; |
| 40 " gn desc out/Default --args=\"some_list=[1, false, \\\"foo\\\"]\"\n"; | |
| 41 | 40 |
| 42 #define COLOR_HELP_LONG \ | 41 #define COLOR_HELP_LONG \ |
| 43 "--[no]color: Forces colored output on or off.\n"\ | 42 "--[no]color: Forces colored output on or off.\n"\ |
| 44 "\n"\ | 43 "\n"\ |
| 45 " Normally GN will try to detect whether it is outputting to a terminal\n"\ | 44 " Normally GN will try to detect whether it is outputting to a terminal\n"\ |
| 46 " and will enable or disable color accordingly. Use of these switches\n"\ | 45 " and will enable or disable color accordingly. Use of these switches\n"\ |
| 47 " will override the default.\n"\ | 46 " will override the default.\n"\ |
| 48 "\n"\ | 47 "\n"\ |
| 49 "Examples\n"\ | 48 "Examples\n"\ |
| 50 "\n"\ | 49 "\n"\ |
| 51 " gn gen out/Default --color\n"\ | 50 " gn gen out/Default --color\n"\ |
| 52 "\n"\ | 51 "\n"\ |
| 53 " gn gen out/Default --nocolor\n" | 52 " gn gen out/Default --nocolor\n" |
| 54 const char kColor[] = "color"; | 53 const char kColor[] = "color"; |
| 55 const char kColor_HelpShort[] = | 54 const char kColor_HelpShort[] = |
| 56 "--color: Force colored output."; | 55 "--color: Force colored output."; |
| 57 const char kColor_Help[] = COLOR_HELP_LONG; | 56 const char kColor_Help[] = COLOR_HELP_LONG; |
| 58 | 57 |
| 59 const char kDotfile[] = "dotfile"; | 58 const char kDotfile[] = "dotfile"; |
| 60 const char kDotfile_HelpShort[] = | 59 const char kDotfile_HelpShort[] = |
| 61 "--dotfile: Override the name of the \".gn\" file."; | 60 "--dotfile: Override the name of the \".gn\" file."; |
| 62 const char kDotfile_Help[] = | 61 const char kDotfile_Help[] = |
| 63 "--dotfile: Override the name of the \".gn\" file.\n" | 62 R"(--dotfile: Override the name of the ".gn" file. |
| 64 "\n" | 63 |
| 65 " Normally GN loads the \".gn\"file from the source root for some basic\n" | 64 Normally GN loads the ".gn"file from the source root for some basic |
| 66 " configuration (see \"gn help dotfile\"). This flag allows you to\n" | 65 configuration (see "gn help dotfile"). This flag allows you to |
| 67 " use a different file.\n" | 66 use a different file. |
| 68 "\n" | 67 |
| 69 " Note that this interacts with \"--root\" in a possibly incorrect way.\n" | 68 Note that this interacts with "--root" in a possibly incorrect way. |
| 70 " It would be nice to test the edge cases and document or fix.\n"; | 69 It would be nice to test the edge cases and document or fix.)"; |
| 71 | 70 |
| 72 const char kFailOnUnusedArgs[] = "fail-on-unused-args"; | 71 const char kFailOnUnusedArgs[] = "fail-on-unused-args"; |
| 73 const char kFailOnUnusedArgs_HelpShort[] = | 72 const char kFailOnUnusedArgs_HelpShort[] = |
| 74 "--fail-on-unused-args: Treat unused build args as fatal errors."; | 73 "--fail-on-unused-args: Treat unused build args as fatal errors."; |
| 75 const char kFailOnUnusedArgs_Help[] = | 74 const char kFailOnUnusedArgs_Help[] = |
| 76 "--fail-on-unused-args: Treat unused build args as fatal errors.\n" | 75 R"(--fail-on-unused-args: Treat unused build args as fatal errors. |
| 77 "\n" | 76 |
| 78 " If you set a value in a build's \"gn args\" and never use it in the\n" | 77 If you set a value in a build's "gn args" and never use it in the build (in |
| 79 " build (in a declare_args() block), GN will normally print an error\n" | 78 a declare_args() block), GN will normally print an error but not fail the |
| 80 " but not fail the build.\n" | 79 build. |
| 81 "\n" | 80 |
| 82 " In many cases engineers would use build args to enable or disable\n" | 81 In many cases engineers would use build args to enable or disable features |
| 83 " features that would sometimes get removed. It would by annoying to\n" | 82 that would sometimes get removed. It would by annoying to block work for |
| 84 " block work for typically benign problems. In Chrome in particular,\n" | 83 typically benign problems. In Chrome in particular, flags might be configured |
| 85 " flags might be configured for build bots in a separate infrastructure\n" | 84 for build bots in a separate infrastructure repository, or a declare_args |
| 86 " repository, or a declare_args block might be changed in a third party\n" | 85 block might be changed in a third party repository. Treating these errors as |
| 87 " repository. Treating these errors as blocking forced complex multi-\n" | 86 blocking forced complex multi- way patches to land what would otherwise be |
| 88 " way patches to land what would otherwise be simple changes.\n" | 87 simple changes. |
| 89 "\n" | 88 |
| 90 " In some cases, such concerns are not as important, and a mismatch\n" | 89 In some cases, such concerns are not as important, and a mismatch in build |
| 91 " in build flags between the invoker of the build and the build files\n" | 90 flags between the invoker of the build and the build files represents a |
| 92 " represents a critical mismatch that should be immediately fixed. Such\n" | 91 critical mismatch that should be immediately fixed. Such users can set this |
| 93 " users can set this flag to force GN to fail in that case.\n"; | 92 flag to force GN to fail in that case.)"; |
| 94 | 93 |
| 95 const char kMarkdown[] = "markdown"; | 94 const char kMarkdown[] = "markdown"; |
| 96 const char kMarkdown_HelpShort[] = | 95 const char kMarkdown_HelpShort[] = |
| 97 "--markdown: Write help output in the Markdown format."; | 96 "--markdown: Write help output in the Markdown format."; |
| 98 const char kMarkdown_Help[] = | 97 const char kMarkdown_Help[] = |
| 99 "--markdown: Write help output in the Markdown format.\n"; | 98 "--markdown: Write help output in the Markdown format.\n"; |
| 100 | 99 |
| 101 const char kNoColor[] = "nocolor"; | 100 const char kNoColor[] = "nocolor"; |
| 102 const char kNoColor_HelpShort[] = | 101 const char kNoColor_HelpShort[] = |
| 103 "--nocolor: Force non-colored output."; | 102 "--nocolor: Force non-colored output."; |
| 104 const char kNoColor_Help[] = COLOR_HELP_LONG; | 103 const char kNoColor_Help[] = COLOR_HELP_LONG; |
| 105 | 104 |
| 106 const char kScriptExecutable[] = "script-executable"; | 105 const char kScriptExecutable[] = "script-executable"; |
| 107 const char kScriptExecutable_HelpShort[] = | 106 const char kScriptExecutable_HelpShort[] = |
| 108 "--script-executable: Set the executable used to execute scripts."; | 107 "--script-executable: Set the executable used to execute scripts."; |
| 109 const char kScriptExecutable_Help[] = | 108 const char kScriptExecutable_Help[] = |
| 110 "--script-executable: Set the executable used to execute scripts.\n" | 109 R"(--script-executable: Set the executable used to execute scripts. |
| 111 "\n" | 110 |
| 112 " By default GN searches the PATH for Python to execute scripts in\n" | 111 By default GN searches the PATH for Python to execute scripts in action |
| 113 " action targets and exec_script calls. This flag allows the\n" | 112 targets and exec_script calls. This flag allows the specification of a |
| 114 " specification of a specific Python executable or potentially\n" | 113 specific Python executable or potentially a different language |
| 115 " a different language interpreter.\n"; | 114 interpreter.)"; |
| 116 | 115 |
| 117 const char kQuiet[] = "q"; | 116 const char kQuiet[] = "q"; |
| 118 const char kQuiet_HelpShort[] = | 117 const char kQuiet_HelpShort[] = |
| 119 "-q: Quiet mode. Don't print output on success."; | 118 "-q: Quiet mode. Don't print output on success."; |
| 120 const char kQuiet_Help[] = | 119 const char kQuiet_Help[] = |
| 121 "-q: Quiet mode. Don't print output on success.\n" | 120 R"(-q: Quiet mode. Don't print output on success. |
| 122 "\n" | 121 |
| 123 " This is useful when running as a part of another script.\n"; | 122 This is useful when running as a part of another script.)"; |
| 124 | 123 |
| 125 const char kRoot[] = "root"; | 124 const char kRoot[] = "root"; |
| 126 const char kRoot_HelpShort[] = | 125 const char kRoot_HelpShort[] = |
| 127 "--root: Explicitly specify source root."; | 126 "--root: Explicitly specify source root."; |
| 128 const char kRoot_Help[] = | 127 const char kRoot_Help[] = |
| 129 "--root: Explicitly specify source root.\n" | 128 R"(--root: Explicitly specify source root. |
| 130 "\n" | 129 |
| 131 " Normally GN will look up in the directory tree from the current\n" | 130 Normally GN will look up in the directory tree from the current directory to |
| 132 " directory to find a \".gn\" file. The source root directory specifies\n" | 131 find a ".gn" file. The source root directory specifies the meaning of "//" |
| 133 " the meaning of \"//\" beginning with paths, and the BUILD.gn file\n" | 132 beginning with paths, and the BUILD.gn file in that directory will be the |
| 134 " in that directory will be the first thing loaded.\n" | 133 first thing loaded. |
| 135 "\n" | 134 |
| 136 " Specifying --root allows GN to do builds in a specific directory\n" | 135 Specifying --root allows GN to do builds in a specific directory regardless |
| 137 " regardless of the current directory.\n" | 136 of the current directory. |
| 138 "\n" | 137 |
| 139 "Examples\n" | 138 Examples |
| 140 "\n" | 139 |
| 141 " gn gen //out/Default --root=/home/baracko/src\n" | 140 gn gen //out/Default --root=/home/baracko/src |
| 142 "\n" | 141 |
| 143 " gn desc //out/Default --root=\"C:\\Users\\BObama\\My Documents\\foo\"\n"; | 142 gn desc //out/Default --root="C:\Users\BObama\My Documents\foo")"; |
| 144 | 143 |
| 145 const char kRuntimeDepsListFile[] = "runtime-deps-list-file"; | 144 const char kRuntimeDepsListFile[] = "runtime-deps-list-file"; |
| 146 const char kRuntimeDepsListFile_HelpShort[] = | 145 const char kRuntimeDepsListFile_HelpShort[] = |
| 147 "--runtime-deps-list-file: Save runtime dependencies for targets in file."; | 146 "--runtime-deps-list-file: Save runtime dependencies for targets in file."; |
| 148 const char kRuntimeDepsListFile_Help[] = | 147 const char kRuntimeDepsListFile_Help[] = |
| 149 "--runtime-deps-list-file: Save runtime dependencies for targets in file.\n" | 148 R"(--runtime-deps-list-file: Save runtime dependencies for targets in file. |
| 150 "\n" | 149 |
| 151 " --runtime-deps-list-file=<filename>\n" | 150 --runtime-deps-list-file=<filename> |
| 152 "\n" | 151 |
| 153 " Where <filename> is a text file consisting of the labels, one per\n" | 152 Where <filename> is a text file consisting of the labels, one per line, of |
| 154 " line, of the targets for which runtime dependencies are desired.\n" | 153 the targets for which runtime dependencies are desired. |
| 155 "\n" | 154 |
| 156 " See \"gn help runtime_deps\" for a description of how runtime\n" | 155 See "gn help runtime_deps" for a description of how runtime dependencies are |
| 157 " dependencies are computed.\n" | 156 computed. |
| 158 "\n" | 157 |
| 159 "Runtime deps output file\n" | 158 Runtime deps output file |
| 160 "\n" | 159 |
| 161 " For each target requested, GN will write a separate runtime dependency\n" | 160 For each target requested, GN will write a separate runtime dependency file. |
| 162 " file. The runtime dependency file will be in the output directory\n" | 161 The runtime dependency file will be in the output directory alongside the |
| 163 " alongside the output file of the target, with a \".runtime_deps\"\n" | 162 output file of the target, with a ".runtime_deps" extension. For example, if |
| 164 " extension. For example, if the target \"//foo:bar\" is listed in the\n" | 163 the target "//foo:bar" is listed in the input file, and that target produces |
| 165 " input file, and that target produces an output file \"bar.so\", GN\n" | 164 an output file "bar.so", GN will create a file "bar.so.runtime_deps" in the |
| 166 " will create a file \"bar.so.runtime_deps\" in the build directory.\n" | 165 build directory. |
| 167 "\n" | 166 |
| 168 " If a source set, action, copy, or group is listed, the runtime deps\n" | 167 If a source set, action, copy, or group is listed, the runtime deps file will |
| 169 " file will correspond to the .stamp file corresponding to that target.\n" | 168 correspond to the .stamp file corresponding to that target. This is probably |
| 170 " This is probably not useful; the use-case for this feature is\n" | 169 not useful; the use-case for this feature is generally executable targets. |
| 171 " generally executable targets.\n" | 170 |
| 172 "\n" | 171 The runtime dependency file will list one file per line, with no escaping. |
| 173 " The runtime dependency file will list one file per line, with no\n" | 172 The files will be relative to the root_build_dir. The first line of the file |
| 174 " escaping. The files will be relative to the root_build_dir. The first\n" | 173 will be the main output file of the target itself (in the above example, |
| 175 " line of the file will be the main output file of the target itself\n" | 174 "bar.so").)"; |
| 176 " (in the above example, \"bar.so\").\n"; | |
| 177 | 175 |
| 178 const char kThreads[] = "threads"; | 176 const char kThreads[] = "threads"; |
| 179 const char kThreads_HelpShort[] = | 177 const char kThreads_HelpShort[] = |
| 180 "--threads: Specify number of worker threads."; | 178 "--threads: Specify number of worker threads."; |
| 181 const char kThreads_Help[] = | 179 const char kThreads_Help[] = |
| 182 "--threads: Specify number of worker threads.\n" | 180 R"(--threads: Specify number of worker threads. |
| 183 "\n" | 181 |
| 184 " GN runs many threads to load and run build files. This can make\n" | 182 GN runs many threads to load and run build files. This can make debugging |
| 185 " debugging challenging. Or you may want to experiment with different\n" | 183 challenging. Or you may want to experiment with different values to see how |
| 186 " values to see how it affects performance.\n" | 184 it affects performance. |
| 187 "\n" | 185 |
| 188 " The parameter is the number of worker threads. This does not count the\n" | 186 The parameter is the number of worker threads. This does not count the main |
| 189 " main thread (so there are always at least two).\n" | 187 thread (so there are always at least two). |
| 190 "\n" | 188 |
| 191 "Examples\n" | 189 Examples |
| 192 "\n" | 190 |
| 193 " gen gen out/Default --threads=1\n"; | 191 gen gen out/Default --threads=1)"; |
| 194 | 192 |
| 195 const char kTime[] = "time"; | 193 const char kTime[] = "time"; |
| 196 const char kTime_HelpShort[] = | 194 const char kTime_HelpShort[] = |
| 197 "--time: Outputs a summary of how long everything took."; | 195 "--time: Outputs a summary of how long everything took."; |
| 198 const char kTime_Help[] = | 196 const char kTime_Help[] = |
| 199 "--time: Outputs a summary of how long everything took.\n" | 197 R"(--time: Outputs a summary of how long everything took. |
| 200 "\n" | 198 |
| 201 " Hopefully self-explanatory.\n" | 199 Hopefully self-explanatory. |
| 202 "\n" | 200 |
| 203 "Examples\n" | 201 Examples |
| 204 "\n" | 202 |
| 205 " gn gen out/Default --time\n"; | 203 gn gen out/Default --time)"; |
| 206 | 204 |
| 207 const char kTracelog[] = "tracelog"; | 205 const char kTracelog[] = "tracelog"; |
| 208 const char kTracelog_HelpShort[] = | 206 const char kTracelog_HelpShort[] = |
| 209 "--tracelog: Writes a Chrome-compatible trace log to the given file."; | 207 "--tracelog: Writes a Chrome-compatible trace log to the given file."; |
| 210 const char kTracelog_Help[] = | 208 const char kTracelog_Help[] = |
| 211 "--tracelog: Writes a Chrome-compatible trace log to the given file.\n" | 209 R"(--tracelog: Writes a Chrome-compatible trace log to the given file. |
| 212 "\n" | 210 |
| 213 " The trace log will show file loads, executions, scripts, and writes.\n" | 211 The trace log will show file loads, executions, scripts, and writes. This |
| 214 " This allows performance analysis of the generation step.\n" | 212 allows performance analysis of the generation step. |
| 215 "\n" | 213 |
| 216 " To view the trace, open Chrome and navigate to \"chrome://tracing/\",\n" | 214 To view the trace, open Chrome and navigate to "chrome://tracing/", then |
| 217 " then press \"Load\" and specify the file you passed to this parameter.\n" | 215 press "Load" and specify the file you passed to this parameter. |
| 218 "\n" | 216 |
| 219 "Examples\n" | 217 Examples |
| 220 "\n" | 218 |
| 221 " gn gen out/Default --tracelog=mytrace.trace\n"; | 219 gn gen out/Default --tracelog=mytrace.trace)"; |
| 222 | 220 |
| 223 const char kVerbose[] = "v"; | 221 const char kVerbose[] = "v"; |
| 224 const char kVerbose_HelpShort[] = | 222 const char kVerbose_HelpShort[] = |
| 225 "-v: Verbose logging."; | 223 "-v: Verbose logging."; |
| 226 const char kVerbose_Help[] = | 224 const char kVerbose_Help[] = |
| 227 "-v: Verbose logging.\n" | 225 R"(-v: Verbose logging. |
| 228 "\n" | 226 |
| 229 " This will spew logging events to the console for debugging issues.\n" | 227 This will spew logging events to the console for debugging issues. |
| 230 " Good luck!\n"; | 228 |
| 229 Good luck!)"; |
| 231 | 230 |
| 232 const char kVersion[] = "version"; | 231 const char kVersion[] = "version"; |
| 233 const char kVersion_HelpShort[] = | 232 const char kVersion_HelpShort[] = |
| 234 "--version: Prints the GN version number and exits."; | 233 "--version: Prints the GN version number and exits."; |
| 235 // It's impossible to see this since gn_main prints the version and exits | 234 // It's impossible to see this since gn_main prints the version and exits |
| 236 // immediately if this switch is used. | 235 // immediately if this switch is used. |
| 237 const char kVersion_Help[] = ""; | 236 const char kVersion_Help[] = ""; |
| 238 | 237 |
| 239 const char kAllToolchains[] = "all-toolchains"; | 238 const char kAllToolchains[] = "all-toolchains"; |
| 240 | 239 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 271 INSERT_VARIABLE(Tracelog) | 270 INSERT_VARIABLE(Tracelog) |
| 272 INSERT_VARIABLE(Verbose) | 271 INSERT_VARIABLE(Verbose) |
| 273 INSERT_VARIABLE(Version) | 272 INSERT_VARIABLE(Version) |
| 274 } | 273 } |
| 275 return info_map; | 274 return info_map; |
| 276 } | 275 } |
| 277 | 276 |
| 278 #undef INSERT_VARIABLE | 277 #undef INSERT_VARIABLE |
| 279 | 278 |
| 280 } // namespace switches | 279 } // namespace switches |
| OLD | NEW |