| Index: tools/gn/command_desc.cc
|
| diff --git a/tools/gn/command_desc.cc b/tools/gn/command_desc.cc
|
| index 8b321e4a20f41307c7dfe1a071c2af4ce61266c0..efb0b068cf0b6bb19099e9ecc12d024047d84a69 100644
|
| --- a/tools/gn/command_desc.cc
|
| +++ b/tools/gn/command_desc.cc
|
| @@ -14,6 +14,7 @@
|
| #include "tools/gn/filesystem_utils.h"
|
| #include "tools/gn/item.h"
|
| #include "tools/gn/label.h"
|
| +#include "tools/gn/runtime_deps.h"
|
| #include "tools/gn/setup.h"
|
| #include "tools/gn/standard_out.h"
|
| #include "tools/gn/substitution_writer.h"
|
| @@ -24,6 +25,9 @@ namespace commands {
|
|
|
| namespace {
|
|
|
| +// The switch for displaying blame.
|
| +const char kBlame[] = "blame";
|
| +
|
| // Prints the given directory in a nice way for the user to view.
|
| std::string FormatSourceDir(const SourceDir& dir) {
|
| #if defined(OS_WIN)
|
| @@ -404,7 +408,7 @@ template<typename T> void OutputRecursiveTargetConfig(
|
| const char* header_name,
|
| const std::vector<T>& (ConfigValues::* getter)() const) {
|
| bool display_blame =
|
| - base::CommandLine::ForCurrentProcess()->HasSwitch("blame");
|
| + base::CommandLine::ForCurrentProcess()->HasSwitch(kBlame);
|
|
|
| DescValueWriter<T> writer;
|
| std::ostringstream out;
|
| @@ -437,6 +441,30 @@ template<typename T> void OutputRecursiveTargetConfig(
|
| }
|
| }
|
|
|
| +void PrintRuntimeDeps(const Target* target) {
|
| + bool display_blame =
|
| + base::CommandLine::ForCurrentProcess()->HasSwitch(kBlame);
|
| + Label toolchain = target->label().GetToolchainLabel();
|
| +
|
| + const Target* previous_from = NULL;
|
| + for (const auto& pair : ComputeRuntimeDeps(target)) {
|
| + if (display_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) {
|
| + OutputString(" "); // Just indent.
|
| + } else {
|
| + previous_from = pair.second;
|
| + OutputString("From ");
|
| + OutputString(pair.second->label().GetUserVisibleName(toolchain));
|
| + OutputString("\n "); // Make the file name indented.
|
| + }
|
| + }
|
| + OutputString(pair.first.value());
|
| + OutputString("\n");
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| // desc ------------------------------------------------------------------------
|
| @@ -514,6 +542,18 @@ const char kDesc_Help[] =
|
| " Shows the given values taken from the target and all configs\n"
|
| " applying. See \"--blame\" below.\n"
|
| "\n"
|
| + " runtime_deps\n"
|
| + " Compute all runtime deps for the given target. This is a\n"
|
| + " computed list and does not correspond to any GN variable, unlike\n"
|
| + " most other values here.\n"
|
| + "\n"
|
| + " The output is a list of file names relative to the build\n"
|
| + " directory. See \"gn help runtime_deps\" for how this is computed.\n"
|
| + " This also works with \"--blame\" to see the source of the\n"
|
| + " dependency.\n"
|
| + "\n"
|
| + "Shared flags\n"
|
| + "\n"
|
| " --blame\n"
|
| " Used with any value specified by a config, this will name\n"
|
| " the config that specified the value. This doesn't currently work\n"
|
| @@ -628,6 +668,8 @@ int RunDesc(const std::vector<std::string>& args) {
|
| PrintLibDirs(target, false);
|
| } else if (what == variables::kLibs) {
|
| PrintLibs(target, false);
|
| + } else if (what == "runtime_deps") {
|
| + PrintRuntimeDeps(target);
|
|
|
| CONFIG_VALUE_HANDLER(defines, std::string)
|
| CONFIG_VALUE_HANDLER(include_dirs, SourceDir)
|
|
|