| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 gen_commands.push_back(build_dir); | 273 gen_commands.push_back(build_dir); |
| 274 return RunGen(gen_commands); | 274 return RunGen(gen_commands); |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace | 277 } // namespace |
| 278 | 278 |
| 279 extern const char kArgs[] = "args"; | 279 extern const char kArgs[] = "args"; |
| 280 extern const char kArgs_HelpShort[] = | 280 extern const char kArgs_HelpShort[] = |
| 281 "args: Display or configure arguments declared by the build."; | 281 "args: Display or configure arguments declared by the build."; |
| 282 extern const char kArgs_Help[] = | 282 extern const char kArgs_Help[] = |
| 283 "gn args <out_dir> [--list] [--short] [--args]\n" | 283 R"(gn args <out_dir> [--list] [--short] [--args] |
| 284 "\n" | 284 |
| 285 " See also \"gn help buildargs\" for a more high-level overview of how\n" | 285 See also "gn help buildargs" for a more high-level overview of how |
| 286 " build arguments work.\n" | 286 build arguments work. |
| 287 "\n" | 287 |
| 288 "Usage\n" | 288 Usage |
| 289 " gn args <out_dir>\n" | 289 gn args <out_dir> |
| 290 " Open the arguments for the given build directory in an editor\n" | 290 Open the arguments for the given build directory in an editor (as |
| 291 " (as specified by the EDITOR environment variable). If the given\n" | 291 specified by the EDITOR environment variable). If the given build |
| 292 " build directory doesn't exist, it will be created and an empty\n" | 292 directory doesn't exist, it will be created and an empty args file will |
| 293 " args file will be opened in the editor. You would type something\n" | 293 be opened in the editor. You would type something like this into that |
| 294 " like this into that file:\n" | 294 file: |
| 295 " enable_doom_melon=false\n" | 295 enable_doom_melon=false |
| 296 " os=\"android\"\n" | 296 os="android" |
| 297 "\n" | 297 |
| 298 " Note: you can edit the build args manually by editing the file\n" | 298 Note: you can edit the build args manually by editing the file "args.gn" |
| 299 " \"args.gn\" in the build directory and then running\n" | 299 in the build directory and then running "gn gen <out_dir>". |
| 300 " \"gn gen <out_dir>\".\n" | 300 |
| 301 "\n" | 301 gn args <out_dir> --list[=<exact_arg>] [--short] |
| 302 " gn args <out_dir> --list[=<exact_arg>] [--short]\n" | 302 Lists all build arguments available in the current configuration, or, if |
| 303 " Lists all build arguments available in the current configuration,\n" | 303 an exact_arg is specified for the list flag, just that one build |
| 304 " or, if an exact_arg is specified for the list flag, just that one\n" | 304 argument. |
| 305 " build argument.\n" | 305 |
| 306 "\n" | 306 The output will list the declaration location, default value, and comment |
| 307 " The output will list the declaration location, default value, and\n" | 307 preceeding the declaration. If --short is specified, only the names and |
| 308 " comment preceeding the declaration. If --short is specified,\n" | 308 values will be printed. |
| 309 " only the names and values will be printed.\n" | 309 |
| 310 "\n" | 310 If the out_dir is specified, the build configuration will be taken from |
| 311 " If the out_dir is specified, the build configuration will be\n" | 311 that build directory. The reason this is needed is that the definition of |
| 312 " taken from that build directory. The reason this is needed is that\n" | 312 some arguments is dependent on the build configuration, so setting some |
| 313 " the definition of some arguments is dependent on the build\n" | 313 values might add, remove, or change the default values for other |
| 314 " configuration, so setting some values might add, remove, or change\n" | 314 arguments. Specifying your exact configuration allows the proper |
| 315 " the default values for other arguments. Specifying your exact\n" | 315 arguments to be displayed. |
| 316 " configuration allows the proper arguments to be displayed.\n" | 316 |
| 317 "\n" | 317 Instead of specifying the out_dir, you can also use the command-line flag |
| 318 " Instead of specifying the out_dir, you can also use the\n" | 318 to specify the build configuration: |
| 319 " command-line flag to specify the build configuration:\n" | 319 --args=<exact list of args to use> |
| 320 " --args=<exact list of args to use>\n" | 320 |
| 321 "\n" | 321 Examples |
| 322 "Examples\n" | 322 |
| 323 " gn args out/Debug\n" | 323 gn args out/Debug |
| 324 " Opens an editor with the args for out/Debug.\n" | 324 Opens an editor with the args for out/Debug. |
| 325 "\n" | 325 |
| 326 " gn args out/Debug --list --short\n" | 326 gn args out/Debug --list --short |
| 327 " Prints all arguments with their default values for the out/Debug\n" | 327 Prints all arguments with their default values for the out/Debug |
| 328 " build.\n" | 328 build. |
| 329 "\n" | 329 |
| 330 " gn args out/Debug --list=target_cpu\n" | 330 gn args out/Debug --list=target_cpu |
| 331 " Prints information about the \"target_cpu\" argument for the " | 331 Prints information about the "target_cpu" argument for the " |
| 332 "out/Debug\n" | 332 "out/Debug |
| 333 " build.\n" | 333 build. |
| 334 "\n" | 334 |
| 335 " gn args --list --args=\"os=\\\"android\\\" enable_doom_melon=true\"\n" | 335 gn args --list --args="os=\"android\" enable_doom_melon=true" |
| 336 " Prints all arguments with the default values for a build with the\n" | 336 Prints all arguments with the default values for a build with the |
| 337 " given arguments set (which may affect the values of other\n" | 337 given arguments set (which may affect the values of other |
| 338 " arguments).\n"; | 338 arguments). |
| 339 )"; |
| 339 | 340 |
| 340 int RunArgs(const std::vector<std::string>& args) { | 341 int RunArgs(const std::vector<std::string>& args) { |
| 341 if (args.size() != 1) { | 342 if (args.size() != 1) { |
| 342 Err(Location(), "Exactly one build dir needed.", | 343 Err(Location(), "Exactly one build dir needed.", |
| 343 "Usage: \"gn args <out_dir>\"\n" | 344 "Usage: \"gn args <out_dir>\"\n" |
| 344 "Or see \"gn help args\" for more variants.").PrintToStdout(); | 345 "Or see \"gn help args\" for more variants.").PrintToStdout(); |
| 345 return 1; | 346 return 1; |
| 346 } | 347 } |
| 347 | 348 |
| 348 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) | 349 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) |
| 349 return ListArgs(args[0]); | 350 return ListArgs(args[0]); |
| 350 return EditArgsFile(args[0]); | 351 return EditArgsFile(args[0]); |
| 351 } | 352 } |
| 352 | 353 |
| 353 } // namespace commands | 354 } // namespace commands |
| OLD | NEW |