Commit 3d36fd0d authored by Dirk Pranke's avatar Dirk Pranke Committed by Commit Bot

Make `gn refs out/foo //out/foo/gn` work.

It would be good if we could use `gn refs` to tell us which
target generated a given executable. The docs suggested that
refs should do this, but it doesn't appear to do so.

Bug: 837876
Change-Id: I45f45bb3346ed21ede83fbacdea2207f1322ad69
Reviewed-on: https://chromium-review.googlesource.com/1033506
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555134}
parent 887c5947
...@@ -155,12 +155,17 @@ bool TargetContainsFile(const Target* target, const SourceFile& file) { ...@@ -155,12 +155,17 @@ bool TargetContainsFile(const Target* target, const SourceFile& file) {
if (target->action_values().script().value() == file.value()) if (target->action_values().script().value() == file.value())
return true; return true;
std::vector<SourceFile> outputs; std::vector<SourceFile> output_sources;
target->action_values().GetOutputsAsSourceFiles(target, &outputs); target->action_values().GetOutputsAsSourceFiles(target, &output_sources);
for (const auto& cur_file : outputs) { for (const auto& cur_file : output_sources) {
if (cur_file == file) if (cur_file == file)
return true; return true;
} }
for (const auto& cur_file : target->computed_outputs()) {
if (cur_file.AsSourceFile(target->settings()->build_settings()) == file)
return true;
}
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment