aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index 4dc14788e7..e76990c04a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -367,7 +367,7 @@ public final class SkyframeActionExecutor {
*
* <p>For use from {@link ArtifactFunction} only.
*/
- ActionExecutionValue executeAction(Action action, FileAndMetadataCache graphFileCache,
+ ActionExecutionValue executeAction(Action action, ActionMetadataHandler metadataHandler,
long actionStartTime,
ActionExecutionContext actionExecutionContext)
throws ActionExecutionException, InterruptedException {
@@ -378,7 +378,7 @@ public final class SkyframeActionExecutor {
}
Artifact primaryOutput = action.getPrimaryOutput();
FutureTask<ActionExecutionValue> actionTask =
- new FutureTask<>(new ActionRunner(action, graphFileCache,
+ new FutureTask<>(new ActionRunner(action, metadataHandler,
actionStartTime, actionExecutionContext));
// Check to see if another action is already executing/has executed this value.
Pair<Action, FutureTask<ActionExecutionValue>> oldAction =
@@ -418,33 +418,40 @@ public final class SkyframeActionExecutor {
}
}
+ private static class MiddlemanExpanderImpl implements MiddlemanExpander {
+ private final Map<Artifact, Collection<Artifact>> expandedInputMiddlemen;
+
+ private MiddlemanExpanderImpl(Map<Artifact, Collection<Artifact>> expandedInputMiddlemen) {
+ this.expandedInputMiddlemen = expandedInputMiddlemen;
+ }
+
+ @Override
+ public void expand(Artifact middlemanArtifact, Collection<? super Artifact> output) {
+ Preconditions.checkState(middlemanArtifact.isMiddlemanArtifact(), middlemanArtifact);
+ Collection<Artifact> result = expandedInputMiddlemen.get(middlemanArtifact);
+ // Note that result may be null for non-aggregating middlemen.
+ if (result != null) {
+ output.addAll(result);
+ }
+ }
+ }
+
/**
* Returns an ActionExecutionContext suitable for executing a particular action. The caller should
* pass the returned context to {@link #executeAction}, and any other method that needs to execute
* tasks related to that action.
*/
ActionExecutionContext constructActionExecutionContext(
- final FileAndMetadataCache graphFileCache) {
+ PerActionFileCache graphFileCache, MetadataHandler metadataHandler,
+ Map<Artifact, Collection<Artifact>> expandedInputMiddlemen) {
// TODO(bazel-team): this should be closed explicitly somewhere.
FileOutErr fileOutErr = actionLogBufferPathGenerator.generate();
return new ActionExecutionContext(
executorEngine,
new DelegatingPairFileCache(graphFileCache, perBuildFileCache),
- graphFileCache,
+ metadataHandler,
fileOutErr,
- new MiddlemanExpander() {
- @Override
- public void expand(Artifact middlemanArtifact,
- Collection<? super Artifact> output) {
- // Legacy code is more permissive regarding "mm" in that it expands any middleman,
- // not just inputs of this action. Skyframe doesn't have access to a global action
- // graph, therefore this implementation can't expand any middleman, only the
- // inputs of this action.
- // This is fine though: actions should only hold references to their input
- // artifacts, otherwise hermeticity would be violated.
- output.addAll(graphFileCache.expandInputMiddleman(middlemanArtifact));
- }
- });
+ new MiddlemanExpanderImpl(expandedInputMiddlemen));
}
/**
@@ -542,15 +549,15 @@ public final class SkyframeActionExecutor {
private class ActionRunner implements Callable<ActionExecutionValue> {
private final Action action;
- private final FileAndMetadataCache graphFileCache;
+ private final ActionMetadataHandler metadataHandler;
private long actionStartTime;
private ActionExecutionContext actionExecutionContext;
- ActionRunner(Action action, FileAndMetadataCache graphFileCache,
+ ActionRunner(Action action, ActionMetadataHandler metadataHandler,
long actionStartTime,
ActionExecutionContext actionExecutionContext) {
this.action = action;
- this.graphFileCache = graphFileCache;
+ this.metadataHandler = metadataHandler;
this.actionStartTime = actionStartTime;
this.actionExecutionContext = actionExecutionContext;
}
@@ -580,7 +587,7 @@ public final class SkyframeActionExecutor {
prepareScheduleExecuteAndCompleteAction(action, actionExecutionContext, actionStartTime);
return new ActionExecutionValue(
- graphFileCache.getOutputData(), graphFileCache.getAdditionalOutputData());
+ metadataHandler.getOutputData(), metadataHandler.getAdditionalOutputData());
} finally {
profiler.completeTask(ProfilerTask.ACTION);
}