| Index: tools/gn/desc_builder.cc
|
| diff --git a/tools/gn/desc_builder.cc b/tools/gn/desc_builder.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c25fa0213eccf3b17e5e62d82cacffd7a520167c
|
| --- /dev/null
|
| +++ b/tools/gn/desc_builder.cc
|
| @@ -0,0 +1,663 @@
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <set>
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| +#include "tools/gn/commands.h"
|
| +#include "tools/gn/config.h"
|
| +#include "tools/gn/config_values_extractors.h"
|
| +#include "tools/gn/deps_iterator.h"
|
| +#include "tools/gn/desc_builder.h"
|
| +#include "tools/gn/input_file.h"
|
| +#include "tools/gn/parse_tree.h"
|
| +#include "tools/gn/runtime_deps.h"
|
| +#include "tools/gn/substitution_writer.h"
|
| +#include "tools/gn/variables.h"
|
| +
|
| +namespace {
|
| +
|
| +std::string FormatSourceDir(const SourceDir& dir) {
|
| +#if defined(OS_WIN)
|
| + // On Windows we fix up system absolute paths to look like native ones.
|
| + // Internally, they'll look like "/C:\foo\bar/"
|
| + if (dir.is_system_absolute()) {
|
| + std::string buf = dir.value();
|
| + if (buf.size() > 3 && buf[2] == ':') {
|
| + buf.erase(buf.begin()); // Erase beginning slash.
|
| + return buf;
|
| + }
|
| + }
|
| +#endif
|
| + return dir.value();
|
| +}
|
| +
|
| +void RecursiveCollectChildDeps(const Target* target,
|
| + std::set<const Target*>* result);
|
| +
|
| +void RecursiveCollectDeps(const Target* target,
|
| + std::set<const Target*>* result) {
|
| + if (result->find(target) != result->end())
|
| + return; // Already did this target.
|
| + result->insert(target);
|
| +
|
| + RecursiveCollectChildDeps(target, result);
|
| +}
|
| +
|
| +void RecursiveCollectChildDeps(const Target* target,
|
| + std::set<const Target*>* result) {
|
| + for (const auto& pair : target->GetDeps(Target::DEPS_ALL))
|
| + RecursiveCollectDeps(pair.ptr, result);
|
| +}
|
| +
|
| +// Common functionality for target and config description builder
|
| +class BaseDescBuilder {
|
| + public:
|
| + typedef std::unique_ptr<base::Value> ValuePtr;
|
| +
|
| + BaseDescBuilder(const std::set<std::string>& what,
|
| + bool all,
|
| + bool tree,
|
| + bool blame)
|
| + : what_(what), all_(all), tree_(tree), blame_(blame) {}
|
| +
|
| + protected:
|
| + virtual Label GetToolchainLabel() const = 0;
|
| +
|
| + bool what(const std::string& w) const {
|
| + return what_.empty() || what_.find(w) != what_.end();
|
| + }
|
| +
|
| + template <typename T>
|
| + ValuePtr RenderValue(const std::vector<T>& vector) {
|
| + auto res = new base::ListValue();
|
| + for (const auto& v : vector) {
|
| + res->Append(RenderValue(v));
|
| + }
|
| + return base::WrapUnique(res);
|
| + }
|
| +
|
| + ValuePtr RenderValue(const std::string& s, bool optional = false) {
|
| + return (s.empty() && optional) ? base::Value::CreateNullValue()
|
| + : ValuePtr(new base::StringValue(s));
|
| + }
|
| +
|
| + ValuePtr RenderValue(const SourceDir& d) {
|
| + return d.is_null() ? base::Value::CreateNullValue()
|
| + : ValuePtr(new base::StringValue(FormatSourceDir(d)));
|
| + }
|
| +
|
| + ValuePtr RenderValue(const SourceFile& f) {
|
| + return f.is_null() ? base::Value::CreateNullValue()
|
| + : ValuePtr(new base::StringValue(f.value()));
|
| + }
|
| +
|
| + ValuePtr RenderValue(const LibFile& lib) {
|
| + if (lib.is_source_file())
|
| + return RenderValue(lib.source_file());
|
| + else
|
| + return RenderValue(lib.value());
|
| + }
|
| +
|
| + template <class VectorType>
|
| + void FillInConfigVector(base::ListValue* out,
|
| + const VectorType& configs,
|
| + int indent = 0) {
|
| + for (const auto& config : configs) {
|
| + std::string name(indent * 2, ' ');
|
| + name.append(config.label.GetUserVisibleName(GetToolchainLabel()));
|
| + out->AppendString(name);
|
| + if (tree_) {
|
| + FillInConfigVector(out, config.ptr->configs(), indent + 1);
|
| + }
|
| + }
|
| + }
|
| +
|
| + void FillInPrecompiledHeader(base::DictionaryValue* out,
|
| + const ConfigValues& values) {
|
| + if (what(variables::kPrecompiledHeader) &&
|
| + !values.precompiled_header().empty()) {
|
| + out->Set(variables::kPrecompiledHeader,
|
| + RenderValue(values.precompiled_header(), true));
|
| + }
|
| + if (what(variables::kPrecompiledSource) &&
|
| + !values.precompiled_source().is_null()) {
|
| + out->Set(variables::kPrecompiledSource,
|
| + RenderValue(values.precompiled_source()));
|
| + }
|
| + }
|
| +
|
| + std::set<std::string> what_;
|
| + bool all_;
|
| + bool tree_;
|
| + bool blame_;
|
| +};
|
| +
|
| +class ConfigDescBuilder : public BaseDescBuilder {
|
| + public:
|
| + ConfigDescBuilder(const Config* config, const std::set<std::string>& what)
|
| + : config_(config), BaseDescBuilder(what, false, false, false) {}
|
| +
|
| + std::unique_ptr<base::DictionaryValue> BuildDescription() {
|
| + auto res = new base::DictionaryValue();
|
| + const ConfigValues& values = config_->resolved_values();
|
| +
|
| + if (what_.empty()) {
|
| + res->SetString(
|
| + "toolchain",
|
| + config_->label().GetToolchainLabel().GetUserVisibleName(false));
|
| + }
|
| +
|
| + if (what(variables::kConfigs) && !config_->configs().empty()) {
|
| + auto configs = new base::ListValue();
|
| + FillInConfigVector(configs, config_->configs().vector());
|
| + res->Set(variables::kConfigs, configs);
|
| + }
|
| +
|
| +#define CONFIG_VALUE_ARRAY_HANDLER(name, type) \
|
| + if (what(#name)) { \
|
| + ValuePtr ptr = \
|
| + render_config_value_array<type>(values, &ConfigValues::name); \
|
| + if (ptr) { \
|
| + res->Set(#name, std::move(ptr)); \
|
| + } \
|
| + }
|
| + CONFIG_VALUE_ARRAY_HANDLER(arflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(asmflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_c, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_cc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_objc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_objcc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(defines, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(include_dirs, SourceDir)
|
| + CONFIG_VALUE_ARRAY_HANDLER(ldflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(lib_dirs, SourceDir)
|
| + CONFIG_VALUE_ARRAY_HANDLER(libs, LibFile)
|
| +
|
| +#undef CONFIG_VALUE_ARRAY_HANDLER
|
| +
|
| + FillInPrecompiledHeader(res, values);
|
| +
|
| + return base::WrapUnique(res);
|
| + }
|
| +
|
| + protected:
|
| + Label GetToolchainLabel() const override {
|
| + return config_->label().GetToolchainLabel();
|
| + }
|
| +
|
| + private:
|
| + template <typename T>
|
| + ValuePtr render_config_value_array(
|
| + const ConfigValues& values,
|
| + const std::vector<T>& (ConfigValues::*getter)() const) {
|
| + auto res = base::WrapUnique(new base::ListValue());
|
| +
|
| + for (const T& cur : (values.*getter)()) {
|
| + res->Append(RenderValue(cur));
|
| + }
|
| +
|
| + return res->empty() ? nullptr : std::move(res);
|
| + }
|
| +
|
| + const Config* config_;
|
| +};
|
| +
|
| +class TargetDescBuilder : public BaseDescBuilder {
|
| + public:
|
| + TargetDescBuilder(const Target* target,
|
| + const std::set<std::string>& what,
|
| + bool all,
|
| + bool tree,
|
| + bool blame)
|
| + : target_(target), BaseDescBuilder(what, all, tree, blame) {}
|
| +
|
| + std::unique_ptr<base::DictionaryValue> BuildDescription() {
|
| + auto res = new base::DictionaryValue();
|
| + bool is_binary_output = target_->IsBinary();
|
| +
|
| + if (what_.empty()) {
|
| + res->SetString(
|
| + "type", DescBuilder::GetStringForOutputType(target_->output_type()));
|
| + res->SetString(
|
| + "toolchain",
|
| + target_->label().GetToolchainLabel().GetUserVisibleName(false));
|
| + }
|
| +
|
| + // General target meta variables.
|
| + if (what(variables::kVisibility)) {
|
| + res->Set(variables::kVisibility, target_->visibility().AsValue());
|
| + }
|
| + if (what(variables::kTestonly)) {
|
| + res->SetBoolean(variables::kTestonly, target_->testonly());
|
| + }
|
| +
|
| + if (is_binary_output) {
|
| + if (what(variables::kCheckIncludes)) {
|
| + res->SetBoolean(variables::kCheckIncludes, target_->check_includes());
|
| + }
|
| + if (what(variables::kAllowCircularIncludesFrom)) {
|
| + auto labels = new base::ListValue();
|
| + for (const auto& cur : target_->allow_circular_includes_from()) {
|
| + labels->AppendString(cur.GetUserVisibleName(GetToolchainLabel()));
|
| + }
|
| + res->Set(variables::kAllowCircularIncludesFrom, labels);
|
| + }
|
| + }
|
| +
|
| + if (what(variables::kSources) && !target_->sources().empty()) {
|
| + res->Set(variables::kSources, RenderValue(target_->sources()));
|
| + }
|
| +
|
| + if (what(variables::kPublic)) {
|
| + if (target_->all_headers_public())
|
| + res->SetString(variables::kPublic, "*");
|
| + else
|
| + res->Set(variables::kPublic, RenderValue(target_->public_headers()));
|
| + }
|
| +
|
| + if (what(variables::kInputs) && !target_->inputs().empty()) {
|
| + res->Set(variables::kInputs, RenderValue(target_->inputs()));
|
| + }
|
| +
|
| + if (is_binary_output && what(variables::kConfigs) &&
|
| + !target_->configs().empty()) {
|
| + auto configs = new base::ListValue();
|
| + FillInConfigVector(configs, target_->configs().vector());
|
| + res->Set(variables::kConfigs, configs);
|
| + }
|
| +
|
| + if (what(variables::kPublicConfigs) && !target_->public_configs().empty()) {
|
| + auto configs = new base::ListValue();
|
| + FillInConfigVector(configs, target_->public_configs());
|
| + res->Set(variables::kPublicConfigs, configs);
|
| + }
|
| +
|
| + if (what(variables::kAllDependentConfigs) &&
|
| + !target_->all_dependent_configs().empty()) {
|
| + auto configs = new base::ListValue();
|
| + FillInConfigVector(configs, target_->all_dependent_configs());
|
| + res->Set(variables::kAllDependentConfigs, configs);
|
| + }
|
| +
|
| + // Action
|
| + if (target_->output_type() == Target::ACTION ||
|
| + target_->output_type() == Target::ACTION_FOREACH) {
|
| + if (what(variables::kScript)) {
|
| + res->SetString(variables::kScript,
|
| + target_->action_values().script().value());
|
| + }
|
| + if (what(variables::kArgs)) {
|
| + auto args = new base::ListValue();
|
| + for (const auto& elem : target_->action_values().args().list()) {
|
| + args->AppendString(elem.AsString());
|
| + }
|
| + res->Set(variables::kArgs, args);
|
| + }
|
| + if (what(variables::kDepfile) &&
|
| + !target_->action_values().depfile().empty()) {
|
| + res->SetString(variables::kDepfile,
|
| + target_->action_values().depfile().AsString());
|
| + }
|
| + }
|
| +
|
| + if (target_->output_type() == Target::ACTION ||
|
| + target_->output_type() == Target::ACTION_FOREACH ||
|
| + target_->output_type() == Target::COPY_FILES ||
|
| + target_->output_type() == Target::CREATE_BUNDLE) {
|
| + if (what(variables::kOutputs)) {
|
| + FillInOutputs(res, target_);
|
| + }
|
| + }
|
| +
|
| + if (target_->output_type() == Target::CREATE_BUNDLE &&
|
| + what("bundle_data")) {
|
| + FillInBundle(res, target_);
|
| + }
|
| +
|
| + if (is_binary_output) {
|
| +#define CONFIG_VALUE_ARRAY_HANDLER(name, type) \
|
| + if (what(#name)) { \
|
| + ValuePtr ptr = RenderConfigValues<type>(&ConfigValues::name); \
|
| + if (ptr) { \
|
| + res->Set(#name, std::move(ptr)); \
|
| + } \
|
| + }
|
| + CONFIG_VALUE_ARRAY_HANDLER(arflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(asmflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_c, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_cc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_objc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(cflags_objcc, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(defines, std::string)
|
| + CONFIG_VALUE_ARRAY_HANDLER(include_dirs, SourceDir)
|
| + CONFIG_VALUE_ARRAY_HANDLER(ldflags, std::string)
|
| +#undef CONFIG_VALUE_ARRAY_HANDLER
|
| +
|
| + // Libs and lib_dirs are handled specially below.
|
| +
|
| + FillInPrecompiledHeader(res, target_->config_values());
|
| + }
|
| +
|
| + if (what(variables::kDeps)) {
|
| + res->Set(variables::kDeps, RenderDeps());
|
| + }
|
| +
|
| + // Runtime deps are special, print only when explicitly asked for and not in
|
| + // overview mode.
|
| + if (what_.find("runtime_deps") != what_.end()) {
|
| + res->Set("runtime_deps", RenderRuntimeDeps());
|
| + }
|
| +
|
| + // libs and lib_dirs are special in that they're inherited. We don't
|
| + // currently
|
| + // implement a blame feature for this since the bottom-up inheritance makes
|
| + // this difficult.
|
| +
|
| + // Libs can be part of any target and get recursively pushed up the chain,
|
| + // so display them regardless of target type.
|
| + if (what(variables::kLibs)) {
|
| + const OrderedSet<LibFile>& all_libs = target_->all_libs();
|
| + if (!all_libs.empty()) {
|
| + auto libs = new base::ListValue();
|
| + for (size_t i = 0; i < all_libs.size(); i++)
|
| + libs->AppendString(all_libs[i].value());
|
| + res->Set(variables::kLibs, libs);
|
| + }
|
| + }
|
| +
|
| + if (what(variables::kLibDirs)) {
|
| + const OrderedSet<SourceDir>& all_lib_dirs = target_->all_lib_dirs();
|
| + if (!all_lib_dirs.empty()) {
|
| + auto lib_dirs = new base::ListValue();
|
| + for (size_t i = 0; i < all_lib_dirs.size(); i++)
|
| + lib_dirs->AppendString(FormatSourceDir(all_lib_dirs[i]));
|
| + res->Set(variables::kLibDirs, lib_dirs);
|
| + }
|
| + }
|
| +
|
| + return base::WrapUnique(res);
|
| + }
|
| +
|
| + private:
|
| + // Prints dependencies of the given target (not the target itself). If the
|
| + // set is non-null, new targets encountered will be added to the set, and if
|
| + // a dependency is in the set already, it will not be recused into. When the
|
| + // set is null, all dependencies will be printed.
|
| + void RecursivePrintDeps(base::ListValue* out,
|
| + const Target* target,
|
| + std::set<const Target*>* seen_targets,
|
| + int indent_level) {
|
| + // Combine all deps into one sorted list.
|
| + std::vector<LabelTargetPair> sorted_deps;
|
| + for (const auto& pair : target->GetDeps(Target::DEPS_ALL))
|
| + sorted_deps.push_back(pair);
|
| + std::sort(sorted_deps.begin(), sorted_deps.end(),
|
| + LabelPtrLabelLess<Target>());
|
| +
|
| + std::string indent(indent_level * 2, ' ');
|
| +
|
| + for (const auto& pair : sorted_deps) {
|
| + const Target* cur_dep = pair.ptr;
|
| + std::string str =
|
| + indent + cur_dep->label().GetUserVisibleName(GetToolchainLabel());
|
| +
|
| + bool print_children = true;
|
| + if (seen_targets) {
|
| + if (seen_targets->find(cur_dep) == seen_targets->end()) {
|
| + // New target, mark it visited.
|
| + seen_targets->insert(cur_dep);
|
| + } else {
|
| + // Already seen.
|
| + print_children = false;
|
| + // Only print "..." if something is actually elided, which means that
|
| + // the current target has children.
|
| + if (!cur_dep->public_deps().empty() ||
|
| + !cur_dep->private_deps().empty() || !cur_dep->data_deps().empty())
|
| + str += "...";
|
| + }
|
| + }
|
| +
|
| + out->AppendString(str);
|
| +
|
| + if (print_children) {
|
| + RecursivePrintDeps(out, cur_dep, seen_targets, indent_level + 1);
|
| + }
|
| + }
|
| + }
|
| +
|
| + ValuePtr RenderDeps() {
|
| + auto res = new base::ListValue();
|
| +
|
| + // Tree mode is separate.
|
| + if (tree_) {
|
| + if (all_) {
|
| + // Show all tree deps with no eliding.
|
| + RecursivePrintDeps(res, target_, nullptr, 0);
|
| + } else {
|
| + // Don't recurse into duplicates.
|
| + std::set<const Target*> seen_targets;
|
| + RecursivePrintDeps(res, target_, &seen_targets, 0);
|
| + }
|
| + } else { // not tree
|
| +
|
| + // Collect the deps to display.
|
| + if (all_) {
|
| + // Show all dependencies.
|
| + std::set<const Target*> all_deps;
|
| + RecursiveCollectChildDeps(target_, &all_deps);
|
| + commands::FilterAndPrintTargetSet(all_deps, res);
|
| + } else {
|
| + // Show direct dependencies only.
|
| + std::vector<const Target*> deps;
|
| + for (const auto& pair : target_->GetDeps(Target::DEPS_ALL))
|
| + deps.push_back(pair.ptr);
|
| + std::sort(deps.begin(), deps.end());
|
| + commands::FilterAndPrintTargets(&deps, res);
|
| + }
|
| + }
|
| +
|
| + return base::WrapUnique(res);
|
| + }
|
| +
|
| + ValuePtr RenderRuntimeDeps() {
|
| + auto res = new base::ListValue();
|
| +
|
| + const Target* previous_from = NULL;
|
| + for (const auto& pair : ComputeRuntimeDeps(target_)) {
|
| + std::string str;
|
| + if (blame_) {
|
| + // Generally a target's runtime deps will be listed sequentially, so
|
| + // group them and don't duplicate the "from" label for two in a row.
|
| + if (previous_from == pair.second) {
|
| + str = " ";
|
| + } else {
|
| + previous_from = pair.second;
|
| + res->AppendString(
|
| + str + "From " +
|
| + pair.second->label().GetUserVisibleName(GetToolchainLabel()));
|
| + str = " ";
|
| + }
|
| + }
|
| +
|
| + res->AppendString(str + pair.first.value());
|
| + }
|
| +
|
| + return base::WrapUnique(res);
|
| + }
|
| +
|
| + void FillInBundle(base::DictionaryValue* res, const Target* target) {
|
| + auto data = new base::DictionaryValue();
|
| + const BundleData& bundle_data = target->bundle_data();
|
| + const Settings* settings = target->settings();
|
| + BundleData::SourceFiles sources;
|
| + bundle_data.GetSourceFiles(&sources);
|
| + data->Set("source_files", RenderValue(sources));
|
| + data->SetString("root_dir_output",
|
| + bundle_data.GetBundleRootDirOutput(settings).value());
|
| + data->Set("root_dir", RenderValue(bundle_data.root_dir()));
|
| + data->Set("resources_dir", RenderValue(bundle_data.resources_dir()));
|
| + data->Set("executable_dir", RenderValue(bundle_data.executable_dir()));
|
| + data->Set("plugins_dir", RenderValue(bundle_data.plugins_dir()));
|
| + data->SetString("product_type", bundle_data.product_type());
|
| +
|
| + auto deps = new base::ListValue();
|
| + for (const auto* dep : bundle_data.bundle_deps()) {
|
| + deps->AppendString(dep->label().GetUserVisibleName(GetToolchainLabel()));
|
| + }
|
| + data->Set("deps", deps);
|
| + res->Set("bundle_data", data);
|
| + }
|
| +
|
| + void FillInOutputs(base::DictionaryValue* res, const Target* target) {
|
| + if (target->output_type() == Target::ACTION) {
|
| + auto list = new base::ListValue();
|
| + for (const auto& elem : target->action_values().outputs().list()) {
|
| + list->AppendString(elem.AsString());
|
| + }
|
| + res->Set(variables::kOutputs, list);
|
| + } else if (target->output_type() == Target::CREATE_BUNDLE) {
|
| + std::vector<SourceFile> output_files;
|
| + target->bundle_data().GetOutputsAsSourceFiles(target->settings(),
|
| + &output_files);
|
| + res->Set(variables::kOutputs, RenderValue(output_files));
|
| + } else {
|
| + const SubstitutionList& outputs = target->action_values().outputs();
|
| + if (!outputs.required_types().empty()) {
|
| + auto patterns = new base::ListValue();
|
| + for (const auto& elem : outputs.list()) {
|
| + patterns->AppendString(elem.AsString());
|
| + }
|
| + res->Set("output_patterns", patterns);
|
| + }
|
| + std::vector<SourceFile> output_files;
|
| + SubstitutionWriter::ApplyListToSources(target->settings(), outputs,
|
| + target->sources(), &output_files);
|
| + res->Set(variables::kOutputs, RenderValue(output_files));
|
| + }
|
| + }
|
| +
|
| + // Writes a given config value type to the string, optionally with
|
| + // attribution.
|
| + // This should match RecursiveTargetConfigToStream in the order it traverses.
|
| + template <class T>
|
| + ValuePtr RenderConfigValues(const std::vector<T>& (ConfigValues::*getter)()
|
| + const) {
|
| + auto res = base::WrapUnique(new base::ListValue());
|
| + for (ConfigValuesIterator iter(target_); !iter.done(); iter.Next()) {
|
| + const std::vector<T>& vec = (iter.cur().*getter)();
|
| +
|
| + if (vec.empty())
|
| + continue;
|
| +
|
| + if (blame_) {
|
| + const Config* config = iter.GetCurrentConfig();
|
| + if (config) {
|
| + // Source of this value is a config.
|
| + std::string from =
|
| + "From " + config->label().GetUserVisibleName(false);
|
| + res->AppendString(from);
|
| + if (iter.origin()) {
|
| + Location location = iter.origin()->GetRange().begin();
|
| + from = " (Added by " + location.file()->name().value() + ":" +
|
| + base::IntToString(location.line_number()) + ")";
|
| + res->AppendString(from);
|
| + }
|
| + } else {
|
| + // Source of this value is the target itself.
|
| + std::string from =
|
| + "From " + target_->label().GetUserVisibleName(false);
|
| + res->AppendString(from);
|
| + }
|
| + }
|
| +
|
| + for (const T& val : vec) {
|
| + ValuePtr rendered = RenderValue(val);
|
| + std::string str;
|
| + // Indent string values in blame mode
|
| + if (blame_ && rendered->GetAsString(&str)) {
|
| + str = " " + str;
|
| + rendered = base::WrapUnique(new base::StringValue(str));
|
| + }
|
| + res->Append(std::move(rendered));
|
| + }
|
| + }
|
| + return res->empty() ? nullptr : std::move(res);
|
| + }
|
| +
|
| + Label GetToolchainLabel() const override {
|
| + return target_->label().GetToolchainLabel();
|
| + }
|
| +
|
| + const Target* target_;
|
| +};
|
| +
|
| +} // Namespace
|
| +
|
| +const char* DescBuilder::GetStringForOutputType(Target::OutputType type) {
|
| +#define CASE(C) \
|
| + case Target::C: \
|
| + return #C
|
| + switch (type) {
|
| + CASE(UNKNOWN);
|
| + CASE(GROUP);
|
| + CASE(EXECUTABLE);
|
| + CASE(LOADABLE_MODULE);
|
| + CASE(SHARED_LIBRARY);
|
| + CASE(STATIC_LIBRARY);
|
| + CASE(SOURCE_SET);
|
| + CASE(COPY_FILES);
|
| + CASE(ACTION);
|
| + CASE(ACTION_FOREACH);
|
| + CASE(BUNDLE_DATA);
|
| + CASE(CREATE_BUNDLE);
|
| + }
|
| +#undef CASE
|
| +}
|
| +
|
| +Target::OutputType DescBuilder::GetOutputTypeForString(
|
| + const std::string& type) {
|
| +#define CASE(C) \
|
| + if (type == #C) \
|
| + return Target::C
|
| + CASE(GROUP);
|
| + CASE(EXECUTABLE);
|
| + CASE(LOADABLE_MODULE);
|
| + CASE(SHARED_LIBRARY);
|
| + CASE(STATIC_LIBRARY);
|
| + CASE(SOURCE_SET);
|
| + CASE(COPY_FILES);
|
| + CASE(ACTION);
|
| + CASE(ACTION_FOREACH);
|
| + CASE(BUNDLE_DATA);
|
| + CASE(CREATE_BUNDLE);
|
| + return Target::UNKNOWN;
|
| +#undef CASE
|
| +}
|
| +
|
| +std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForTarget(
|
| + const Target* target,
|
| + const std::string& what,
|
| + bool all,
|
| + bool tree,
|
| + bool blame) {
|
| + std::set<std::string> w;
|
| + if (!what.empty())
|
| + w.insert(what);
|
| + TargetDescBuilder b(target, w, all, tree, blame);
|
| + return b.BuildDescription();
|
| +}
|
| +
|
| +std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig(
|
| + const Config* config,
|
| + const std::string& what) {
|
| + std::set<std::string> w;
|
| + if (!what.empty())
|
| + w.insert(what);
|
| + ConfigDescBuilder b(config, w);
|
| + return b.BuildDescription();
|
| +}
|
|
|