Search in sources :

Example 6 with ArtifactPrefixConflictException

use of com.google.devtools.build.lib.actions.ArtifactPrefixConflictException in project bazel by bazelbuild.

the class ActionTemplateExpansionFunction method compute.

@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws ActionTemplateExpansionFunctionException, InterruptedException {
    ActionTemplateExpansionKey key = (ActionTemplateExpansionKey) skyKey.argument();
    ActionTemplate actionTemplate = key.getActionTemplate();
    // Requests the TreeArtifactValue object for the input TreeArtifact.
    SkyKey artifactValueKey = ArtifactSkyKey.key(actionTemplate.getInputTreeArtifact(), true);
    TreeArtifactValue treeArtifactValue = (TreeArtifactValue) env.getValue(artifactValueKey);
    // Input TreeArtifact is not ready yet.
    if (env.valuesMissing()) {
        return null;
    }
    Iterable<TreeFileArtifact> inputTreeFileArtifacts = treeArtifactValue.getChildren();
    Iterable<Action> expandedActions;
    try {
        // Expand the action template using the list of expanded input TreeFileArtifacts.
        expandedActions = ImmutableList.<Action>copyOf(actionTemplate.generateActionForInputArtifacts(inputTreeFileArtifacts, key));
        // TODO(rduan): Add a check to verify the inputs of expanded actions are subsets of inputs
        // of the ActionTemplate.
        checkActionAndArtifactConflicts(expandedActions);
    } catch (ActionConflictException e) {
        e.reportTo(env.getListener());
        throw new ActionTemplateExpansionFunctionException(e);
    } catch (ArtifactPrefixConflictException e) {
        env.getListener().handle(Event.error(e.getMessage()));
        throw new ActionTemplateExpansionFunctionException(e);
    }
    return new ActionTemplateExpansionValue(expandedActions);
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) ActionConflictException(com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException) Action(com.google.devtools.build.lib.actions.Action) ActionTemplateExpansionKey(com.google.devtools.build.lib.skyframe.ActionTemplateExpansionValue.ActionTemplateExpansionKey) ActionTemplate(com.google.devtools.build.lib.analysis.actions.ActionTemplate) ArtifactPrefixConflictException(com.google.devtools.build.lib.actions.ArtifactPrefixConflictException)

Aggregations

ArtifactPrefixConflictException (com.google.devtools.build.lib.actions.ArtifactPrefixConflictException)6 Artifact (com.google.devtools.build.lib.actions.Artifact)4 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ActionAnalysisMetadata (com.google.devtools.build.lib.actions.ActionAnalysisMetadata)3 ActionConflictException (com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException)3 ActionInput (com.google.devtools.build.lib.actions.ActionInput)2 MutableActionGraph (com.google.devtools.build.lib.actions.MutableActionGraph)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 Map (java.util.Map)2 Action (com.google.devtools.build.lib.actions.Action)1 ActionExecutionException (com.google.devtools.build.lib.actions.ActionExecutionException)1 ActionGraph (com.google.devtools.build.lib.actions.ActionGraph)1 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)1 BaseSpawn (com.google.devtools.build.lib.actions.BaseSpawn)1 ExecException (com.google.devtools.build.lib.actions.ExecException)1 Executor (com.google.devtools.build.lib.actions.Executor)1 MapBasedActionGraph (com.google.devtools.build.lib.actions.MapBasedActionGraph)1 Spawn (com.google.devtools.build.lib.actions.Spawn)1