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

Unified Diff: tools/gn/analyzer.cc

Issue 2350963006: Fix an issue in `gn analyze` when building all. (Closed)
Patch Set: initial patch for review Created 4 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 | « no previous file | tools/gn/analyzer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/analyzer.cc
diff --git a/tools/gn/analyzer.cc b/tools/gn/analyzer.cc
index f89c93dfef20e134ce5db6b6fd34e58806ef697a..d73a23b63890edc612c833a1f0a5dfc28c73874b 100644
--- a/tools/gn/analyzer.cc
+++ b/tools/gn/analyzer.cc
@@ -43,6 +43,7 @@ struct Inputs {
struct Outputs {
std::string status;
std::string error;
+ bool compile_includes_all;
LabelSet compile_labels;
LabelSet test_labels;
LabelSet invalid_labels;
@@ -203,8 +204,14 @@ std::string OutputsToJSON(const Outputs& outputs,
outputs.invalid_labels);
} else {
WriteString(*value, "status", outputs.status);
- WriteLabels(default_toolchain, *value, "compile_targets",
- outputs.compile_labels);
+ if (outputs.compile_includes_all) {
+ auto compile_targets = base::WrapUnique(new base::ListValue());
Nico 2016/09/20 19:20:44 For better or worse, I think we have decided to pr
Dirk Pranke 2016/09/20 19:24:17 I think we mostly use WrapUnique() elsewhere, stil
+ compile_targets->AppendString("all");
+ value->Set("compile_targets", std::move(compile_targets));
+ } else {
+ WriteLabels(default_toolchain, *value, "compile_targets",
+ outputs.compile_labels);
+ }
WriteLabels(default_toolchain, *value, "test_targets", outputs.test_labels);
}
@@ -232,8 +239,8 @@ Analyzer::Analyzer(const Builder& builder)
Analyzer::~Analyzer() {}
std::string Analyzer::Analyze(const std::string& input, Err* err) const {
- Inputs inputs;
- Outputs outputs;
+ Inputs inputs = Inputs();
+ Outputs outputs = Outputs();
Dirk Pranke 2016/09/20 18:54:23 Is this the best way to make sure everything is ze
Nico 2016/09/20 19:16:59 The best way is to give your thing a ctor, eg by d
Dirk Pranke 2016/09/20 19:24:17 Ah, I was wondering if you could do something like
Err local_err = JSONToInputs(default_toolchain_, input, &inputs);
if (local_err.has_error()) {
@@ -259,7 +266,14 @@ std::string Analyzer::Analyze(const std::string& input, Err* err) const {
// or toolchain defined in that file.
if (AnyBuildFilesWereModified(inputs.source_files)) {
outputs.status = "Found dependency (all)";
- outputs.compile_labels = inputs.compile_labels;
+ if (inputs.compile_included_all) {
+ outputs.compile_includes_all = true;
+ } else {
+ for (const auto label: inputs.compile_labels)
+ outputs.compile_labels.insert(label);
+ for (const auto label: inputs.test_labels)
+ outputs.compile_labels.insert(label);
Dirk Pranke 2016/09/20 18:54:23 This is the thing that is equivalent to a set_unio
Nico 2016/09/20 19:20:44 I haven't looked at the docs of std::set, but I'd'
Dirk Pranke 2016/09/20 19:24:17 Yeah, that might also work, though I'm not sure th
brettw 2016/09/20 19:28:53 Just do what Nico suggested. Since you already hav
Dirk Pranke 2016/09/20 19:36:20 ok, done.
+ }
outputs.test_labels = inputs.test_labels;
return OutputsToJSON(outputs, default_toolchain_, err);
}
« no previous file with comments | « no previous file | tools/gn/analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698