use of com.google.devtools.build.lib.packages.PackageSpecification in project bazel by bazelbuild.
the class ConfiguredTargetFactory method createConfiguredTarget.
/**
* Invokes the appropriate constructor to create a {@link ConfiguredTarget} instance.
* <p>For use in {@code ConfiguredTargetFunction}.
*
* <p>Returns null if Skyframe deps are missing or upon certain errors.
*/
@Nullable
public final ConfiguredTarget createConfiguredTarget(AnalysisEnvironment analysisEnvironment, ArtifactFactory artifactFactory, Target target, BuildConfiguration config, BuildConfiguration hostConfig, OrderedSetMultimap<Attribute, ConfiguredTarget> prerequisiteMap, ImmutableMap<Label, ConfigMatchingProvider> configConditions) throws InterruptedException {
if (target instanceof Rule) {
return createRule(analysisEnvironment, (Rule) target, config, hostConfig, prerequisiteMap, configConditions);
}
// Visibility, like all package groups, doesn't have a configuration
NestedSet<PackageSpecification> visibility = convertVisibility(prerequisiteMap, analysisEnvironment.getEventHandler(), target, null);
TargetContext targetContext = new TargetContext(analysisEnvironment, target, config, prerequisiteMap.get(null), visibility);
if (target instanceof OutputFile) {
OutputFile outputFile = (OutputFile) target;
boolean isFileset = outputFile.getGeneratingRule().getRuleClass().equals("Fileset");
Artifact artifact = getOutputArtifact(outputFile, config, isFileset, artifactFactory);
TransitiveInfoCollection rule = targetContext.findDirectPrerequisite(outputFile.getGeneratingRule().getLabel(), config);
if (isFileset) {
return new FilesetOutputConfiguredTarget(targetContext, outputFile, rule, artifact, rule.getProvider(FilesetProvider.class).getTraversals());
} else {
return new OutputFileConfiguredTarget(targetContext, outputFile, rule, artifact);
}
} else if (target instanceof InputFile) {
InputFile inputFile = (InputFile) target;
Artifact artifact = artifactFactory.getSourceArtifact(inputFile.getExecPath(), Root.asSourceRoot(inputFile.getPackage().getSourceRoot(), inputFile.getPackage().getPackageIdentifier().getRepository().isMain()), new ConfiguredTargetKey(target.getLabel(), config));
return new InputFileConfiguredTarget(targetContext, inputFile, artifact);
} else if (target instanceof PackageGroup) {
PackageGroup packageGroup = (PackageGroup) target;
return new PackageGroupConfiguredTarget(targetContext, packageGroup);
} else if (target instanceof EnvironmentGroup) {
return new EnvironmentGroupConfiguredTarget(targetContext, (EnvironmentGroup) target);
} else {
throw new AssertionError("Unexpected target class: " + target.getClass().getName());
}
}
Aggregations