Redefine --nohost_deps to exclude exec transitions as well as host transitions.
Rename the NO_HOST_DEPS Setting enum value and DependencyFilter to ONLY_TARGET_DEPS, to reflect better what it is supposed to do.
Work towards https://github.com/bazelbuild/bazel/issues/8976.
PiperOrigin-RevId: 267372015
diff --git a/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java
index 038e4cc..45916b0 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/PostAnalysisQueryEnvironment.java
@@ -176,7 +176,7 @@
|| settings.contains(Setting.TESTS_EXPRESSION_STRICT)) {
settings =
Sets.difference(
- settings, ImmutableSet.of(Setting.NO_HOST_DEPS, Setting.NO_IMPLICIT_DEPS));
+ settings, ImmutableSet.of(Setting.ONLY_TARGET_DEPS, Setting.NO_IMPLICIT_DEPS));
throw new QueryException(
String.format(
"The following filter(s) are not currently supported by configured query: %s",
@@ -326,15 +326,15 @@
// cases if --nohost_deps is turned on, we only allow reachable targets that are ALSO in the
// host config. This is somewhat counterintuitive and subject to change in the future but seems
// like the best option right now.
- if (settings.contains(Setting.NO_HOST_DEPS)) {
+ if (settings.contains(Setting.ONLY_TARGET_DEPS)) {
BuildConfiguration currentConfig = getConfiguration(target);
- if (currentConfig != null && currentConfig.isHostConfiguration()) {
+ if (currentConfig != null && currentConfig.isToolConfiguration()) {
deps =
deps.stream()
.filter(
dep ->
getConfiguration(dep) != null
- && getConfiguration(dep).isHostConfiguration())
+ && getConfiguration(dep).isToolConfiguration())
.collect(Collectors.toList());
} else {
deps =
@@ -342,7 +342,7 @@
.filter(
dep ->
getConfiguration(dep) != null
- && !getConfiguration(dep).isHostConfiguration())
+ && !getConfiguration(dep).isToolConfiguration())
.collect(Collectors.toList());
}
}