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 <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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 "\nDirect dependencies " | 146 "\nDirect dependencies " |
147 "(try also \"--all\", \"--tree\", or even \"--all --tree\"):\n"); | 147 "(try also \"--all\", \"--tree\", or even \"--all --tree\"):\n"); |
148 } | 148 } |
149 for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) | 149 for (const auto& pair : target->GetDeps(Target::DEPS_ALL)) |
150 deps.push_back(pair.ptr); | 150 deps.push_back(pair.ptr); |
151 std::sort(deps.begin(), deps.end()); | 151 std::sort(deps.begin(), deps.end()); |
152 FilterAndPrintTargets(display_header, &deps); | 152 FilterAndPrintTargets(display_header, &deps); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void PrintForwardDependentConfigsFrom(const Target* target, | |
157 bool display_header) { | |
158 if (target->forward_dependent_configs().empty()) | |
159 return; | |
160 | |
161 if (display_header) | |
162 OutputString("\nforward_dependent_configs_from:\n"); | |
163 | |
164 // Collect the sorted list of deps. | |
165 std::vector<Label> forward; | |
166 for (const auto& pair : target->forward_dependent_configs()) | |
167 forward.push_back(pair.label); | |
168 std::sort(forward.begin(), forward.end()); | |
169 | |
170 Label toolchain_label = target->label().GetToolchainLabel(); | |
171 for (const auto& fwd : forward) | |
172 OutputString(" " + fwd.GetUserVisibleName(toolchain_label) + "\n"); | |
173 } | |
174 | |
175 // libs and lib_dirs are special in that they're inherited. We don't currently | 156 // libs and lib_dirs are special in that they're inherited. We don't currently |
176 // implement a blame feature for this since the bottom-up inheritance makes | 157 // implement a blame feature for this since the bottom-up inheritance makes |
177 // this difficult. | 158 // this difficult. |
178 void PrintLibDirs(const Target* target, bool display_header) { | 159 void PrintLibDirs(const Target* target, bool display_header) { |
179 const OrderedSet<SourceDir>& lib_dirs = target->all_lib_dirs(); | 160 const OrderedSet<SourceDir>& lib_dirs = target->all_lib_dirs(); |
180 if (lib_dirs.empty()) | 161 if (lib_dirs.empty()) |
181 return; | 162 return; |
182 | 163 |
183 if (display_header) | 164 if (display_header) |
184 OutputString("\nlib_dirs\n"); | 165 OutputString("\nlib_dirs\n"); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 "\n" | 501 "\n" |
521 " deps\n" | 502 " deps\n" |
522 " Show immediate or recursive dependencies. See below for flags that\n" | 503 " Show immediate or recursive dependencies. See below for flags that\n" |
523 " control deps printing.\n" | 504 " control deps printing.\n" |
524 "\n" | 505 "\n" |
525 " public_configs\n" | 506 " public_configs\n" |
526 " all_dependent_configs\n" | 507 " all_dependent_configs\n" |
527 " Shows the labels of configs applied to targets that depend on this\n" | 508 " Shows the labels of configs applied to targets that depend on this\n" |
528 " one (either directly or all of them).\n" | 509 " one (either directly or all of them).\n" |
529 "\n" | 510 "\n" |
530 " forward_dependent_configs_from\n" | |
531 " Shows the labels of dependencies for which dependent configs will\n" | |
532 " be pushed to targets depending on the current one.\n" | |
533 "\n" | |
534 " script\n" | 511 " script\n" |
535 " args\n" | 512 " args\n" |
536 " depfile\n" | 513 " depfile\n" |
537 " Actions only. The script and related values.\n" | 514 " Actions only. The script and related values.\n" |
538 "\n" | 515 "\n" |
539 " outputs\n" | 516 " outputs\n" |
540 " Outputs for script and copy target types.\n" | 517 " Outputs for script and copy target types.\n" |
541 "\n" | 518 "\n" |
542 " defines [--blame]\n" | 519 " defines [--blame]\n" |
543 " include_dirs [--blame]\n" | 520 " include_dirs [--blame]\n" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 617 |
641 if (args.size() == 3) { | 618 if (args.size() == 3) { |
642 // User specified one thing to display. | 619 // User specified one thing to display. |
643 const std::string& what = args[2]; | 620 const std::string& what = args[2]; |
644 if (what == variables::kConfigs) { | 621 if (what == variables::kConfigs) { |
645 PrintConfigs(target, false); | 622 PrintConfigs(target, false); |
646 } else if (what == variables::kPublicConfigs) { | 623 } else if (what == variables::kPublicConfigs) { |
647 PrintPublicConfigs(target, false); | 624 PrintPublicConfigs(target, false); |
648 } else if (what == variables::kAllDependentConfigs) { | 625 } else if (what == variables::kAllDependentConfigs) { |
649 PrintAllDependentConfigs(target, false); | 626 PrintAllDependentConfigs(target, false); |
650 } else if (what == variables::kForwardDependentConfigsFrom) { | |
651 PrintForwardDependentConfigsFrom(target, false); | |
652 } else if (what == variables::kSources) { | 627 } else if (what == variables::kSources) { |
653 PrintSources(target, false); | 628 PrintSources(target, false); |
654 } else if (what == variables::kPublic) { | 629 } else if (what == variables::kPublic) { |
655 PrintPublic(target, false); | 630 PrintPublic(target, false); |
656 } else if (what == variables::kCheckIncludes) { | 631 } else if (what == variables::kCheckIncludes) { |
657 PrintCheckIncludes(target, false); | 632 PrintCheckIncludes(target, false); |
658 } else if (what == variables::kAllowCircularIncludesFrom) { | 633 } else if (what == variables::kAllowCircularIncludesFrom) { |
659 PrintAllowCircularIncludesFrom(target, false); | 634 PrintAllowCircularIncludesFrom(target, false); |
660 } else if (what == variables::kVisibility) { | 635 } else if (what == variables::kVisibility) { |
661 PrintVisibility(target, false); | 636 PrintVisibility(target, false); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 PrintAllowCircularIncludesFrom(target, true); | 704 PrintAllowCircularIncludesFrom(target, true); |
730 } | 705 } |
731 PrintVisibility(target, true); | 706 PrintVisibility(target, true); |
732 if (is_binary_output) { | 707 if (is_binary_output) { |
733 PrintTestonly(target, true); | 708 PrintTestonly(target, true); |
734 PrintConfigs(target, true); | 709 PrintConfigs(target, true); |
735 } | 710 } |
736 | 711 |
737 PrintPublicConfigs(target, true); | 712 PrintPublicConfigs(target, true); |
738 PrintAllDependentConfigs(target, true); | 713 PrintAllDependentConfigs(target, true); |
739 PrintForwardDependentConfigsFrom(target, true); | |
740 | 714 |
741 PrintInputs(target, true); | 715 PrintInputs(target, true); |
742 | 716 |
743 if (is_binary_output) { | 717 if (is_binary_output) { |
744 OUTPUT_CONFIG_VALUE(defines, std::string) | 718 OUTPUT_CONFIG_VALUE(defines, std::string) |
745 OUTPUT_CONFIG_VALUE(include_dirs, SourceDir) | 719 OUTPUT_CONFIG_VALUE(include_dirs, SourceDir) |
746 OUTPUT_CONFIG_VALUE(asmflags, std::string) | 720 OUTPUT_CONFIG_VALUE(asmflags, std::string) |
747 OUTPUT_CONFIG_VALUE(cflags, std::string) | 721 OUTPUT_CONFIG_VALUE(cflags, std::string) |
748 OUTPUT_CONFIG_VALUE(cflags_c, std::string) | 722 OUTPUT_CONFIG_VALUE(cflags_c, std::string) |
749 OUTPUT_CONFIG_VALUE(cflags_cc, std::string) | 723 OUTPUT_CONFIG_VALUE(cflags_cc, std::string) |
(...skipping 19 matching lines...) Expand all Loading... |
769 // so always display them, even for groups and such. | 743 // so always display them, even for groups and such. |
770 PrintLibs(target, true); | 744 PrintLibs(target, true); |
771 PrintLibDirs(target, true); | 745 PrintLibDirs(target, true); |
772 | 746 |
773 PrintDeps(target, true); | 747 PrintDeps(target, true); |
774 | 748 |
775 return 0; | 749 return 0; |
776 } | 750 } |
777 | 751 |
778 } // namespace commands | 752 } // namespace commands |
OLD | NEW |