Search in sources :

Example 1 with PackageSpecification

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());
    }
}
Also used : OutputFile(com.google.devtools.build.lib.packages.OutputFile) Artifact(com.google.devtools.build.lib.actions.Artifact) PackageGroup(com.google.devtools.build.lib.packages.PackageGroup) InputFile(com.google.devtools.build.lib.packages.InputFile) EnvironmentGroup(com.google.devtools.build.lib.packages.EnvironmentGroup) Rule(com.google.devtools.build.lib.packages.Rule) ConfiguredTargetKey(com.google.devtools.build.lib.skyframe.ConfiguredTargetKey) PackageSpecification(com.google.devtools.build.lib.packages.PackageSpecification) Nullable(javax.annotation.Nullable)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)1 EnvironmentGroup (com.google.devtools.build.lib.packages.EnvironmentGroup)1 InputFile (com.google.devtools.build.lib.packages.InputFile)1 OutputFile (com.google.devtools.build.lib.packages.OutputFile)1 PackageGroup (com.google.devtools.build.lib.packages.PackageGroup)1 PackageSpecification (com.google.devtools.build.lib.packages.PackageSpecification)1 Rule (com.google.devtools.build.lib.packages.Rule)1 ConfiguredTargetKey (com.google.devtools.build.lib.skyframe.ConfiguredTargetKey)1 Nullable (javax.annotation.Nullable)1