aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java
index 8ff1716644..776a84e28e 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/ConfiguredTargetQueryEnvironment.java
@@ -105,7 +105,7 @@ public class ConfiguredTargetQueryEnvironment
protected WalkableGraph graph;
private static final Function<ConfiguredTarget, SkyKey> CT_TO_SKYKEY =
- target -> ConfiguredTargetValue.key(target.getLabel(), target.getConfiguration());
+ target -> ConfiguredTargetValue.key(getCorrectLabel(target), target.getConfiguration());
private static final Function<SkyKey, ConfiguredTargetKey> SKYKEY_TO_CTKEY =
skyKey -> (ConfiguredTargetKey) skyKey.argument();
private static final ImmutableList<TargetPatternKey> ALL_PATTERNS;
@@ -175,6 +175,17 @@ public class ConfiguredTargetQueryEnvironment
return ImmutableList.of(new ConfigFunction());
}
+ /**
+ * This method has to exist because {@link AliasConfiguredTarget#getLabel()} returns
+ * the label of the "actual" target instead of the alias target. Grr.
+ */
+ public static Label getCorrectLabel(ConfiguredTarget target) {
+ if (target instanceof AliasConfiguredTarget) {
+ return ((AliasConfiguredTarget) target).getOriginalLabel();
+ }
+ return target.getLabel();
+ }
+
// Check to make sure the settings requested are currently supported by this class
private void checkSettings(Set<Setting> settings) throws QueryException {
if (settings.contains(Setting.NO_NODEP_DEPS)
@@ -319,7 +330,7 @@ public class ConfiguredTargetQueryEnvironment
public Void call() throws QueryException, InterruptedException {
List<ConfiguredTarget> transformedResult = new ArrayList<>();
for (ConfiguredTarget target : targets) {
- Label label = target.getLabel();
+ Label label = getCorrectLabel(target);
ConfiguredTarget configuredTarget;
switch (configuration) {
case "\'host\'":
@@ -379,10 +390,6 @@ public class ConfiguredTargetQueryEnvironment
if (settings.isEmpty()) {
return rawFwdDeps;
}
- if (configTarget instanceof AliasConfiguredTarget
- && ((AliasConfiguredTarget) configTarget).getActual() instanceof RuleConfiguredTarget) {
- return getAllowedDeps(((AliasConfiguredTarget) configTarget).getActual(), rawFwdDeps);
- }
return getAllowedDeps(configTarget, rawFwdDeps);
}
@@ -424,7 +431,7 @@ public class ConfiguredTargetQueryEnvironment
dep ->
!implicitDeps.contains(
ConfiguredTargetKey.of(
- dep.getLabel(), dep.getConfiguration())))
+ getCorrectLabel(dep), dep.getConfiguration())))
.collect(Collectors.toList());
}
return deps;