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;
}
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);
}
Aggregations