| Index: tools/gn/command_refs.cc
|
| diff --git a/tools/gn/command_refs.cc b/tools/gn/command_refs.cc
|
| index d49f5368c23e67782153034b872ec5cb2a4dc367..fde617c2d9239bdf45047425cdf2832ca1669fa2 100644
|
| --- a/tools/gn/command_refs.cc
|
| +++ b/tools/gn/command_refs.cc
|
| @@ -9,7 +9,6 @@
|
| #include "tools/gn/filesystem_utils.h"
|
| #include "tools/gn/input_file.h"
|
| #include "tools/gn/item.h"
|
| -#include "tools/gn/item_node.h"
|
| #include "tools/gn/pattern.h"
|
| #include "tools/gn/setup.h"
|
| #include "tools/gn/standard_out.h"
|
| @@ -19,12 +18,12 @@ namespace commands {
|
|
|
| namespace {
|
|
|
| -// Returns the file path generating this item node.
|
| -base::FilePath FilePathForItemNode(const ItemNode& node) {
|
| - const InputFile* file = node.generated_from_here().begin().file();
|
| - if (!file)
|
| +// Returns the file path generating this record.
|
| +base::FilePath FilePathForRecord(const BuilderRecord* record) {
|
| + if (!record->item())
|
| return base::FilePath(FILE_PATH_LITERAL("=UNRESOLVED DEPENDENCY="));
|
| - return file->physical_name();
|
| + return record->item()->defined_from()->GetRange().begin().file()
|
| + ->physical_name();
|
| }
|
|
|
| } // namespace
|
| @@ -34,6 +33,7 @@ const char kRefs_HelpShort[] =
|
| "refs: Find stuff referencing a target, directory, or config.";
|
| const char kRefs_Help[] =
|
| "gn refs <label_pattern> [--files]\n"
|
| + "\n"
|
| " Finds code referencing a given label. The label can be a\n"
|
| " target or config name. Unlike most other commands, unresolved\n"
|
| " dependencies will be tolerated. This allows you to use this command\n"
|
| @@ -88,33 +88,30 @@ int RunRefs(const std::vector<std::string>& args) {
|
| if (!setup->DoSetup() || !setup->Run())
|
| return 1;
|
|
|
| - const ItemTree& item_tree = setup->build_settings().item_tree();
|
| - base::AutoLock lock(item_tree.lock());
|
| -
|
| - std::vector<const ItemNode*> nodes;
|
| - item_tree.GetAllItemNodesLocked(&nodes);
|
| + std::vector<const BuilderRecord*> records = setup->builder()->GetAllRecords();
|
|
|
| const CommandLine* cmdline = CommandLine::ForCurrentProcess();
|
|
|
| bool file_output = cmdline->HasSwitch("files");
|
| std::set<std::string> unique_output;
|
|
|
| - for (size_t node_index = 0; node_index < nodes.size(); node_index++) {
|
| - const ItemNode& node = *nodes[node_index];
|
| - const ItemNode::ItemNodeMap& deps = node.direct_dependencies();
|
| - for (ItemNode::ItemNodeMap::const_iterator d = deps.begin();
|
| + for (size_t record_index = 0; record_index < records.size(); record_index++) {
|
| + const BuilderRecord* record = records[record_index];
|
| + const BuilderRecord::BuilderRecordSet& deps = record->all_deps();
|
| + for (BuilderRecord::BuilderRecordSet::const_iterator d = deps.begin();
|
| d != deps.end(); ++d) {
|
| - std::string label = d->first->item()->label().GetUserVisibleName(false);
|
| + std::string label = (*d)->label().GetUserVisibleName(false);
|
| if (pattern.MatchesString(label)) {
|
| // Got a match.
|
| if (file_output) {
|
| - unique_output.insert(FilePathToUTF8(FilePathForItemNode(node)));
|
| + unique_output.insert(FilePathToUTF8(FilePathForRecord(record)));
|
| break; // Found a match for this target's file, don't need more.
|
| } else {
|
| // We can get dupes when there are differnet toolchains involved,
|
| // so we want to send all output through the de-duper.
|
| unique_output.insert(
|
| - node.item()->label().GetUserVisibleName(false) + " -> " + label);
|
| + record->item()->label().GetUserVisibleName(false) + " -> " +
|
| + label);
|
| }
|
| }
|
| }
|
|
|