| 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 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace | 286 } // namespace |
| 287 | 287 |
| 288 // desc ------------------------------------------------------------------------ | 288 // desc ------------------------------------------------------------------------ |
| 289 | 289 |
| 290 const char kDesc[] = "desc"; | 290 const char kDesc[] = "desc"; |
| 291 const char kDesc_HelpShort[] = | 291 const char kDesc_HelpShort[] = |
| 292 "desc: Show lots of insightful information about a target or config."; | 292 "desc: Show lots of insightful information about a target or config."; |
| 293 const char kDesc_Help[] = | 293 const char kDesc_Help[] = |
| 294 "gn desc <out_dir> <label or pattern> [<what to show>] [--blame] " | 294 R"(gn desc <out_dir> <label or pattern> [<what to show>] [--blame] " |
| 295 "[--format=json]\n" | 295 [--format=json] |
| 296 "\n" | 296 |
| 297 " Displays information about a given target or config. The build\n" | 297 Displays information about a given target or config. The build build |
| 298 " build parameters will be taken for the build in the given <out_dir>.\n" | 298 parameters will be taken for the build in the given <out_dir>. |
| 299 "\n" | 299 |
| 300 " The <label or pattern> can be a target label, a config label, or a\n" | 300 The <label or pattern> can be a target label, a config label, or a label |
| 301 " label pattern (see \"gn help label_pattern\"). A label pattern will\n" | 301 pattern (see "gn help label_pattern"). A label pattern will only match |
| 302 " only match targets.\n" | 302 targets. |
| 303 "\n" | 303 |
| 304 "Possibilities for <what to show>\n" | 304 Possibilities for <what to show> |
| 305 "\n" | 305 |
| 306 " (If unspecified an overall summary will be displayed.)\n" | 306 (If unspecified an overall summary will be displayed.) |
| 307 "\n" | 307 |
| 308 " all_dependent_configs\n" | 308 all_dependent_configs |
| 309 " allow_circular_includes_from\n" | 309 allow_circular_includes_from |
| 310 " arflags [--blame]\n" | 310 arflags [--blame] |
| 311 " args\n" | 311 args |
| 312 " cflags [--blame]\n" | 312 cflags [--blame] |
| 313 " cflags_cc [--blame]\n" | 313 cflags_cc [--blame] |
| 314 " cflags_cxx [--blame]\n" | 314 cflags_cxx [--blame] |
| 315 " check_includes\n" | 315 check_includes |
| 316 " configs [--tree] (see below)\n" | 316 configs [--tree] (see below) |
| 317 " defines [--blame]\n" | 317 defines [--blame] |
| 318 " depfile\n" | 318 depfile |
| 319 " deps [--all] [--tree] (see below)\n" | 319 deps [--all] [--tree] (see below) |
| 320 " include_dirs [--blame]\n" | 320 include_dirs [--blame] |
| 321 " inputs\n" | 321 inputs |
| 322 " ldflags [--blame]\n" | 322 ldflags [--blame] |
| 323 " lib_dirs\n" | 323 lib_dirs |
| 324 " libs\n" | 324 libs |
| 325 " outputs\n" | 325 outputs |
| 326 " public_configs\n" | 326 public_configs |
| 327 " public\n" | 327 public |
| 328 " script\n" | 328 script |
| 329 " sources\n" | 329 sources |
| 330 " testonly\n" | 330 testonly |
| 331 " visibility\n" | 331 visibility |
| 332 "\n" | 332 |
| 333 " runtime_deps\n" | 333 runtime_deps |
| 334 " Compute all runtime deps for the given target. This is a\n" | 334 Compute all runtime deps for the given target. This is a computed list |
| 335 " computed list and does not correspond to any GN variable, unlike\n" | 335 and does not correspond to any GN variable, unlike most other values |
| 336 " most other values here.\n" | 336 here. |
| 337 "\n" | 337 |
| 338 " The output is a list of file names relative to the build\n" | 338 The output is a list of file names relative to the build directory. See |
| 339 " directory. See \"gn help runtime_deps\" for how this is computed.\n" | 339 "gn help runtime_deps" for how this is computed. This also works with |
| 340 " This also works with \"--blame\" to see the source of the\n" | 340 "--blame" to see the source of the dependency. |
| 341 " dependency.\n" | 341 |
| 342 "\n" | 342 Shared flags |
| 343 "Shared flags\n" | 343 )" |
| 344 "\n" | 344 |
| 345 ALL_TOOLCHAINS_SWITCH_HELP | 345 ALL_TOOLCHAINS_SWITCH_HELP |
| 346 "\n" | 346 |
| 347 " --format=json\n" | 347 R"( |
| 348 " Format the output as JSON instead of text.\n" | 348 --format=json |
| 349 "\n" | 349 Format the output as JSON instead of text. |
| 350 "Target flags\n" | 350 |
| 351 "\n" | 351 Target flags |
| 352 " --blame\n" | 352 |
| 353 " Used with any value specified on a config, this will name\n" | 353 --blame |
| 354 " the config that cause that target to get the flag. This doesn't\n" | 354 Used with any value specified on a config, this will name the config that |
| 355 " currently work for libs and lib_dirs because those are inherited\n" | 355 cause that target to get the flag. This doesn't currently work for libs |
| 356 " and are more complicated to figure out the blame (patches\n" | 356 and lib_dirs because those are inherited and are more complicated to |
| 357 " welcome).\n" | 357 figure out the blame (patches welcome). |
| 358 "\n" | 358 |
| 359 "Configs\n" | 359 Configs |
| 360 "\n" | 360 |
| 361 " The \"configs\" section will list all configs that apply. For targets\n" | 361 The "configs" section will list all configs that apply. For targets this will |
| 362 " this will include configs specified in the \"configs\" variable of\n" | 362 include configs specified in the "configs" variable of the target, and also |
| 363 " the target, and also configs pushed onto this target via public\n" | 363 configs pushed onto this target via public or "all dependent" configs. |
| 364 " or \"all dependent\" configs.\n" | 364 |
| 365 "\n" | 365 Configs can have child configs. Specifying --tree will show the hierarchy. |
| 366 " Configs can have child configs. Specifying --tree will show the\n" | 366 |
| 367 " hierarchy.\n" | 367 Printing outputs |
| 368 "\n" | 368 |
| 369 "Printing outputs\n" | 369 The "outputs" section will list all outputs that apply, including the outputs |
| 370 "\n" | 370 computed from the tool definition (eg for "executable", "static_library", ... |
| 371 " The \"outputs\" section will list all outputs that apply, including\n" | 371 targets). |
| 372 " the outputs computed from the tool definition (eg for \"executable\",\n" | 372 |
| 373 " \"static_library\", ... targets).\n" | 373 Printing deps |
| 374 "\n" | 374 |
| 375 "Printing deps\n" | 375 Deps will include all public, private, and data deps (TODO this could be |
| 376 "\n" | 376 clarified and enhanced) sorted in order applying. The following may be used: |
| 377 " Deps will include all public, private, and data deps (TODO this could\n" | 377 |
| 378 " be clarified and enhanced) sorted in order applying. The following\n" | 378 --all |
| 379 " may be used:\n" | 379 Collects all recursive dependencies and prints a sorted flat list. Also |
| 380 "\n" | 380 usable with --tree (see below). |
| 381 " --all\n" | 381 )" |
| 382 " Collects all recursive dependencies and prints a sorted flat list.\n" | 382 |
| 383 " Also usable with --tree (see below).\n" | |
| 384 "\n" | |
| 385 TARGET_PRINTING_MODE_COMMAND_LINE_HELP | 383 TARGET_PRINTING_MODE_COMMAND_LINE_HELP |
| 386 "\n" | 384 "\n" |
| 387 TARGET_TESTONLY_FILTER_COMMAND_LINE_HELP | 385 TARGET_TESTONLY_FILTER_COMMAND_LINE_HELP |
| 388 "\n" | 386 |
| 389 " --tree\n" | 387 R"( |
| 390 " Print a dependency tree. By default, duplicates will be elided\n" | 388 --tree |
| 391 " with \"...\" but when --all and -tree are used together, no\n" | 389 Print a dependency tree. By default, duplicates will be elided with "..." |
| 392 " eliding will be performed.\n" | 390 but when --all and -tree are used together, no eliding will be performed. |
| 393 "\n" | 391 |
| 394 " The \"deps\", \"public_deps\", and \"data_deps\" will all be\n" | 392 The "deps", "public_deps", and "data_deps" will all be included in the |
| 395 " included in the tree.\n" | 393 tree. |
| 396 "\n" | 394 |
| 397 " Tree output can not be used with the filtering or output flags:\n" | 395 Tree output can not be used with the filtering or output flags: --as, |
| 398 " --as, --type, --testonly.\n" | 396 --type, --testonly. |
| 399 "\n" | 397 )" |
| 400 TARGET_TYPE_FILTER_COMMAND_LINE_HELP | 398 |
| 401 "\n" | 399 TARGET_TYPE_FILTER_COMMAND_LINE_HELP |
| 402 "Note\n" | 400 |
| 403 "\n" | 401 R"(Note |
| 404 " This command will show the full name of directories and source files,\n" | 402 |
| 405 " but when directories and source paths are written to the build file,\n" | 403 This command will show the full name of directories and source files, but |
| 406 " they will be adjusted to be relative to the build directory. So the\n" | 404 when directories and source paths are written to the build file, they will be |
| 407 " values for paths displayed by this command won't match (but should\n" | 405 adjusted to be relative to the build directory. So the values for paths |
| 408 " mean the same thing).\n" | 406 displayed by this command won't match (but should mean the same thing). |
| 409 "\n" | 407 |
| 410 "Examples\n" | 408 Examples |
| 411 "\n" | 409 |
| 412 " gn desc out/Debug //base:base\n" | 410 gn desc out/Debug //base:base |
| 413 " Summarizes the given target.\n" | 411 Summarizes the given target. |
| 414 "\n" | 412 |
| 415 " gn desc out/Foo :base_unittests deps --tree\n" | 413 gn desc out/Foo :base_unittests deps --tree |
| 416 " Shows a dependency tree of the \"base_unittests\" project in\n" | 414 Shows a dependency tree of the "base_unittests" project in |
| 417 " the current directory.\n" | 415 the current directory. |
| 418 "\n" | 416 |
| 419 " gn desc out/Debug //base defines --blame\n" | 417 gn desc out/Debug //base defines --blame |
| 420 " Shows defines set for the //base:base target, annotated by where\n" | 418 Shows defines set for the //base:base target, annotated by where |
| 421 " each one was set from.\n"; | 419 each one was set from.)"; |
| 422 | 420 |
| 423 int RunDesc(const std::vector<std::string>& args) { | 421 int RunDesc(const std::vector<std::string>& args) { |
| 424 if (args.size() != 2 && args.size() != 3) { | 422 if (args.size() != 2 && args.size() != 3) { |
| 425 Err(Location(), "You're holding it wrong.", | 423 Err(Location(), "You're holding it wrong.", |
| 426 "Usage: \"gn desc <out_dir> <target_name> [<what to display>]\"") | 424 "Usage: \"gn desc <out_dir> <target_name> [<what to display>]\"") |
| 427 .PrintToStdout(); | 425 .PrintToStdout(); |
| 428 return 1; | 426 return 1; |
| 429 } | 427 } |
| 430 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 428 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 431 | 429 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 500 |
| 503 if (!PrintConfig(config, what_to_print, !multiple_outputs)) | 501 if (!PrintConfig(config, what_to_print, !multiple_outputs)) |
| 504 return 1; | 502 return 1; |
| 505 } | 503 } |
| 506 } | 504 } |
| 507 | 505 |
| 508 return 0; | 506 return 0; |
| 509 } | 507 } |
| 510 | 508 |
| 511 } // namespace commands | 509 } // namespace commands |
| OLD | NEW |