Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: tools/gn/command_refs.cc

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/command_gyp.cc ('k') | tools/gn/commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
}
« no previous file with comments | « tools/gn/command_gyp.cc ('k') | tools/gn/commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698