use of com.google.devtools.build.lib.skyframe.ArtifactSkyKey.OwnedArtifact in project bazel by bazelbuild.
the class ArtifactFunction method compute.
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws ArtifactFunctionException, InterruptedException {
OwnedArtifact ownedArtifact = (OwnedArtifact) skyKey.argument();
Artifact artifact = ownedArtifact.getArtifact();
if (artifact.isSourceArtifact()) {
try {
return createSourceValue(artifact, ownedArtifact.isMandatory(), env);
} catch (MissingInputFileException e) {
// is potentially used to report root causes.
throw new ArtifactFunctionException(e, Transience.TRANSIENT);
}
}
ActionAnalysisMetadata actionMetadata = extractActionFromArtifact(artifact, env);
if (actionMetadata == null) {
return null;
}
// actions, execute those actions in parallel and then aggregate the action execution results.
if (artifact.isTreeArtifact() && 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);
} else {
Preconditions.checkState(actionMetadata instanceof Action, "%s is not a proper Action object and therefore cannot be executed", actionMetadata);
Action action = (Action) actionMetadata;
ActionExecutionValue actionValue = (ActionExecutionValue) env.getValue(ActionExecutionValue.key(action));
if (actionValue == null) {
return null;
}
if (artifact.isTreeArtifact()) {
// TreeArtifactValue.
return Preconditions.checkNotNull(actionValue.getTreeArtifactValue(artifact), artifact);
} else if (isAggregatingValue(action)) {
return createAggregatingValue(artifact, action, actionValue.getArtifactValue(artifact), env);
} else {
return createSimpleFileArtifactValue(artifact, action, actionValue, env);
}
}
}
Aggregations