use of com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider in project bazel by bazelbuild.
the class AndroidStudioInfoAspect method createIdeBuildArtifact.
private AndroidStudioInfoFilesProvider createIdeBuildArtifact(ConfiguredTarget base, RuleContext ruleContext, DependenciesResult dependenciesResult, AndroidStudioInfoFilesProvider.Builder providerBuilder) {
Artifact ideInfoFile = derivedArtifact(base, ruleContext, ASWB_BUILD_SUFFIX);
Artifact ideInfoTextFile = derivedArtifact(base, ruleContext, ASWB_BUILD_TEXT_SUFFIX);
providerBuilder.ideInfoFilesBuilder().add(ideInfoFile);
providerBuilder.ideInfoTextFilesBuilder().add(ideInfoTextFile);
NestedSetBuilder<Artifact> ideResolveArtifacts = providerBuilder.ideResolveFilesBuilder();
TargetIdeInfo.Builder outputBuilder = TargetIdeInfo.newBuilder();
outputBuilder.setLabel(base.getLabel().toString());
outputBuilder.setBuildFileArtifactLocation(makeArtifactLocation(ruleContext.getRule().getPackage(), ruleContext.getLabel()));
outputBuilder.setKindString(ruleContext.getRule().getRuleClass());
// Java rules
JavaRuleOutputJarsProvider outputJarsProvider = JavaProvider.getProvider(JavaRuleOutputJarsProvider.class, base);
if (outputJarsProvider != null && !androidStudioInfoSemantics.suppressJavaRuleInfo(base)) {
JavaIdeInfo javaIdeInfo = makeJavaIdeInfo(base, ruleContext, outputJarsProvider, providerBuilder);
outputBuilder.setJavaIdeInfo(javaIdeInfo);
}
// C rules
if (isCppRule(base)) {
CppCompilationContext cppCompilationContext = base.getProvider(CppCompilationContext.class);
if (cppCompilationContext != null) {
CIdeInfo cIdeInfo = makeCIdeInfo(base, ruleContext, cppCompilationContext, ideResolveArtifacts);
outputBuilder.setCIdeInfo(cIdeInfo);
}
}
// CCToolchain rule
CcToolchainProvider ccToolchainProvider = base.getProvider(CcToolchainProvider.class);
if (ccToolchainProvider != null) {
CppConfiguration cppConfiguration = ccToolchainProvider.getCppConfiguration();
if (cppConfiguration != null) {
CToolchainIdeInfo cToolchainIdeInfo = makeCToolchainIdeInfo(ruleContext, cppConfiguration);
if (cToolchainIdeInfo != null) {
outputBuilder.setCToolchainIdeInfo(cToolchainIdeInfo);
}
}
}
// Android rules
AndroidIdeInfoProvider androidIdeInfoProvider = base.getProvider(AndroidIdeInfoProvider.class);
if (androidIdeInfoProvider != null) {
outputBuilder.setAndroidIdeInfo(makeAndroidIdeInfo(androidIdeInfoProvider, dependenciesResult, ideResolveArtifacts));
}
// Python rules
if (isPythonRule(base)) {
outputBuilder.setPyIdeInfo(makePyIdeInfo(base, ruleContext, ideResolveArtifacts));
}
// Test rules
if (TargetUtils.isTestRule(base.getTarget())) {
TestInfo.Builder builder = TestInfo.newBuilder();
String attr = NonconfigurableAttributeMapper.of(base.getTarget().getAssociatedRule()).get("size", Type.STRING);
if (attr != null) {
builder.setSize(attr);
}
outputBuilder.setTestInfo(builder);
}
// Java toolchain rule
JavaToolchainProvider javaToolchainProvider = base.getProvider(JavaToolchainProvider.class);
if (javaToolchainProvider != null) {
outputBuilder.setJavaToolchainIdeInfo(JavaToolchainIdeInfo.newBuilder().setSourceVersion(javaToolchainProvider.getSourceVersion()).setTargetVersion(javaToolchainProvider.getTargetVersion()));
}
androidStudioInfoSemantics.augmentRuleInfo(outputBuilder, base, ruleContext, ideResolveArtifacts);
AndroidStudioInfoFilesProvider provider = providerBuilder.build();
outputBuilder.addAllDependencies(transform(dependenciesResult.deps, LABEL_TO_STRING));
outputBuilder.addAllRuntimeDeps(transform(dependenciesResult.runtimeDeps, LABEL_TO_STRING));
outputBuilder.addAllTags(base.getTarget().getAssociatedRule().getRuleTags());
final TargetIdeInfo targetIdeInfo = outputBuilder.build();
ruleContext.registerAction(makeProtoWriteAction(ruleContext.getActionOwner(), targetIdeInfo, ideInfoFile));
ruleContext.registerAction(makeProtoTextWriteAction(ruleContext.getActionOwner(), targetIdeInfo, ideInfoTextFile));
return provider;
}
Aggregations