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

Unified Diff: tools/gn/command_desc.cc

Issue 1342183003: Allow GN configs to have sub-configs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_desc.cc
diff --git a/tools/gn/command_desc.cc b/tools/gn/command_desc.cc
index 48fa31ab7ebf140b7351ed2283f326ba0f7813c3..59dc3e61ebbd96c43ae41dcf8d456b5723d0b378 100644
--- a/tools/gn/command_desc.cc
+++ b/tools/gn/command_desc.cc
@@ -25,8 +25,9 @@ namespace commands {
namespace {
-// The switch for displaying blame.
+// Desc-specific command line switches.
const char kBlame[] = "blame";
+const char kTree[] = "tree";
// Prints the given directory in a nice way for the user to view.
std::string FormatSourceDir(const SourceDir& dir) {
@@ -113,7 +114,7 @@ void PrintDeps(const Target* target, bool display_header) {
Label toolchain_label = target->label().GetToolchainLabel();
// Tree mode is separate.
- if (cmdline->HasSwitch("tree")) {
+ if (cmdline->HasSwitch(kTree)) {
if (display_header)
OutputString("\nDependency tree:\n");
@@ -249,39 +250,46 @@ void PrintTestonly(const Target* target, bool display_header) {
OutputString(" false\n");
}
-void PrintConfigsVector(const Target* target,
- const LabelConfigVector& configs,
- const std::string& heading,
- bool display_header) {
- if (configs.empty())
+// Recursively prints subconfigs of a config.
+void PrintSubConfigs(const Config* config, int indent_level) {
+ if (config->configs().empty())
return;
- // Don't sort since the order determines how things are processed.
- if (display_header)
- OutputString("\n" + heading + " (in order applying):\n");
-
- Label toolchain_label = target->label().GetToolchainLabel();
- for (const auto& config : configs) {
- OutputString(" " + config.label.GetUserVisibleName(toolchain_label) +
- "\n");
+ std::string indent(indent_level * 2, ' ');
+ Label toolchain_label = config->label().GetToolchainLabel();
+ for (const auto& pair : config->configs()) {
+ OutputString(
+ indent + pair.label.GetUserVisibleName(toolchain_label) + "\n");
+ PrintSubConfigs(pair.ptr, indent_level + 1);
}
}
+// This allows configs stored as either std::vector<LabelConfigPair> or
+// UniqueVector<LabelConfigPair> to be printed.
+template <class VectorType>
void PrintConfigsVector(const Target* target,
- const UniqueVector<LabelConfigPair>& configs,
+ const VectorType& configs,
const std::string& heading,
bool display_header) {
if (configs.empty())
return;
+ bool tree = base::CommandLine::ForCurrentProcess()->HasSwitch(kTree);
+
// Don't sort since the order determines how things are processed.
- if (display_header)
- OutputString("\n" + heading + " (in order applying):\n");
+ if (display_header) {
+ if (tree)
+ OutputString("\n" + heading + " tree (in order applying):\n");
+ else
+ OutputString("\n" + heading + " (in order applying, try also --tree):\n");
+ }
Label toolchain_label = target->label().GetToolchainLabel();
for (const auto& config : configs) {
OutputString(" " + config.label.GetUserVisibleName(toolchain_label) +
"\n");
+ if (tree)
+ PrintSubConfigs(config.ptr, 2); // 2 = start with double-indent.
}
}
« no previous file with comments | « tools/gn/builder.cc ('k') | tools/gn/config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698