Revert "Fix a bug in `gn analyze` for host-only file mods."
This reverts commit 21886543a0cbedeb869fb68944e13ef613cedceb.
Reason for revert:
It looks like `gn analyze` returns targets in other toolchains in the label format `foo(//bar)` and MB isn't smart enough to turn those into the correct ninja outputs, and so running `gn analyze` on all does the wrong thing and compiles fail :(. See crbug.com/736215 for more.
Original change's description:
> Fix a bug in `gn analyze` for host-only file mods.
>
> If you modified a file that only affected targets defined in a
> non-default toolchain (e.g., like the host toolchain), `gn analyze`
> would skip over it and hence not do the right thing. For example,
> if you modified //testing/iossim/iossim.mm, analyze would think
> that no compile was needed, when really you'd want to recompile
> the simulator and re-run every test.
>
> Unfortunately, I don't remember why I wrote the code the way I did,
> but looking at it now I can't think of a reason not to just look in
> every toolchain.
>
> BUG=667989
>
> Change-Id: I8e1935d7dc23bf49fa87e191c1a136a5492d3678
> Reviewed-on: https://chromium-review.googlesource.com/528527
> Reviewed-by: smut <smut@chromium.org>
> Reviewed-by: Brett Wilson <brettw@chromium.org>
> Commit-Queue: Dirk Pranke <dpranke@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#478388}
TBR=brettw@chromium.org,smut@google.com,dpranke@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 667989
Change-Id: I4042f17d185709edfca75987f1a32c864c2ea4ab
Reviewed-on: https://chromium-review.googlesource.com/546679
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#482003}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: bf0dae2525be222e524a7fcb8e6e370165ea1441
diff --git a/tools/gn/analyzer.cc b/tools/gn/analyzer.cc
index aa0eca4..d1f2d52 100644
--- a/tools/gn/analyzer.cc
+++ b/tools/gn/analyzer.cc
@@ -395,7 +395,9 @@
void Analyzer::AddTargetsDirectlyReferringToFileTo(const SourceFile* file,
TargetSet* matches) const {
for (auto* target : all_targets_) {
- if (TargetRefersToFile(target, file))
+ // Only handles targets in the default toolchain.
+ if ((target->label().GetToolchainLabel() == default_toolchain_) &&
+ TargetRefersToFile(target, file))
matches->insert(target);
}
}