Search in sources :

Example 1 with ActionLookupKey

use of com.google.devtools.build.lib.skyframe.ActionLookupValue.ActionLookupKey in project bazel by bazelbuild.

the class CppCompileAction method discoverInputsStage2.

@Override
public Iterable<Artifact> discoverInputsStage2(SkyFunction.Environment env) throws ActionExecutionException, InterruptedException {
    if (this.usedModules == null) {
        return null;
    }
    Map<Artifact, SkyKey> skyKeys = new HashMap<>();
    for (Artifact artifact : this.usedModules) {
        skyKeys.put(artifact, ActionLookupValue.key((ActionLookupKey) artifact.getArtifactOwner()));
    }
    Map<SkyKey, SkyValue> skyValues = env.getValues(skyKeys.values());
    Set<Artifact> additionalModules = Sets.newLinkedHashSet();
    for (Artifact artifact : this.usedModules) {
        SkyKey skyKey = skyKeys.get(artifact);
        ActionLookupValue value = (ActionLookupValue) skyValues.get(skyKey);
        Preconditions.checkNotNull(value, "Owner %s of %s not in graph %s", artifact.getArtifactOwner(), artifact, skyKey);
        CppCompileAction action = (CppCompileAction) value.getGeneratingAction(artifact);
        for (Artifact input : action.getInputs()) {
            if (CppFileTypes.CPP_MODULE.matches(input.getFilename())) {
                additionalModules.add(input);
            }
        }
    }
    ImmutableSet.Builder<Artifact> topLevelModules = ImmutableSet.builder();
    for (Artifact artifact : this.usedModules) {
        if (!additionalModules.contains(artifact)) {
            topLevelModules.add(artifact);
        }
    }
    this.topLevelModules = topLevelModules.build();
    this.additionalInputs = new ImmutableList.Builder<Artifact>().addAll(this.additionalInputs).addAll(additionalModules).build();
    this.usedModules = null;
    return additionalModules;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) Artifact(com.google.devtools.build.lib.actions.Artifact) SkyValue(com.google.devtools.build.skyframe.SkyValue) ImmutableSet(com.google.common.collect.ImmutableSet) ActionLookupValue(com.google.devtools.build.lib.skyframe.ActionLookupValue) ActionLookupKey(com.google.devtools.build.lib.skyframe.ActionLookupValue.ActionLookupKey)

Example 2 with ActionLookupKey

use of com.google.devtools.build.lib.skyframe.ActionLookupValue.ActionLookupKey in project bazel by bazelbuild.

the class ArtifactFunction method extractActionFromArtifact.

private static ActionAnalysisMetadata extractActionFromArtifact(Artifact artifact, SkyFunction.Environment env) throws InterruptedException {
    ArtifactOwner artifactOwner = artifact.getArtifactOwner();
    Preconditions.checkState(artifactOwner instanceof ActionLookupKey, "", artifact, artifactOwner);
    SkyKey actionLookupKey = ActionLookupValue.key((ActionLookupKey) artifactOwner);
    ActionLookupValue value = (ActionLookupValue) env.getValue(actionLookupKey);
    if (value == null) {
        Preconditions.checkState(artifactOwner == CoverageReportValue.ARTIFACT_OWNER, "Not-yet-present artifact owner: %s", artifactOwner);
        return null;
    }
    // The value should already exist (except for the coverage report action output artifacts):
    // ConfiguredTargetValues were created during the analysis phase, and BuildInfo*Values
    // were created during the first analysis of a configured target.
    Preconditions.checkNotNull(value, "Owner %s of %s not in graph %s", artifactOwner, artifact, actionLookupKey);
    ActionAnalysisMetadata action = value.getGeneratingAction(artifact);
    if (artifact.hasParent()) {
        // generating action for its parent TreeArtifact, which contains this TreeFileArtifact.
        if (action == null) {
            action = value.getGeneratingAction(artifact.getParent());
        }
    }
    return Preconditions.checkNotNull(action, "Value %s does not contain generating action of %s", value, artifact);
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) ArtifactOwner(com.google.devtools.build.lib.actions.ArtifactOwner) ActionAnalysisMetadata(com.google.devtools.build.lib.actions.ActionAnalysisMetadata) ActionLookupKey(com.google.devtools.build.lib.skyframe.ActionLookupValue.ActionLookupKey)

Aggregations

ActionLookupKey (com.google.devtools.build.lib.skyframe.ActionLookupValue.ActionLookupKey)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ActionAnalysisMetadata (com.google.devtools.build.lib.actions.ActionAnalysisMetadata)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 ArtifactOwner (com.google.devtools.build.lib.actions.ArtifactOwner)1 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)1 ActionLookupValue (com.google.devtools.build.lib.skyframe.ActionLookupValue)1 SkyValue (com.google.devtools.build.skyframe.SkyValue)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1