Search in sources :

Example 1 with ActionTemplateExpansionKey

use of com.google.devtools.build.lib.skyframe.ActionTemplateExpansionValue.ActionTemplateExpansionKey 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

Action (com.google.devtools.build.lib.actions.Action)1 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)1 ArtifactPrefixConflictException (com.google.devtools.build.lib.actions.ArtifactPrefixConflictException)1 ActionConflictException (com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictException)1 ActionTemplate (com.google.devtools.build.lib.analysis.actions.ActionTemplate)1 ActionTemplateExpansionKey (com.google.devtools.build.lib.skyframe.ActionTemplateExpansionValue.ActionTemplateExpansionKey)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1