Add safety checks for aspects.
As aspects are not currently supported in retroactive trimming mode, these
checks ensure that they are not silently executed incorrectly.
Progress on #6524.
PiperOrigin-RevId: 244946454
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index bc1dff2..33d20e1 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -324,6 +324,11 @@
String skylarkFunctionName = aspect.substring(delimiterPosition + 1);
for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) {
+ if (targetSpec.getConfiguration() != null
+ && targetSpec.getConfiguration().trimConfigurationsRetroactively()) {
+ throw new ViewCreationFailedException(
+ "Aspects were requested, but are not supported in retroactive trimming mode.");
+ }
aspectConfigurations.put(
Pair.of(targetSpec.getLabel(), aspect), targetSpec.getConfiguration());
aspectKeys.add(
@@ -342,6 +347,11 @@
if (aspectFactoryClass != null) {
for (TargetAndConfiguration targetSpec : topLevelTargetsWithConfigs) {
+ if (targetSpec.getConfiguration() != null
+ && targetSpec.getConfiguration().trimConfigurationsRetroactively()) {
+ throw new ViewCreationFailedException(
+ "Aspects were requested, but are not supported in retroactive trimming mode.");
+ }
// For invoking top-level aspects, use the top-level configuration for both the
// aspect and the base target while the top-level configuration is untrimmed.
BuildConfiguration configuration = targetSpec.getConfiguration();