[Skymeld] Make RemoteModule compatible with Skymeld
... by incrementally parsing the NoCacheOutputs of ConfiguredTargets as they
come, instead of once at the end of analysis.
This is a no-op for non-Skymeld code path.
@@ -703,35 +703,65 @@ public final class RemoteModule extends BlazeModule {
remoteExecutionCode));
}
+ // This is a Skymeld-only code path. At the same time, afterAnalysis is exclusive to the
+ // non-Skymeld code path.
+ @Override
+ public void afterTopLevelTargetAnalysis(
+ CommandEnvironment env,
+ BuildRequest request,
+ BuildOptions buildOptions,
+ ConfiguredTarget configuredTarget) {
+ if (shouldParseNoCacheOutputs()) {
+ parseNoCacheOutputsFromSingleConfiguredTarget(
+ Preconditions.checkNotNull(buildEventArtifactUploaderFactoryDelegate.get()),
+ configuredTarget);
+ }
+ }
+
@Override
public void afterAnalysis(
CommandEnvironment env,
BuildRequest request,
BuildOptions buildOptions,
AnalysisResult analysisResult) {
- if (remoteOptions != null
- && remoteOptions.remoteBuildEventUploadMode == RemoteBuildEventUploadMode.ALL
- && remoteOptions.incompatibleRemoteBuildEventUploadRespectNoCache) {
+ if (shouldParseNoCacheOutputs()) {
parseNoCacheOutputs(analysisResult);
}
}
- private void parseNoCacheOutputs(AnalysisResult analysisResult) {
+ // Separating the conditions for readability.
+ private boolean shouldParseNoCacheOutputs() {
+ if (remoteOptions == null
+ || remoteOptions.remoteBuildEventUploadMode != RemoteBuildEventUploadMode.ALL
+ || !remoteOptions.incompatibleRemoteBuildEventUploadRespectNoCache) {
+ return false;
+ }
+
if (actionContextProvider == null || actionContextProvider.getRemoteCache() == null) {
- return;
+ return false;
}
- ByteStreamBuildEventArtifactUploader uploader = buildEventArtifactUploaderFactoryDelegate.get();
- if (uploader == null) {
- return;
+ return buildEventArtifactUploaderFactoryDelegate.get() != null;
}
+ private void parseNoCacheOutputs(AnalysisResult analysisResult) {
+ ByteStreamBuildEventArtifactUploader uploader =
+ Preconditions.checkNotNull(buildEventArtifactUploaderFactoryDelegate.get());
+
for (ConfiguredTarget configuredTarget : analysisResult.getTargetsToBuild()) {
+ parseNoCacheOutputsFromSingleConfiguredTarget(uploader, configuredTarget);
+ }
+ }
+
+ private void parseNoCacheOutputsFromSingleConfiguredTarget(
+ ByteStreamBuildEventArtifactUploader uploader, ConfiguredTarget configuredTarget) {
// This will either dereference an alias chain, or return the final ConfiguredTarget.
- configuredTarget = configuredTarget.getActual();
+ ConfiguredTarget actualConfiguredTarget = configuredTarget.getActual();
+ if (!(actualConfiguredTarget instanceof RuleConfiguredTarget)) {
+ return;
+ }
- if (configuredTarget instanceof RuleConfiguredTarget) {
- RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) configuredTarget;
+ RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) actualConfiguredTarget;
for (ActionAnalysisMetadata action : ruleConfiguredTarget.getActions()) {
boolean uploadLocalResults =
Utils.shouldUploadLocalResultsToRemoteCache(remoteOptions, action.getExecutionInfo());
@@ -746,8 +776,6 @@ public final class RemoteModule extends BlazeModule {
}
}
}
- }
- }
private static void cleanAndCreateRemoteLogsDir(Path logDir) throws AbruptExitException {
try {
