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