use of com.google.devtools.build.lib.actions.ActionAnalysisMetadata 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);
}
use of com.google.devtools.build.lib.actions.ActionAnalysisMetadata in project bazel by bazelbuild.
the class ConfiguredTargetFunction method createConfiguredTarget.
@Nullable
private ConfiguredTargetValue createConfiguredTarget(SkyframeBuildView view, Environment env, Target target, BuildConfiguration configuration, OrderedSetMultimap<Attribute, ConfiguredTarget> depValueMap, ImmutableMap<Label, ConfigMatchingProvider> configConditions, NestedSetBuilder<Package> transitivePackages) throws ConfiguredTargetFunctionException, InterruptedException {
StoredEventHandler events = new StoredEventHandler();
BuildConfiguration ownerConfig = (configuration == null) ? null : configuration.getArtifactOwnerConfiguration();
CachingAnalysisEnvironment analysisEnvironment = view.createAnalysisEnvironment(new ConfiguredTargetKey(target.getLabel(), ownerConfig), false, events, env, configuration);
if (env.valuesMissing()) {
return null;
}
Preconditions.checkNotNull(depValueMap);
ConfiguredTarget configuredTarget = view.createConfiguredTarget(target, configuration, analysisEnvironment, depValueMap, configConditions);
events.replayOn(env.getListener());
if (events.hasErrors()) {
analysisEnvironment.disable(target);
throw new ConfiguredTargetFunctionException(new ConfiguredValueCreationException("Analysis of target '" + target.getLabel() + "' failed; build aborted", target.getLabel()));
}
Preconditions.checkState(!analysisEnvironment.hasErrors(), "Analysis environment hasError() but no errors reported");
if (env.valuesMissing()) {
return null;
}
analysisEnvironment.disable(target);
Preconditions.checkNotNull(configuredTarget, target);
ImmutableMap<Artifact, ActionAnalysisMetadata> generatingActions;
// rule implementation).
try {
generatingActions = Actions.filterSharedActionsAndThrowActionConflict(analysisEnvironment.getRegisteredActions());
} catch (ActionConflictException e) {
throw new ConfiguredTargetFunctionException(e);
}
return new ConfiguredTargetValue(configuredTarget, generatingActions, transitivePackages.build());
}
use of com.google.devtools.build.lib.actions.ActionAnalysisMetadata in project bazel by bazelbuild.
the class CrosstoolCompilationSupport method registerHeaderScanningActions.
private void registerHeaderScanningActions(Info info, ObjcProvider objcProvider, CompilationArtifacts compilationArtifacts) {
// PIC is not used for Obj-C builds, if that changes this method will need to change
if (!isHeaderThinningEnabled() || info.getCcCompilationOutputs().getObjectFiles(false).isEmpty()) {
return;
}
ImmutableList.Builder<ObjcHeaderThinningInfo> headerThinningInfos = ImmutableList.builder();
AnalysisEnvironment analysisEnvironment = ruleContext.getAnalysisEnvironment();
for (Artifact objectFile : info.getCcCompilationOutputs().getObjectFiles(false)) {
ActionAnalysisMetadata generatingAction = analysisEnvironment.getLocalGeneratingAction(objectFile);
if (generatingAction instanceof CppCompileAction) {
CppCompileAction action = (CppCompileAction) generatingAction;
Artifact sourceFile = action.getSourceFile();
if (!sourceFile.isTreeArtifact() && SOURCES_FOR_HEADER_THINNING.matches(sourceFile.getFilename())) {
headerThinningInfos.add(new ObjcHeaderThinningInfo(sourceFile, intermediateArtifacts.headersListFile(sourceFile), action.getCompilerOptions()));
}
}
}
registerHeaderScanningActions(headerThinningInfos.build(), objcProvider, compilationArtifacts);
}
use of com.google.devtools.build.lib.actions.ActionAnalysisMetadata in project bazel by bazelbuild.
the class BuildViewTestCase method getGeneratingAction.
protected final Action getGeneratingAction(Artifact artifact) {
Preconditions.checkNotNull(artifact);
ActionAnalysisMetadata action = mutableActionGraph.getGeneratingAction(artifact);
if (action == null) {
action = getActionGraph().getGeneratingAction(artifact);
}
if (action != null) {
Preconditions.checkState(action instanceof Action, "%s is not a proper Action object", action.prettyPrint());
return (Action) action;
} else {
return null;
}
}
use of com.google.devtools.build.lib.actions.ActionAnalysisMetadata in project bazel by bazelbuild.
the class AnalysisTestCase method getGeneratingAction.
protected Action getGeneratingAction(Artifact artifact) {
ensureUpdateWasCalled();
ActionAnalysisMetadata action = analysisResult.getActionGraph().getGeneratingAction(artifact);
if (action != null) {
Preconditions.checkState(action instanceof Action, "%s is not a proper Action object", action.prettyPrint());
return (Action) action;
} else {
return null;
}
}
Aggregations