Search in sources :

Example 6 with ConfiguredAspect

use of com.google.devtools.build.lib.analysis.ConfiguredAspect in project bazel by bazelbuild.

the class SkylarkAspectFactory method createAspect.

private ConfiguredAspect createAspect(Object aspectSkylarkObject, AspectDescriptor aspectDescriptor, RuleContext ruleContext) throws EvalException {
    ConfiguredAspect.Builder builder = new ConfiguredAspect.Builder(aspectDescriptor, ruleContext);
    if (aspectSkylarkObject instanceof Iterable) {
        addDeclaredProviders(builder, (Iterable) aspectSkylarkObject);
    } else {
        SkylarkClassObject struct = (SkylarkClassObject) aspectSkylarkObject;
        Location loc = struct.getCreationLoc();
        for (String key : struct.getKeys()) {
            if (key.equals("output_groups")) {
                addOutputGroups(struct.getValue(key), loc, builder);
            } else if (key.equals("providers")) {
                Object value = struct.getValue(key);
                Iterable providers = SkylarkType.cast(value, Iterable.class, loc, "The value for \"providers\" should be a list of declared providers, " + "got %s instead", EvalUtils.getDataTypeName(value, false));
                addDeclaredProviders(builder, providers);
            } else {
                builder.addSkylarkTransitiveInfo(key, struct.getValue(key), loc);
            }
        }
    }
    ConfiguredAspect configuredAspect = builder.build();
    SkylarkProviderValidationUtil.checkOrphanArtifacts(ruleContext);
    return configuredAspect;
}
Also used : ConfiguredAspect(com.google.devtools.build.lib.analysis.ConfiguredAspect) SkylarkRuleConfiguredTargetBuilder(com.google.devtools.build.lib.rules.SkylarkRuleConfiguredTargetBuilder) SkylarkClassObject(com.google.devtools.build.lib.packages.SkylarkClassObject) SkylarkClassObject(com.google.devtools.build.lib.packages.SkylarkClassObject) Location(com.google.devtools.build.lib.events.Location)

Example 7 with ConfiguredAspect

use of com.google.devtools.build.lib.analysis.ConfiguredAspect in project bazel by bazelbuild.

the class AndroidStudioInfoAspect method create.

@Override
public ConfiguredAspect create(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) {
    ConfiguredAspect.Builder builder = new Builder(this, parameters, ruleContext);
    AndroidStudioInfoFilesProvider.Builder providerBuilder = new AndroidStudioInfoFilesProvider.Builder();
    DependenciesResult dependenciesResult = processDependencies(base, ruleContext, providerBuilder);
    AndroidStudioInfoFilesProvider provider = createIdeBuildArtifact(base, ruleContext, dependenciesResult, providerBuilder);
    NestedSetBuilder<Artifact> ideCompileArtifacts = NestedSetBuilder.stableOrder();
    // Add artifacts required for compilation
    OutputGroupProvider outputGroupProvider = base.getProvider(OutputGroupProvider.class);
    if (outputGroupProvider != null) {
        ideCompileArtifacts.addTransitive(outputGroupProvider.getOutputGroup(OutputGroupProvider.FILES_TO_COMPILE));
    }
    builder.addOutputGroup(IDE_INFO, provider.getIdeInfoFiles()).addOutputGroup(IDE_INFO_TEXT, provider.getIdeInfoTextFiles()).addOutputGroup(IDE_RESOLVE, provider.getIdeResolveFiles()).addOutputGroup(IDE_COMPILE, ideCompileArtifacts.build()).addProvider(provider);
    return builder.build();
}
Also used : ConfiguredAspect(com.google.devtools.build.lib.analysis.ConfiguredAspect) OutputGroupProvider(com.google.devtools.build.lib.analysis.OutputGroupProvider) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) Builder(com.google.devtools.build.lib.analysis.ConfiguredAspect.Builder) Builder(com.google.devtools.build.lib.analysis.ConfiguredAspect.Builder) Artifact(com.google.devtools.build.lib.actions.Artifact) LibraryArtifact(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)

Example 8 with ConfiguredAspect

use of com.google.devtools.build.lib.analysis.ConfiguredAspect in project bazel by bazelbuild.

the class JackAspect method create.

@Override
public ConfiguredAspect create(ConfiguredTarget base, RuleContext ruleContext, AspectParameters params) {
    if (base.getProvider(JackLibraryProvider.class) != null) {
        return new ConfiguredAspect.Builder(this, params, ruleContext).build();
    }
    JavaSourceInfoProvider sourceProvider = base.getProvider(JavaSourceInfoProvider.class);
    PathFragment rulePath = ruleContext.getLabel().toPathFragment();
    PathFragment jackLibraryPath = rulePath.replaceName("lib" + rulePath.getBaseName() + ".jack");
    Artifact jackLibraryOutput = ruleContext.getAnalysisEnvironment().getDerivedArtifact(jackLibraryPath, ruleContext.getBinOrGenfilesDirectory());
    if (!AndroidSdkProvider.verifyPresence(ruleContext)) {
        return null;
    }
    AndroidSdkProvider androidSdk = AndroidSdkProvider.fromRuleContext(ruleContext);
    JackCompilationHelper jackHelper = new JackCompilationHelper.Builder().setRuleContext(ruleContext).setOutputArtifact(jackLibraryOutput).setJackBinary(androidSdk.getJack()).setJillBinary(androidSdk.getJill()).setResourceExtractorBinary(androidSdk.getResourceExtractor()).setJackBaseClasspath(androidSdk.getJavaBaseClasspathForJack()).addJavaSources(sourceProvider.getSourceFiles()).addSourceJars(sourceProvider.getSourceJars()).addCompiledJars(sourceProvider.getJarFiles()).addResources(sourceProvider.getResources()).addProcessorNames(sourceProvider.getProcessorNames()).addProcessorClasspathJars(sourceProvider.getProcessorPath()).addExports(getPotentialDependency(ruleContext, "exports")).addDeps(getPotentialDependency(ruleContext, "deps")).addRuntimeDeps(getPotentialDependency(ruleContext, "runtime_deps")).build();
    JackLibraryProvider result = JavaCommon.isNeverLink(ruleContext) ? jackHelper.compileAsNeverlinkLibrary() : jackHelper.compileAsLibrary();
    return new ConfiguredAspect.Builder(this, params, ruleContext).addProvider(result).build();
}
Also used : ConfiguredAspect(com.google.devtools.build.lib.analysis.ConfiguredAspect) JavaSourceInfoProvider(com.google.devtools.build.lib.rules.java.JavaSourceInfoProvider) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 9 with ConfiguredAspect

use of com.google.devtools.build.lib.analysis.ConfiguredAspect in project bazel by bazelbuild.

the class CcProtoAspect method create.

@Override
public ConfiguredAspect create(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException {
    // Get SupportData, which is provided by the proto_library rule we attach to.
    SupportData supportData = checkNotNull(base.getProvider(ProtoSupportDataProvider.class)).getSupportData();
    try {
        ConfiguredAspect.Builder result = new ConfiguredAspect.Builder(this, parameters, ruleContext);
        new Impl(ruleContext, supportData, cppSemantics).addProviders(result);
        return result.build();
    } catch (RuleErrorException e) {
        ruleContext.ruleError(e.getMessage());
        return null;
    }
}
Also used : ConfiguredAspect(com.google.devtools.build.lib.analysis.ConfiguredAspect) RuleErrorException(com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException) SupportData(com.google.devtools.build.lib.rules.proto.SupportData) ProtoCompileActionBuilder(com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)

Example 10 with ConfiguredAspect

use of com.google.devtools.build.lib.analysis.ConfiguredAspect in project bazel by bazelbuild.

the class JavaProtoAspect method create.

@Override
public ConfiguredAspect create(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException {
    ConfiguredAspect.Builder aspect = new ConfiguredAspect.Builder(this, parameters, ruleContext);
    if (!rpcSupport.checkAttributes(ruleContext, parameters)) {
        return aspect.build();
    }
    // Get SupportData, which is provided by the proto_library rule we attach to.
    SupportData supportData = checkNotNull(base.getProvider(ProtoSupportDataProvider.class)).getSupportData();
    Impl impl = new Impl(ruleContext, supportData, javaSemantics, rpcSupport);
    if (impl.shouldGenerateCode() && ActionReuser.reuseExistingActions(base, ruleContext, aspect)) {
        return aspect.build();
    }
    impl.addProviders(aspect);
    return aspect.build();
}
Also used : ConfiguredAspect(com.google.devtools.build.lib.analysis.ConfiguredAspect) SupportData(com.google.devtools.build.lib.rules.proto.SupportData) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) ProtoCompileActionBuilder(com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder)

Aggregations

ConfiguredAspect (com.google.devtools.build.lib.analysis.ConfiguredAspect)12 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)5 Artifact (com.google.devtools.build.lib.actions.Artifact)4 ProtoCompileActionBuilder (com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder)4 SupportData (com.google.devtools.build.lib.rules.proto.SupportData)3 RuleErrorException (com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)2 SkyKey (com.google.devtools.build.skyframe.SkyKey)2 HashSet (java.util.HashSet)2 Nullable (javax.annotation.Nullable)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 AspectDeps (com.google.devtools.build.lib.analysis.AspectCollection.AspectDeps)1 CachingAnalysisEnvironment (com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment)1 Builder (com.google.devtools.build.lib.analysis.ConfiguredAspect.Builder)1 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 Dependency (com.google.devtools.build.lib.analysis.Dependency)1 MergedConfiguredTarget (com.google.devtools.build.lib.analysis.MergedConfiguredTarget)1 OutputGroupProvider (com.google.devtools.build.lib.analysis.OutputGroupProvider)1 NestedSet (com.google.devtools.build.lib.collect.nestedset.NestedSet)1 Location (com.google.devtools.build.lib.events.Location)1