Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: tools/gn/command_desc.cc

Issue 500423003: Enhance GN diagnostic tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use patterns for gn check Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/command_check.cc ('k') | tools/gn/command_help.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <set> 6 #include <set>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "tools/gn/commands.h" 10 #include "tools/gn/commands.h"
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 428 }
429 429
430 } // namespace 430 } // namespace
431 431
432 // desc ------------------------------------------------------------------------ 432 // desc ------------------------------------------------------------------------
433 433
434 const char kDesc[] = "desc"; 434 const char kDesc[] = "desc";
435 const char kDesc_HelpShort[] = 435 const char kDesc_HelpShort[] =
436 "desc: Show lots of insightful information about a target."; 436 "desc: Show lots of insightful information about a target.";
437 const char kDesc_Help[] = 437 const char kDesc_Help[] =
438 "gn desc <target label> [<what to show>] [--blame] [--all | --tree]\n" 438 "gn desc <out_dir> <target label> [<what to show>]\n"
439 " Displays information about a given labeled target.\n" 439 " [--blame] [--all | --tree]\n"
440 "\n"
441 " Displays information about a given labeled target for the given build.\n"
442 " The build parameters will be taken for the build in the given\n"
443 " <out_dir>.\n"
440 "\n" 444 "\n"
441 "Possibilities for <what to show>:\n" 445 "Possibilities for <what to show>:\n"
442 " (If unspecified an overall summary will be displayed.)\n" 446 " (If unspecified an overall summary will be displayed.)\n"
443 "\n" 447 "\n"
444 " sources\n" 448 " sources\n"
445 " Source files.\n" 449 " Source files.\n"
446 "\n" 450 "\n"
447 " inputs\n" 451 " inputs\n"
448 " Additional input dependencies.\n" 452 " Additional input dependencies.\n"
449 "\n" 453 "\n"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 " complicated to figure out the blame (patches welcome).\n" 507 " complicated to figure out the blame (patches welcome).\n"
504 "\n" 508 "\n"
505 "Note:\n" 509 "Note:\n"
506 " This command will show the full name of directories and source files,\n" 510 " This command will show the full name of directories and source files,\n"
507 " but when directories and source paths are written to the build file,\n" 511 " but when directories and source paths are written to the build file,\n"
508 " they will be adjusted to be relative to the build directory. So the\n" 512 " they will be adjusted to be relative to the build directory. So the\n"
509 " values for paths displayed by this command won't match (but should\n" 513 " values for paths displayed by this command won't match (but should\n"
510 " mean the same thing).\n" 514 " mean the same thing).\n"
511 "\n" 515 "\n"
512 "Examples:\n" 516 "Examples:\n"
513 " gn desc //base:base\n" 517 " gn desc out/Debug //base:base\n"
514 " Summarizes the given target.\n" 518 " Summarizes the given target.\n"
515 "\n" 519 "\n"
516 " gn desc :base_unittests deps --tree\n" 520 " gn desc out/Foo :base_unittests deps --tree\n"
517 " Shows a dependency tree of the \"base_unittests\" project in\n" 521 " Shows a dependency tree of the \"base_unittests\" project in\n"
518 " the current directory.\n" 522 " the current directory.\n"
519 "\n" 523 "\n"
520 " gn desc //base defines --blame\n" 524 " gn desc out/Debug //base defines --blame\n"
521 " Shows defines set for the //base:base target, annotated by where\n" 525 " Shows defines set for the //base:base target, annotated by where\n"
522 " each one was set from.\n"; 526 " each one was set from.\n";
523 527
524 #define OUTPUT_CONFIG_VALUE(name, type) \ 528 #define OUTPUT_CONFIG_VALUE(name, type) \
525 OutputRecursiveTargetConfig<type>(target, #name, &ConfigValues::name); 529 OutputRecursiveTargetConfig<type>(target, #name, &ConfigValues::name);
526 530
527 int RunDesc(const std::vector<std::string>& args) { 531 int RunDesc(const std::vector<std::string>& args) {
528 if (args.size() != 1 && args.size() != 2) { 532 if (args.size() != 2 && args.size() != 3) {
529 Err(Location(), "You're holding it wrong.", 533 Err(Location(), "You're holding it wrong.",
530 "Usage: \"gn desc <target_name> <what to display>\"").PrintToStdout(); 534 "Usage: \"gn desc <out_dir> <target_name> [<what to display>]\"")
535 .PrintToStdout();
531 return 1; 536 return 1;
532 } 537 }
533 538
534 const Target* target = GetTargetForDesc(args); 539 // Deliberately leaked to avoid expensive process teardown.
540 Setup* setup = new Setup;
541 if (!setup->DoSetup(args[0]))
542 return 1;
543 if (!setup->Run())
544 return 1;
545
546 const Target* target = ResolveTargetFromCommandLineString(setup, args[1]);
535 if (!target) 547 if (!target)
536 return 1; 548 return 1;
537 549
538 #define CONFIG_VALUE_HANDLER(name, type) \ 550 #define CONFIG_VALUE_HANDLER(name, type) \
539 } else if (what == #name) { OUTPUT_CONFIG_VALUE(name, type) 551 } else if (what == #name) { OUTPUT_CONFIG_VALUE(name, type)
540 552
541 if (args.size() == 2) { 553 if (args.size() == 3) {
542 // User specified one thing to display. 554 // User specified one thing to display.
543 const std::string& what = args[1]; 555 const std::string& what = args[2];
544 if (what == "configs") { 556 if (what == "configs") {
545 PrintConfigs(target, false); 557 PrintConfigs(target, false);
546 } else if (what == "direct_dependent_configs") { 558 } else if (what == "direct_dependent_configs") {
547 PrintDirectDependentConfigs(target, false); 559 PrintDirectDependentConfigs(target, false);
548 } else if (what == "all_dependent_configs") { 560 } else if (what == "all_dependent_configs") {
549 PrintAllDependentConfigs(target, false); 561 PrintAllDependentConfigs(target, false);
550 } else if (what == "forward_dependent_configs_from") { 562 } else if (what == "forward_dependent_configs_from") {
551 PrintForwardDependentConfigsFrom(target, false); 563 PrintForwardDependentConfigsFrom(target, false);
552 } else if (what == "sources") { 564 } else if (what == "sources") {
553 PrintSources(target, false); 565 PrintSources(target, false);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // so always display them, even for groups and such. 666 // so always display them, even for groups and such.
655 PrintLibs(target, true); 667 PrintLibs(target, true);
656 PrintLibDirs(target, true); 668 PrintLibDirs(target, true);
657 669
658 PrintDeps(target, true); 670 PrintDeps(target, true);
659 671
660 return 0; 672 return 0;
661 } 673 }
662 674
663 } // namespace commands 675 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_check.cc ('k') | tools/gn/command_help.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698