| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "tools/gn/commands.h" | 9 #include "tools/gn/commands.h" |
| 10 #include "tools/gn/config.h" | 10 #include "tools/gn/config.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 virtual Label GetToolchainLabel() const = 0; | 109 virtual Label GetToolchainLabel() const = 0; |
| 110 | 110 |
| 111 bool what(const std::string& w) const { | 111 bool what(const std::string& w) const { |
| 112 return what_.empty() || what_.find(w) != what_.end(); | 112 return what_.empty() || what_.find(w) != what_.end(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 template <typename T> | 115 template <typename T> |
| 116 ValuePtr RenderValue(const std::vector<T>& vector) { | 116 ValuePtr RenderValue(const std::vector<T>& vector) { |
| 117 auto res = base::WrapUnique(new base::ListValue()); | 117 auto res = base::MakeUnique<base::ListValue>(); |
| 118 for (const auto& v : vector) | 118 for (const auto& v : vector) |
| 119 res->Append(RenderValue(v)); | 119 res->Append(RenderValue(v)); |
| 120 | 120 |
| 121 return std::move(res); | 121 return std::move(res); |
| 122 } | 122 } |
| 123 | 123 |
| 124 ValuePtr RenderValue(const std::string& s, bool optional = false) { | 124 ValuePtr RenderValue(const std::string& s, bool optional = false) { |
| 125 return (s.empty() && optional) ? base::Value::CreateNullValue() | 125 return (s.empty() && optional) ? base::Value::CreateNullValue() |
| 126 : ValuePtr(new base::StringValue(s)); | 126 : ValuePtr(new base::StringValue(s)); |
| 127 } | 127 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 bool tree_; | 174 bool tree_; |
| 175 bool blame_; | 175 bool blame_; |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 class ConfigDescBuilder : public BaseDescBuilder { | 178 class ConfigDescBuilder : public BaseDescBuilder { |
| 179 public: | 179 public: |
| 180 ConfigDescBuilder(const Config* config, const std::set<std::string>& what) | 180 ConfigDescBuilder(const Config* config, const std::set<std::string>& what) |
| 181 : BaseDescBuilder(what, false, false, false), config_(config) {} | 181 : BaseDescBuilder(what, false, false, false), config_(config) {} |
| 182 | 182 |
| 183 std::unique_ptr<base::DictionaryValue> BuildDescription() { | 183 std::unique_ptr<base::DictionaryValue> BuildDescription() { |
| 184 auto res = base::WrapUnique(new base::DictionaryValue()); | 184 auto res = base::MakeUnique<base::DictionaryValue>(); |
| 185 const ConfigValues& values = config_->resolved_values(); | 185 const ConfigValues& values = config_->resolved_values(); |
| 186 | 186 |
| 187 if (what_.empty()) | 187 if (what_.empty()) |
| 188 res->SetString( | 188 res->SetString( |
| 189 "toolchain", | 189 "toolchain", |
| 190 config_->label().GetToolchainLabel().GetUserVisibleName(false)); | 190 config_->label().GetToolchainLabel().GetUserVisibleName(false)); |
| 191 | 191 |
| 192 if (what(variables::kConfigs) && !config_->configs().empty()) { | 192 if (what(variables::kConfigs) && !config_->configs().empty()) { |
| 193 auto configs = base::WrapUnique(new base::ListValue()); | 193 auto configs = base::MakeUnique<base::ListValue>(); |
| 194 FillInConfigVector(configs.get(), config_->configs().vector()); | 194 FillInConfigVector(configs.get(), config_->configs().vector()); |
| 195 res->Set(variables::kConfigs, std::move(configs)); | 195 res->Set(variables::kConfigs, std::move(configs)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 #define CONFIG_VALUE_ARRAY_HANDLER(name, type) \ | 198 #define CONFIG_VALUE_ARRAY_HANDLER(name, type) \ |
| 199 if (what(#name)) { \ | 199 if (what(#name)) { \ |
| 200 ValuePtr ptr = \ | 200 ValuePtr ptr = \ |
| 201 render_config_value_array<type>(values, &ConfigValues::name); \ | 201 render_config_value_array<type>(values, &ConfigValues::name); \ |
| 202 if (ptr) { \ | 202 if (ptr) { \ |
| 203 res->Set(#name, std::move(ptr)); \ | 203 res->Set(#name, std::move(ptr)); \ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 226 protected: | 226 protected: |
| 227 Label GetToolchainLabel() const override { | 227 Label GetToolchainLabel() const override { |
| 228 return config_->label().GetToolchainLabel(); | 228 return config_->label().GetToolchainLabel(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 private: | 231 private: |
| 232 template <typename T> | 232 template <typename T> |
| 233 ValuePtr render_config_value_array( | 233 ValuePtr render_config_value_array( |
| 234 const ConfigValues& values, | 234 const ConfigValues& values, |
| 235 const std::vector<T>& (ConfigValues::*getter)() const) { | 235 const std::vector<T>& (ConfigValues::*getter)() const) { |
| 236 auto res = base::WrapUnique(new base::ListValue()); | 236 auto res = base::MakeUnique<base::ListValue>(); |
| 237 | 237 |
| 238 for (const T& cur : (values.*getter)()) | 238 for (const T& cur : (values.*getter)()) |
| 239 res->Append(RenderValue(cur)); | 239 res->Append(RenderValue(cur)); |
| 240 | 240 |
| 241 return res->empty() ? nullptr : std::move(res); | 241 return res->empty() ? nullptr : std::move(res); |
| 242 } | 242 } |
| 243 | 243 |
| 244 const Config* config_; | 244 const Config* config_; |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 class TargetDescBuilder : public BaseDescBuilder { | 247 class TargetDescBuilder : public BaseDescBuilder { |
| 248 public: | 248 public: |
| 249 TargetDescBuilder(const Target* target, | 249 TargetDescBuilder(const Target* target, |
| 250 const std::set<std::string>& what, | 250 const std::set<std::string>& what, |
| 251 bool all, | 251 bool all, |
| 252 bool tree, | 252 bool tree, |
| 253 bool blame) | 253 bool blame) |
| 254 : BaseDescBuilder(what, all, tree, blame), target_(target) {} | 254 : BaseDescBuilder(what, all, tree, blame), target_(target) {} |
| 255 | 255 |
| 256 std::unique_ptr<base::DictionaryValue> BuildDescription() { | 256 std::unique_ptr<base::DictionaryValue> BuildDescription() { |
| 257 auto res = base::WrapUnique(new base::DictionaryValue()); | 257 auto res = base::MakeUnique<base::DictionaryValue>(); |
| 258 bool is_binary_output = target_->IsBinary(); | 258 bool is_binary_output = target_->IsBinary(); |
| 259 | 259 |
| 260 if (what_.empty()) { | 260 if (what_.empty()) { |
| 261 res->SetString("type", | 261 res->SetString("type", |
| 262 Target::GetStringForOutputType(target_->output_type())); | 262 Target::GetStringForOutputType(target_->output_type())); |
| 263 res->SetString( | 263 res->SetString( |
| 264 "toolchain", | 264 "toolchain", |
| 265 target_->label().GetToolchainLabel().GetUserVisibleName(false)); | 265 target_->label().GetToolchainLabel().GetUserVisibleName(false)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 // General target meta variables. | 268 // General target meta variables. |
| 269 if (what(variables::kVisibility)) | 269 if (what(variables::kVisibility)) |
| 270 res->Set(variables::kVisibility, target_->visibility().AsValue()); | 270 res->Set(variables::kVisibility, target_->visibility().AsValue()); |
| 271 | 271 |
| 272 if (what(variables::kTestonly)) | 272 if (what(variables::kTestonly)) |
| 273 res->SetBoolean(variables::kTestonly, target_->testonly()); | 273 res->SetBoolean(variables::kTestonly, target_->testonly()); |
| 274 | 274 |
| 275 if (is_binary_output) { | 275 if (is_binary_output) { |
| 276 if (what(variables::kCheckIncludes)) | 276 if (what(variables::kCheckIncludes)) |
| 277 res->SetBoolean(variables::kCheckIncludes, target_->check_includes()); | 277 res->SetBoolean(variables::kCheckIncludes, target_->check_includes()); |
| 278 | 278 |
| 279 if (what(variables::kAllowCircularIncludesFrom)) { | 279 if (what(variables::kAllowCircularIncludesFrom)) { |
| 280 auto labels = base::WrapUnique(new base::ListValue()); | 280 auto labels = base::MakeUnique<base::ListValue>(); |
| 281 for (const auto& cur : target_->allow_circular_includes_from()) | 281 for (const auto& cur : target_->allow_circular_includes_from()) |
| 282 labels->AppendString(cur.GetUserVisibleName(GetToolchainLabel())); | 282 labels->AppendString(cur.GetUserVisibleName(GetToolchainLabel())); |
| 283 | 283 |
| 284 res->Set(variables::kAllowCircularIncludesFrom, std::move(labels)); | 284 res->Set(variables::kAllowCircularIncludesFrom, std::move(labels)); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 | 287 |
| 288 if (what(variables::kSources) && !target_->sources().empty()) | 288 if (what(variables::kSources) && !target_->sources().empty()) |
| 289 res->Set(variables::kSources, RenderValue(target_->sources())); | 289 res->Set(variables::kSources, RenderValue(target_->sources())); |
| 290 | 290 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 302 res->SetString(variables::kPublic, "*"); | 302 res->SetString(variables::kPublic, "*"); |
| 303 else | 303 else |
| 304 res->Set(variables::kPublic, RenderValue(target_->public_headers())); | 304 res->Set(variables::kPublic, RenderValue(target_->public_headers())); |
| 305 } | 305 } |
| 306 | 306 |
| 307 if (what(variables::kInputs) && !target_->inputs().empty()) | 307 if (what(variables::kInputs) && !target_->inputs().empty()) |
| 308 res->Set(variables::kInputs, RenderValue(target_->inputs())); | 308 res->Set(variables::kInputs, RenderValue(target_->inputs())); |
| 309 | 309 |
| 310 if (is_binary_output && what(variables::kConfigs) && | 310 if (is_binary_output && what(variables::kConfigs) && |
| 311 !target_->configs().empty()) { | 311 !target_->configs().empty()) { |
| 312 auto configs = base::WrapUnique(new base::ListValue()); | 312 auto configs = base::MakeUnique<base::ListValue>(); |
| 313 FillInConfigVector(configs.get(), target_->configs().vector()); | 313 FillInConfigVector(configs.get(), target_->configs().vector()); |
| 314 res->Set(variables::kConfigs, std::move(configs)); | 314 res->Set(variables::kConfigs, std::move(configs)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 if (what(variables::kPublicConfigs) && !target_->public_configs().empty()) { | 317 if (what(variables::kPublicConfigs) && !target_->public_configs().empty()) { |
| 318 auto configs = base::WrapUnique(new base::ListValue()); | 318 auto configs = base::MakeUnique<base::ListValue>(); |
| 319 FillInConfigVector(configs.get(), target_->public_configs()); | 319 FillInConfigVector(configs.get(), target_->public_configs()); |
| 320 res->Set(variables::kPublicConfigs, std::move(configs)); | 320 res->Set(variables::kPublicConfigs, std::move(configs)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 if (what(variables::kAllDependentConfigs) && | 323 if (what(variables::kAllDependentConfigs) && |
| 324 !target_->all_dependent_configs().empty()) { | 324 !target_->all_dependent_configs().empty()) { |
| 325 auto configs = base::WrapUnique(new base::ListValue()); | 325 auto configs = base::MakeUnique<base::ListValue>(); |
| 326 FillInConfigVector(configs.get(), target_->all_dependent_configs()); | 326 FillInConfigVector(configs.get(), target_->all_dependent_configs()); |
| 327 res->Set(variables::kAllDependentConfigs, std::move(configs)); | 327 res->Set(variables::kAllDependentConfigs, std::move(configs)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 // Action | 330 // Action |
| 331 if (target_->output_type() == Target::ACTION || | 331 if (target_->output_type() == Target::ACTION || |
| 332 target_->output_type() == Target::ACTION_FOREACH) { | 332 target_->output_type() == Target::ACTION_FOREACH) { |
| 333 if (what(variables::kScript)) | 333 if (what(variables::kScript)) |
| 334 res->SetString(variables::kScript, | 334 res->SetString(variables::kScript, |
| 335 target_->action_values().script().value()); | 335 target_->action_values().script().value()); |
| 336 | 336 |
| 337 if (what(variables::kArgs)) { | 337 if (what(variables::kArgs)) { |
| 338 auto args = base::WrapUnique(new base::ListValue()); | 338 auto args = base::MakeUnique<base::ListValue>(); |
| 339 for (const auto& elem : target_->action_values().args().list()) | 339 for (const auto& elem : target_->action_values().args().list()) |
| 340 args->AppendString(elem.AsString()); | 340 args->AppendString(elem.AsString()); |
| 341 | 341 |
| 342 res->Set(variables::kArgs, std::move(args)); | 342 res->Set(variables::kArgs, std::move(args)); |
| 343 } | 343 } |
| 344 if (what(variables::kDepfile) && | 344 if (what(variables::kDepfile) && |
| 345 !target_->action_values().depfile().empty()) { | 345 !target_->action_values().depfile().empty()) { |
| 346 res->SetString(variables::kDepfile, | 346 res->SetString(variables::kDepfile, |
| 347 target_->action_values().depfile().AsString()); | 347 target_->action_values().depfile().AsString()); |
| 348 } | 348 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // libs and lib_dirs are special in that they're inherited. We don't | 398 // libs and lib_dirs are special in that they're inherited. We don't |
| 399 // currently | 399 // currently |
| 400 // implement a blame feature for this since the bottom-up inheritance makes | 400 // implement a blame feature for this since the bottom-up inheritance makes |
| 401 // this difficult. | 401 // this difficult. |
| 402 | 402 |
| 403 // Libs can be part of any target and get recursively pushed up the chain, | 403 // Libs can be part of any target and get recursively pushed up the chain, |
| 404 // so display them regardless of target type. | 404 // so display them regardless of target type. |
| 405 if (what(variables::kLibs)) { | 405 if (what(variables::kLibs)) { |
| 406 const OrderedSet<LibFile>& all_libs = target_->all_libs(); | 406 const OrderedSet<LibFile>& all_libs = target_->all_libs(); |
| 407 if (!all_libs.empty()) { | 407 if (!all_libs.empty()) { |
| 408 auto libs = base::WrapUnique(new base::ListValue()); | 408 auto libs = base::MakeUnique<base::ListValue>(); |
| 409 for (size_t i = 0; i < all_libs.size(); i++) | 409 for (size_t i = 0; i < all_libs.size(); i++) |
| 410 libs->AppendString(all_libs[i].value()); | 410 libs->AppendString(all_libs[i].value()); |
| 411 res->Set(variables::kLibs, std::move(libs)); | 411 res->Set(variables::kLibs, std::move(libs)); |
| 412 } | 412 } |
| 413 } | 413 } |
| 414 | 414 |
| 415 if (what(variables::kLibDirs)) { | 415 if (what(variables::kLibDirs)) { |
| 416 const OrderedSet<SourceDir>& all_lib_dirs = target_->all_lib_dirs(); | 416 const OrderedSet<SourceDir>& all_lib_dirs = target_->all_lib_dirs(); |
| 417 if (!all_lib_dirs.empty()) { | 417 if (!all_lib_dirs.empty()) { |
| 418 auto lib_dirs = base::WrapUnique(new base::ListValue()); | 418 auto lib_dirs = base::MakeUnique<base::ListValue>(); |
| 419 for (size_t i = 0; i < all_lib_dirs.size(); i++) | 419 for (size_t i = 0; i < all_lib_dirs.size(); i++) |
| 420 lib_dirs->AppendString(FormatSourceDir(all_lib_dirs[i])); | 420 lib_dirs->AppendString(FormatSourceDir(all_lib_dirs[i])); |
| 421 res->Set(variables::kLibDirs, std::move(lib_dirs)); | 421 res->Set(variables::kLibDirs, std::move(lib_dirs)); |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 | 424 |
| 425 return res; | 425 return res; |
| 426 } | 426 } |
| 427 | 427 |
| 428 private: | 428 private: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } | 465 } |
| 466 | 466 |
| 467 out->AppendString(str); | 467 out->AppendString(str); |
| 468 | 468 |
| 469 if (print_children) | 469 if (print_children) |
| 470 RecursivePrintDeps(out, cur_dep, seen_targets, indent_level + 1); | 470 RecursivePrintDeps(out, cur_dep, seen_targets, indent_level + 1); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 ValuePtr RenderDeps() { | 474 ValuePtr RenderDeps() { |
| 475 auto res = base::WrapUnique(new base::ListValue()); | 475 auto res = base::MakeUnique<base::ListValue>(); |
| 476 | 476 |
| 477 // Tree mode is separate. | 477 // Tree mode is separate. |
| 478 if (tree_) { | 478 if (tree_) { |
| 479 if (all_) { | 479 if (all_) { |
| 480 // Show all tree deps with no eliding. | 480 // Show all tree deps with no eliding. |
| 481 RecursivePrintDeps(res.get(), target_, nullptr, 0); | 481 RecursivePrintDeps(res.get(), target_, nullptr, 0); |
| 482 } else { | 482 } else { |
| 483 // Don't recurse into duplicates. | 483 // Don't recurse into duplicates. |
| 484 std::set<const Target*> seen_targets; | 484 std::set<const Target*> seen_targets; |
| 485 RecursivePrintDeps(res.get(), target_, &seen_targets, 0); | 485 RecursivePrintDeps(res.get(), target_, &seen_targets, 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 499 deps.push_back(pair.ptr); | 499 deps.push_back(pair.ptr); |
| 500 std::sort(deps.begin(), deps.end()); | 500 std::sort(deps.begin(), deps.end()); |
| 501 commands::FilterAndPrintTargets(&deps, res.get()); | 501 commands::FilterAndPrintTargets(&deps, res.get()); |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 | 504 |
| 505 return std::move(res); | 505 return std::move(res); |
| 506 } | 506 } |
| 507 | 507 |
| 508 ValuePtr RenderRuntimeDeps() { | 508 ValuePtr RenderRuntimeDeps() { |
| 509 auto res = base::WrapUnique(new base::ListValue()); | 509 auto res = base::MakeUnique<base::ListValue>(); |
| 510 | 510 |
| 511 const Target* previous_from = NULL; | 511 const Target* previous_from = NULL; |
| 512 for (const auto& pair : ComputeRuntimeDeps(target_)) { | 512 for (const auto& pair : ComputeRuntimeDeps(target_)) { |
| 513 std::string str; | 513 std::string str; |
| 514 if (blame_) { | 514 if (blame_) { |
| 515 // Generally a target's runtime deps will be listed sequentially, so | 515 // Generally a target's runtime deps will be listed sequentially, so |
| 516 // group them and don't duplicate the "from" label for two in a row. | 516 // group them and don't duplicate the "from" label for two in a row. |
| 517 if (previous_from == pair.second) { | 517 if (previous_from == pair.second) { |
| 518 str = " "; | 518 str = " "; |
| 519 } else { | 519 } else { |
| 520 previous_from = pair.second; | 520 previous_from = pair.second; |
| 521 res->AppendString( | 521 res->AppendString( |
| 522 str + "From " + | 522 str + "From " + |
| 523 pair.second->label().GetUserVisibleName(GetToolchainLabel())); | 523 pair.second->label().GetUserVisibleName(GetToolchainLabel())); |
| 524 str = " "; | 524 str = " "; |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 | 527 |
| 528 res->AppendString(str + pair.first.value()); | 528 res->AppendString(str + pair.first.value()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 return std::move(res); | 531 return std::move(res); |
| 532 } | 532 } |
| 533 | 533 |
| 534 void FillInSourceOutputs(base::DictionaryValue* res) { | 534 void FillInSourceOutputs(base::DictionaryValue* res) { |
| 535 auto dict = base::WrapUnique(new base::DictionaryValue()); | 535 auto dict = base::MakeUnique<base::DictionaryValue>(); |
| 536 for (const auto& source : target_->sources()) { | 536 for (const auto& source : target_->sources()) { |
| 537 std::vector<OutputFile> outputs; | 537 std::vector<OutputFile> outputs; |
| 538 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; | 538 Toolchain::ToolType tool_type = Toolchain::TYPE_NONE; |
| 539 if (target_->GetOutputFilesForSource(source, &tool_type, &outputs)) { | 539 if (target_->GetOutputFilesForSource(source, &tool_type, &outputs)) { |
| 540 auto list = base::WrapUnique(new base::ListValue()); | 540 auto list = base::MakeUnique<base::ListValue>(); |
| 541 for (const auto& output : outputs) | 541 for (const auto& output : outputs) |
| 542 list->AppendString(output.value()); | 542 list->AppendString(output.value()); |
| 543 | 543 |
| 544 dict->SetWithoutPathExpansion(source.value(), std::move(list)); | 544 dict->SetWithoutPathExpansion(source.value(), std::move(list)); |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 res->Set("source_outputs", std::move(dict)); | 547 res->Set("source_outputs", std::move(dict)); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void FillInBundle(base::DictionaryValue* res) { | 550 void FillInBundle(base::DictionaryValue* res) { |
| 551 auto data = base::WrapUnique(new base::DictionaryValue()); | 551 auto data = base::MakeUnique<base::DictionaryValue>(); |
| 552 const BundleData& bundle_data = target_->bundle_data(); | 552 const BundleData& bundle_data = target_->bundle_data(); |
| 553 const Settings* settings = target_->settings(); | 553 const Settings* settings = target_->settings(); |
| 554 BundleData::SourceFiles sources; | 554 BundleData::SourceFiles sources; |
| 555 bundle_data.GetSourceFiles(&sources); | 555 bundle_data.GetSourceFiles(&sources); |
| 556 data->Set("source_files", RenderValue(sources)); | 556 data->Set("source_files", RenderValue(sources)); |
| 557 data->SetString("root_dir_output", | 557 data->SetString("root_dir_output", |
| 558 bundle_data.GetBundleRootDirOutput(settings).value()); | 558 bundle_data.GetBundleRootDirOutput(settings).value()); |
| 559 data->Set("root_dir", RenderValue(bundle_data.root_dir())); | 559 data->Set("root_dir", RenderValue(bundle_data.root_dir())); |
| 560 data->Set("resources_dir", RenderValue(bundle_data.resources_dir())); | 560 data->Set("resources_dir", RenderValue(bundle_data.resources_dir())); |
| 561 data->Set("executable_dir", RenderValue(bundle_data.executable_dir())); | 561 data->Set("executable_dir", RenderValue(bundle_data.executable_dir())); |
| 562 data->Set("plugins_dir", RenderValue(bundle_data.plugins_dir())); | 562 data->Set("plugins_dir", RenderValue(bundle_data.plugins_dir())); |
| 563 data->SetString("product_type", bundle_data.product_type()); | 563 data->SetString("product_type", bundle_data.product_type()); |
| 564 | 564 |
| 565 auto deps = base::WrapUnique(new base::ListValue()); | 565 auto deps = base::MakeUnique<base::ListValue>(); |
| 566 for (const auto* dep : bundle_data.bundle_deps()) | 566 for (const auto* dep : bundle_data.bundle_deps()) |
| 567 deps->AppendString(dep->label().GetUserVisibleName(GetToolchainLabel())); | 567 deps->AppendString(dep->label().GetUserVisibleName(GetToolchainLabel())); |
| 568 | 568 |
| 569 data->Set("deps", std::move(deps)); | 569 data->Set("deps", std::move(deps)); |
| 570 res->Set("bundle_data", std::move(data)); | 570 res->Set("bundle_data", std::move(data)); |
| 571 } | 571 } |
| 572 | 572 |
| 573 void FillInOutputs(base::DictionaryValue* res) { | 573 void FillInOutputs(base::DictionaryValue* res) { |
| 574 if (target_->output_type() == Target::ACTION) { | 574 if (target_->output_type() == Target::ACTION) { |
| 575 auto list = base::WrapUnique(new base::ListValue()); | 575 auto list = base::MakeUnique<base::ListValue>(); |
| 576 for (const auto& elem : target_->action_values().outputs().list()) | 576 for (const auto& elem : target_->action_values().outputs().list()) |
| 577 list->AppendString(elem.AsString()); | 577 list->AppendString(elem.AsString()); |
| 578 | 578 |
| 579 res->Set(variables::kOutputs, std::move(list)); | 579 res->Set(variables::kOutputs, std::move(list)); |
| 580 } else if (target_->output_type() == Target::CREATE_BUNDLE) { | 580 } else if (target_->output_type() == Target::CREATE_BUNDLE) { |
| 581 std::vector<SourceFile> output_files; | 581 std::vector<SourceFile> output_files; |
| 582 target_->bundle_data().GetOutputsAsSourceFiles(target_->settings(), | 582 target_->bundle_data().GetOutputsAsSourceFiles(target_->settings(), |
| 583 &output_files); | 583 &output_files); |
| 584 res->Set(variables::kOutputs, RenderValue(output_files)); | 584 res->Set(variables::kOutputs, RenderValue(output_files)); |
| 585 } else if (target_->output_type() == Target::ACTION_FOREACH || | 585 } else if (target_->output_type() == Target::ACTION_FOREACH || |
| 586 target_->output_type() == Target::COPY_FILES) { | 586 target_->output_type() == Target::COPY_FILES) { |
| 587 const SubstitutionList& outputs = target_->action_values().outputs(); | 587 const SubstitutionList& outputs = target_->action_values().outputs(); |
| 588 if (!outputs.required_types().empty()) { | 588 if (!outputs.required_types().empty()) { |
| 589 auto patterns = base::WrapUnique(new base::ListValue()); | 589 auto patterns = base::MakeUnique<base::ListValue>(); |
| 590 for (const auto& elem : outputs.list()) | 590 for (const auto& elem : outputs.list()) |
| 591 patterns->AppendString(elem.AsString()); | 591 patterns->AppendString(elem.AsString()); |
| 592 | 592 |
| 593 res->Set("output_patterns", std::move(patterns)); | 593 res->Set("output_patterns", std::move(patterns)); |
| 594 } | 594 } |
| 595 std::vector<SourceFile> output_files; | 595 std::vector<SourceFile> output_files; |
| 596 SubstitutionWriter::ApplyListToSources(target_->settings(), outputs, | 596 SubstitutionWriter::ApplyListToSources(target_->settings(), outputs, |
| 597 target_->sources(), &output_files); | 597 target_->sources(), &output_files); |
| 598 res->Set(variables::kOutputs, RenderValue(output_files)); | 598 res->Set(variables::kOutputs, RenderValue(output_files)); |
| 599 } else { | 599 } else { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 612 res->Set(variables::kOutputs, RenderValue(output_files_as_source_file)); | 612 res->Set(variables::kOutputs, RenderValue(output_files_as_source_file)); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 // Writes a given config value type to the string, optionally with | 616 // Writes a given config value type to the string, optionally with |
| 617 // attribution. | 617 // attribution. |
| 618 // This should match RecursiveTargetConfigToStream in the order it traverses. | 618 // This should match RecursiveTargetConfigToStream in the order it traverses. |
| 619 template <class T> | 619 template <class T> |
| 620 ValuePtr RenderConfigValues(const std::vector<T>& (ConfigValues::*getter)() | 620 ValuePtr RenderConfigValues(const std::vector<T>& (ConfigValues::*getter)() |
| 621 const) { | 621 const) { |
| 622 auto res = base::WrapUnique(new base::ListValue()); | 622 auto res = base::MakeUnique<base::ListValue>(); |
| 623 for (ConfigValuesIterator iter(target_); !iter.done(); iter.Next()) { | 623 for (ConfigValuesIterator iter(target_); !iter.done(); iter.Next()) { |
| 624 const std::vector<T>& vec = (iter.cur().*getter)(); | 624 const std::vector<T>& vec = (iter.cur().*getter)(); |
| 625 | 625 |
| 626 if (vec.empty()) | 626 if (vec.empty()) |
| 627 continue; | 627 continue; |
| 628 | 628 |
| 629 if (blame_) { | 629 if (blame_) { |
| 630 const Config* config = iter.GetCurrentConfig(); | 630 const Config* config = iter.GetCurrentConfig(); |
| 631 if (config) { | 631 if (config) { |
| 632 // Source of this value is a config. | 632 // Source of this value is a config. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 646 res->AppendString(from); | 646 res->AppendString(from); |
| 647 } | 647 } |
| 648 } | 648 } |
| 649 | 649 |
| 650 for (const T& val : vec) { | 650 for (const T& val : vec) { |
| 651 ValuePtr rendered = RenderValue(val); | 651 ValuePtr rendered = RenderValue(val); |
| 652 std::string str; | 652 std::string str; |
| 653 // Indent string values in blame mode | 653 // Indent string values in blame mode |
| 654 if (blame_ && rendered->GetAsString(&str)) { | 654 if (blame_ && rendered->GetAsString(&str)) { |
| 655 str = " " + str; | 655 str = " " + str; |
| 656 rendered = base::WrapUnique(new base::StringValue(str)); | 656 rendered = base::MakeUnique<base::StringValue>(str); |
| 657 } | 657 } |
| 658 res->Append(std::move(rendered)); | 658 res->Append(std::move(rendered)); |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 return res->empty() ? nullptr : std::move(res); | 661 return res->empty() ? nullptr : std::move(res); |
| 662 } | 662 } |
| 663 | 663 |
| 664 Label GetToolchainLabel() const override { | 664 Label GetToolchainLabel() const override { |
| 665 return target_->label().GetToolchainLabel(); | 665 return target_->label().GetToolchainLabel(); |
| 666 } | 666 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 685 | 685 |
| 686 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig( | 686 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig( |
| 687 const Config* config, | 687 const Config* config, |
| 688 const std::string& what) { | 688 const std::string& what) { |
| 689 std::set<std::string> w; | 689 std::set<std::string> w; |
| 690 if (!what.empty()) | 690 if (!what.empty()) |
| 691 w.insert(what); | 691 w.insert(what); |
| 692 ConfigDescBuilder b(config, w); | 692 ConfigDescBuilder b(config, w); |
| 693 return b.BuildDescription(); | 693 return b.BuildDescription(); |
| 694 } | 694 } |
| OLD | NEW |