| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 #undef CONFIG_VALUE_ARRAY_HANDLER | 399 #undef CONFIG_VALUE_ARRAY_HANDLER |
| 400 | 400 |
| 401 // Libs and lib_dirs are handled specially below. | 401 // Libs and lib_dirs are handled specially below. |
| 402 | 402 |
| 403 FillInPrecompiledHeader(res.get(), target_->config_values()); | 403 FillInPrecompiledHeader(res.get(), target_->config_values()); |
| 404 } | 404 } |
| 405 | 405 |
| 406 if (what(variables::kDeps)) | 406 if (what(variables::kDeps)) |
| 407 res->SetWithoutPathExpansion(variables::kDeps, RenderDeps()); | 407 res->SetWithoutPathExpansion(variables::kDeps, RenderDeps()); |
| 408 | 408 |
| 409 // By default RenderDeps only renders Target::DEPS_PRIVATE, in that case |
| 410 // the output should be enriched also with Target::DEPS_PUBLIC. |
| 411 if (!tree_ && !all_) { |
| 412 if (what(variables::kPublicDeps)) { |
| 413 res->SetWithoutPathExpansion(variables::kPublicDeps, |
| 414 RenderPublicDeps()); |
| 415 } |
| 416 } |
| 417 |
| 409 // Runtime deps are special, print only when explicitly asked for and not in | 418 // Runtime deps are special, print only when explicitly asked for and not in |
| 410 // overview mode. | 419 // overview mode. |
| 411 if (what_.find("runtime_deps") != what_.end()) | 420 if (what_.find("runtime_deps") != what_.end()) |
| 412 res->SetWithoutPathExpansion("runtime_deps", RenderRuntimeDeps()); | 421 res->SetWithoutPathExpansion("runtime_deps", RenderRuntimeDeps()); |
| 413 | 422 |
| 414 // libs and lib_dirs are special in that they're inherited. We don't | 423 // libs and lib_dirs are special in that they're inherited. We don't |
| 415 // currently | 424 // currently |
| 416 // implement a blame feature for this since the bottom-up inheritance makes | 425 // implement a blame feature for this since the bottom-up inheritance makes |
| 417 // this difficult. | 426 // this difficult. |
| 418 | 427 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 513 |
| 505 // Collect the deps to display. | 514 // Collect the deps to display. |
| 506 if (all_) { | 515 if (all_) { |
| 507 // Show all dependencies. | 516 // Show all dependencies. |
| 508 std::set<const Target*> all_deps; | 517 std::set<const Target*> all_deps; |
| 509 RecursiveCollectChildDeps(target_, &all_deps); | 518 RecursiveCollectChildDeps(target_, &all_deps); |
| 510 commands::FilterAndPrintTargetSet(all_deps, res.get()); | 519 commands::FilterAndPrintTargetSet(all_deps, res.get()); |
| 511 } else { | 520 } else { |
| 512 // Show direct dependencies only. | 521 // Show direct dependencies only. |
| 513 std::vector<const Target*> deps; | 522 std::vector<const Target*> deps; |
| 514 for (const auto& pair : target_->GetDeps(Target::DEPS_ALL)) | 523 for (const auto& pair : target_->GetDeps(Target::DEPS_PRIVATE)) |
| 515 deps.push_back(pair.ptr); | 524 deps.push_back(pair.ptr); |
| 516 std::sort(deps.begin(), deps.end()); | 525 std::sort(deps.begin(), deps.end()); |
| 517 commands::FilterAndPrintTargets(&deps, res.get()); | 526 commands::FilterAndPrintTargets(&deps, res.get()); |
| 518 } | 527 } |
| 519 } | 528 } |
| 520 | 529 |
| 521 return std::move(res); | 530 return std::move(res); |
| 522 } | 531 } |
| 523 | 532 |
| 533 ValuePtr RenderPublicDeps() { |
| 534 auto res = base::MakeUnique<base::ListValue>(); |
| 535 |
| 536 std::vector<const Target*> deps; |
| 537 for (const auto& pair : target_->GetDeps(Target::DEPS_PUBLIC)) |
| 538 deps.push_back(pair.ptr); |
| 539 |
| 540 std::sort(deps.begin(), deps.end()); |
| 541 commands::FilterAndPrintTargets(&deps, res.get()); |
| 542 |
| 543 return std::move(res); |
| 544 } |
| 545 |
| 524 ValuePtr RenderRuntimeDeps() { | 546 ValuePtr RenderRuntimeDeps() { |
| 525 auto res = base::MakeUnique<base::ListValue>(); | 547 auto res = base::MakeUnique<base::ListValue>(); |
| 526 | 548 |
| 527 const Target* previous_from = NULL; | 549 const Target* previous_from = NULL; |
| 528 for (const auto& pair : ComputeRuntimeDeps(target_)) { | 550 for (const auto& pair : ComputeRuntimeDeps(target_)) { |
| 529 std::string str; | 551 std::string str; |
| 530 if (blame_) { | 552 if (blame_) { |
| 531 // Generally a target's runtime deps will be listed sequentially, so | 553 // Generally a target's runtime deps will be listed sequentially, so |
| 532 // group them and don't duplicate the "from" label for two in a row. | 554 // group them and don't duplicate the "from" label for two in a row. |
| 533 if (previous_from == pair.second) { | 555 if (previous_from == pair.second) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 | 733 |
| 712 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig( | 734 std::unique_ptr<base::DictionaryValue> DescBuilder::DescriptionForConfig( |
| 713 const Config* config, | 735 const Config* config, |
| 714 const std::string& what) { | 736 const std::string& what) { |
| 715 std::set<std::string> w; | 737 std::set<std::string> w; |
| 716 if (!what.empty()) | 738 if (!what.empty()) |
| 717 w.insert(what); | 739 w.insert(what); |
| 718 ConfigDescBuilder b(config, w); | 740 ConfigDescBuilder b(config, w); |
| 719 return b.BuildDescription(); | 741 return b.BuildDescription(); |
| 720 } | 742 } |
| OLD | NEW |