use of com.google.devtools.build.lib.rules.proto.SupportData in project bazel by bazelbuild.
the class J2ObjcAspect method createJ2ObjcProtoCompileActions.
private J2ObjcMappingFileProvider createJ2ObjcProtoCompileActions(ConfiguredTarget base, RuleContext ruleContext, Iterable<Artifact> filteredProtoSources, J2ObjcSource j2ObjcSource) {
Iterable<Artifact> outputHeaderMappingFiles = ProtoCommon.getGeneratedOutputs(ruleContext, ImmutableList.copyOf(filteredProtoSources), ".j2objc.mapping");
Iterable<Artifact> outputClassMappingFiles = ProtoCommon.getGeneratedOutputs(ruleContext, ImmutableList.copyOf(filteredProtoSources), ".clsmap.properties");
ImmutableList<Artifact> outputs = ImmutableList.<Artifact>builder().addAll(j2ObjcSource.getObjcSrcs()).addAll(j2ObjcSource.getObjcHdrs()).addAll(outputHeaderMappingFiles).addAll(outputClassMappingFiles).build();
String langPluginParameter = String.format("%s:%s", Joiner.on(',').join(J2OBJC_PLUGIN_PARAMS), ruleContext.getConfiguration().getGenfilesFragment().getPathString());
SupportData supportData = base.getProvider(ProtoSupportDataProvider.class).getSupportData();
ProtoCompileActionBuilder actionBuilder = new ProtoCompileActionBuilder(ruleContext, supportData, "J2ObjC", "j2objc", outputs).setLangPluginName("$j2objc_plugin").setLangPluginParameter(langPluginParameter).allowServices(shouldAllowProtoServices(ruleContext));
ruleContext.registerAction(actionBuilder.build());
return new J2ObjcMappingFileProvider(NestedSetBuilder.<Artifact>stableOrder().addAll(outputHeaderMappingFiles).build(), NestedSetBuilder.<Artifact>stableOrder().addAll(outputClassMappingFiles).build(), NestedSetBuilder.<Artifact>stableOrder().build(), NestedSetBuilder.<Artifact>stableOrder().build());
}
use of com.google.devtools.build.lib.rules.proto.SupportData in project bazel by bazelbuild.
the class JavaLiteProtoAspect method create.
@Override
public ConfiguredAspect create(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException {
ConfiguredAspect.Builder aspect = new ConfiguredAspect.Builder(this, parameters, ruleContext);
// 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);
impl.addProviders(aspect);
return aspect.build();
}
use of com.google.devtools.build.lib.rules.proto.SupportData 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.rules.proto.SupportData 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();
}
use of com.google.devtools.build.lib.rules.proto.SupportData in project bazel by bazelbuild.
the class JavaProtoSkylarkCommon method createProtoCompileAction.
@SkylarkCallable(name = "create_java_lite_proto_compile_action", // This function is experimental for now.
documented = false, // There's 2 mandatory positional arguments, the Skylark context and the ConfiguredTarget.
mandatoryPositionals = 2, parameters = { @Param(name = "src_jar", positional = false, named = true, type = Artifact.class), @Param(name = "proto_toolchain_attr", positional = false, named = true, type = String.class), @Param(name = "flavour", positional = false, named = true, type = String.class, defaultValue = "java") })
public static void createProtoCompileAction(SkylarkRuleContext skylarkRuleContext, ConfiguredTarget target, Artifact sourceJar, String protoToolchainAttr, String flavour) {
SupportData supportData = checkNotNull(target.getProvider(ProtoSupportDataProvider.class).getSupportData());
ProtoCompileActionBuilder.registerActions(skylarkRuleContext.getRuleContext(), ImmutableList.of(new ProtoCompileActionBuilder.ToolchainInvocation(flavour, getProtoToolchainProvider(skylarkRuleContext, protoToolchainAttr), sourceJar.getExecPathString())), supportData.getDirectProtoSources(), supportData.getTransitiveImports(), supportData.getProtosInDirectDeps(), skylarkRuleContext.getLabel().getCanonicalForm(), ImmutableList.of(sourceJar), "JavaLite", true);
}
Aggregations