aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-02-15 10:33:53 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-15 10:35:15 -0800
commitcb314a2e36031c8a5f1dd26bb3b94f1b8f1cb901 (patch)
treee04b828849bd9b5be4d4bc1dde67b46cf46de9d7 /src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
parent10b1a5fc3ade9c5f12078cd616218f9ef45ef13c (diff)
Stop storing ActionTemplate in a SkyKey: it's too heavyweight. Use the same mechanism as for normal actions, have the ActionTemplateExpansionFunction look the template up when needed.
PiperOrigin-RevId: 185861672
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
index 6e6e4321ea..5cef0fc2c6 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
@@ -29,12 +29,10 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;
import com.google.devtools.build.lib.actions.ArtifactOwner;
import com.google.devtools.build.lib.actions.MissingInputFileException;
-import com.google.devtools.build.lib.analysis.actions.ActionTemplate;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.util.Pair;
-import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionException;
@@ -84,26 +82,21 @@ class ArtifactFunction implements SkyFunction {
// If the action is an ActionTemplate, we need to expand the ActionTemplate into concrete
// actions, execute those actions in parallel and then aggregate the action execution results.
- if (artifact.isTreeArtifact()) {
- ActionAnalysisMetadata actionMetadata =
- actionLookupValue.getIfPresentAndNotAction(actionIndex);
- if (actionMetadata instanceof ActionTemplate) {
- // Create the directory structures for the output TreeArtifact first.
- try {
- FileSystemUtils.createDirectoryAndParents(artifact.getPath());
- } catch (IOException e) {
- env.getListener()
- .handle(
- Event.error(
- String.format(
- "Failed to create output directory for TreeArtifact %s: %s",
- artifact, e.getMessage())));
- throw new ArtifactFunctionException(e, Transience.TRANSIENT);
- }
-
- return createTreeArtifactValueFromActionTemplate(
- (ActionTemplate<?>) actionMetadata, artifact, env);
+ if (artifact.isTreeArtifact() && actionLookupValue.isActionTemplate(actionIndex)) {
+ // Create the directory structures for the output TreeArtifact first.
+ try {
+ artifact.getPath().createDirectoryAndParents();
+ } catch (IOException e) {
+ env.getListener()
+ .handle(
+ Event.error(
+ String.format(
+ "Failed to create output directory for TreeArtifact %s: %s",
+ artifact, e.getMessage())));
+ throw new ArtifactFunctionException(e, Transience.TRANSIENT);
}
+
+ return createTreeArtifactValueFromActionKey(actionLookupKey, actionIndex, artifact, env);
}
ActionExecutionValue actionValue =
(ActionExecutionValue) env.getValue(ActionExecutionValue.key(actionLookupKey, actionIndex));
@@ -133,12 +126,15 @@ class ArtifactFunction implements SkyFunction {
return createSimpleFileArtifactValue(artifact, actionValue);
}
- private static TreeArtifactValue createTreeArtifactValueFromActionTemplate(
- final ActionTemplate<?> actionTemplate, final Artifact treeArtifact, Environment env)
- throws InterruptedException {
+ private static TreeArtifactValue createTreeArtifactValueFromActionKey(
+ ActionLookupKey actionLookupKey,
+ int actionIndex,
+ final Artifact treeArtifact,
+ Environment env)
+ throws InterruptedException {
// Request the list of expanded actions from the ActionTemplate.
ActionTemplateExpansionValue.ActionTemplateExpansionKey templateKey =
- ActionTemplateExpansionValue.key(actionTemplate);
+ ActionTemplateExpansionValue.key(actionLookupKey, actionIndex);
ActionTemplateExpansionValue expansionValue =
(ActionTemplateExpansionValue) env.getValue(templateKey);
@@ -166,9 +162,10 @@ class ArtifactFunction implements SkyFunction {
(ActionExecutionValue)
Preconditions.checkNotNull(
expandedActionValueMap.get(expandedActionExecutionKeys.get(i)),
- "Missing tree value: %s %s %s %s",
+ "Missing tree value: %s %s %s %s %s",
treeArtifact,
- actionTemplate,
+ actionLookupKey,
+ actionIndex,
expansionValue,
expandedActionValueMap);
Iterable<TreeFileArtifact> treeFileArtifacts =
@@ -180,11 +177,12 @@ class ArtifactFunction implements SkyFunction {
public boolean apply(Artifact artifact) {
Preconditions.checkState(
artifact.hasParent(),
- "No parent: %s %s %s %s",
+ "No parent: %s %s %s %s %s",
artifact,
treeArtifact,
actionExecutionValue,
- actionTemplate);
+ actionLookupKey,
+ actionIndex);
return artifact.getParent().equals(treeArtifact);
}
}),