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

Unified Diff: tools/gn/commands.cc

Issue 2156173003: Re-land r406064 "[GN] Add JSON project writer". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clear dependency Created 4 years, 5 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/commands.h ('k') | tools/gn/desc_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/commands.cc
diff --git a/tools/gn/commands.cc b/tools/gn/commands.cc
index a6466797ac0ccfe738884f7742f201e42b80fcf5..492b74f12a0afaf37de68c57c2dcbca831b0fe30 100644
--- a/tools/gn/commands.cc
+++ b/tools/gn/commands.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/strings/string_split.h"
+#include "base/values.h"
#include "tools/gn/builder.h"
#include "tools/gn/filesystem_utils.h"
#include "tools/gn/item.h"
@@ -280,22 +281,20 @@ base::FilePath BuildFileForItem(const Item* item) {
return item->defined_from()->GetRange().begin().file()->physical_name();
}
-void PrintTargetsAsBuildfiles(bool indent,
- const std::vector<const Target*>& targets) {
+void PrintTargetsAsBuildfiles(const std::vector<const Target*>& targets,
+ base::ListValue* out) {
// Output the set of unique source files.
std::set<std::string> unique_files;
for (const Target* target : targets)
unique_files.insert(FilePathToUTF8(BuildFileForItem(target)));
for (const std::string& file : unique_files) {
- if (indent)
- OutputString(" ");
- OutputString(file + "\n");
+ out->AppendString(file);
}
}
-void PrintTargetsAsLabels(bool indent,
- const std::vector<const Target*>& targets) {
+void PrintTargetsAsLabels(const std::vector<const Target*>& targets,
+ base::ListValue* out) {
// Putting the labels into a set automatically sorts them for us.
std::set<Label> unique_labels;
for (auto* target : targets)
@@ -307,16 +306,13 @@ void PrintTargetsAsLabels(bool indent,
for (const Label& label : unique_labels) {
// Print toolchain only for ones not in the default toolchain.
- if (indent)
- OutputString(" ");
- OutputString(label.GetUserVisibleName(
- label.GetToolchainLabel() != default_tc_label));
- OutputString("\n");
+ out->AppendString(label.GetUserVisibleName(label.GetToolchainLabel() !=
+ default_tc_label));
}
}
-void PrintTargetsAsOutputs(bool indent,
- const std::vector<const Target*>& targets) {
+void PrintTargetsAsOutputs(const std::vector<const Target*>& targets,
+ base::ListValue* out) {
if (targets.empty())
return;
@@ -336,10 +332,7 @@ void PrintTargetsAsOutputs(bool indent,
std::string result = RebasePath(output_as_source.value(),
build_settings->build_dir(),
build_settings->root_path_utf8());
- if (indent)
- OutputString(" ");
- OutputString(result);
- OutputString("\n");
+ out->AppendString(result);
}
}
@@ -490,7 +483,8 @@ bool FilterPatternsFromString(const BuildSettings* build_settings,
return true;
}
-void FilterAndPrintTargets(bool indent, std::vector<const Target*>* targets) {
+void FilterAndPrintTargets(std::vector<const Target*>* targets,
+ base::ListValue* out) {
if (targets->empty())
return;
@@ -504,21 +498,40 @@ void FilterAndPrintTargets(bool indent, std::vector<const Target*>* targets) {
return;
switch (printing_mode) {
case TARGET_PRINT_BUILDFILE:
- PrintTargetsAsBuildfiles(indent, *targets);
+ PrintTargetsAsBuildfiles(*targets, out);
break;
case TARGET_PRINT_LABEL:
- PrintTargetsAsLabels(indent, *targets);
+ PrintTargetsAsLabels(*targets, out);
break;
case TARGET_PRINT_OUTPUT:
- PrintTargetsAsOutputs(indent, *targets);
+ PrintTargetsAsOutputs(*targets, out);
break;
}
}
+void FilterAndPrintTargets(bool indent, std::vector<const Target*>* targets) {
+ base::ListValue tmp;
+ FilterAndPrintTargets(targets, &tmp);
+ for (const auto& value : tmp) {
+ std::string string;
+ value->GetAsString(&string);
+ if (indent)
+ OutputString(" ");
+ OutputString(string);
+ OutputString("\n");
+ }
+}
+
void FilterAndPrintTargetSet(bool indent,
const std::set<const Target*>& targets) {
std::vector<const Target*> target_vector(targets.begin(), targets.end());
FilterAndPrintTargets(indent, &target_vector);
}
+void FilterAndPrintTargetSet(const std::set<const Target*>& targets,
+ base::ListValue* out) {
+ std::vector<const Target*> target_vector(targets.begin(), targets.end());
+ FilterAndPrintTargets(&target_vector, out);
+}
+
} // namespace commands
« no previous file with comments | « tools/gn/commands.h ('k') | tools/gn/desc_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698