diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-04 14:17:57 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-05 10:05:06 +0000 |
commit | 39d357e3248f80abea0159765ff39554affb40db (patch) | |
tree | aba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/tools/gn/commands.cc | |
parent | 87778abf5a1f89266f37d1321b92a21851d8244d (diff) | |
download | qtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz |
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2
Change-Id: I20d43c737f82764d857ada9a55586901b18b9243
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/tools/gn/commands.cc')
-rw-r--r-- | chromium/tools/gn/commands.cc | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/chromium/tools/gn/commands.cc b/chromium/tools/gn/commands.cc index 8682d920dfb..39dd079a062 100644 --- a/chromium/tools/gn/commands.cc +++ b/chromium/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" @@ -55,7 +56,7 @@ bool ResolveTargetsFromCommandLinePattern( std::vector<LabelPattern> pattern_vector; pattern_vector.push_back(pattern); - FilterTargetsByPatterns(setup->builder()->GetAllResolvedTargets(), + FilterTargetsByPatterns(setup->builder().GetAllResolvedTargets(), pattern_vector, matches); return true; } @@ -101,7 +102,7 @@ bool ResolveStringFromCommandLineInput( return true; } - const Item* item = setup->builder()->GetItem(label); + const Item* item = setup->builder().GetItem(label); if (item) { if (const Config* as_config = item->AsConfig()) config_matches->push_back(as_config); @@ -280,25 +281,23 @@ 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 (const auto& target : targets) + for (auto* target : targets) unique_labels.insert(target->label()); // Grab the label of the default toolchain from the first target. @@ -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); } } @@ -367,6 +360,7 @@ const CommandInfoMap& GetCommands() { k##cmd##_Help, \ &Run##cmd); + INSERT_COMMAND(Analyze) INSERT_COMMAND(Args) INSERT_COMMAND(Check) INSERT_COMMAND(Clean) @@ -398,7 +392,7 @@ const Target* ResolveTargetFromCommandLineString( return nullptr; } - const Item* item = setup->builder()->GetItem(label); + const Item* item = setup->builder().GetItem(label); if (!item) { Err(Location(), "Label not found.", label.GetUserVisibleName(false) + " not found.").PrintToStdout(); @@ -446,7 +440,7 @@ bool ResolveFromCommandLineInput( void FilterTargetsByPatterns(const std::vector<const Target*>& input, const std::vector<LabelPattern>& filter, std::vector<const Target*>* output) { - for (const auto& target : input) { + for (auto* target : input) { for (const auto& pattern : filter) { if (pattern.Matches(target->label())) { output->push_back(target); @@ -459,7 +453,7 @@ void FilterTargetsByPatterns(const std::vector<const Target*>& input, void FilterTargetsByPatterns(const std::vector<const Target*>& input, const std::vector<LabelPattern>& filter, UniqueVector<const Target*>* output) { - for (const auto& target : input) { + for (auto* target : input) { for (const auto& pattern : filter) { if (pattern.Matches(target->label())) { output->push_back(target); @@ -490,7 +484,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 +499,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 |