Make aspects support SkylarkApiProviders.
These are initialised with a TransitiveInfoCollection, which aspects do not implement. By fiddling with the interfaces we can pull out a ProviderCollection which is sufficient for a SkylarkApiProvider to operate.
RELNOTES: None
PiperOrigin-RevId: 215441598
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAspect.java b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAspect.java
index a87bdde..5c01533 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAspect.java
@@ -26,6 +26,7 @@
import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException;
+import com.google.devtools.build.lib.analysis.skylark.SkylarkApiProvider;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
@@ -76,6 +77,14 @@
this.actions = actions;
this.generatingActionIndex = generatingActionIndex;
this.providers = providers;
+
+ // Initialize every SkylarkApiProvider
+ for (int i = 0; i < providers.getProviderCount(); i++) {
+ Object obj = providers.getProviderInstanceAt(i);
+ if (obj instanceof SkylarkApiProvider) {
+ ((SkylarkApiProvider) obj).init(providers);
+ }
+ }
}
/**
@@ -125,14 +134,14 @@
}
public InfoInterface get(Provider.Key key) {
- return providers.getProvider(key);
+ return providers.get(key);
}
public Object get(String legacyKey) {
if (OutputGroupInfo.SKYLARK_NAME.equals(legacyKey)) {
return get(OutputGroupInfo.SKYLARK_CONSTRUCTOR.getKey());
}
- return providers.getProvider(legacyKey);
+ return providers.get(legacyKey);
}
public static ConfiguredAspect forAlias(ConfiguredAspect real) {