aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2016-11-29 01:04:35 +0000
committerGravatar Irina Iancu <elenairina@google.com>2016-11-29 08:07:22 +0000
commitf1aa34c87cbd1944f385911244f3828e8d9114eb (patch)
treeb7c656cb89e1f9ebbdd7a13ddbd585a2d61cb512 /src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
parent2b5038831c2514f65841ce4e40f8e4648250bf01 (diff)
Make it easier to use protos in Bazel out of the box.
java_xxx_proto_library rules now look for toolchains in the external repo @com_google_protobuf_xxx//:xxx_toolchain This still requires getting protobuf's GitHub repository to build with Bazel. -- MOS_MIGRATED_REVID=140420903
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
index 7ae7cadd19..e8fa34660a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaLiteProtoAspect.java
@@ -66,22 +66,29 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured
public static final String PROTO_TOOLCHAIN_ATTR = ":aspect_proto_toolchain_for_javalite";
- public static final Attribute.LateBoundLabel<BuildConfiguration> PROTO_TOOLCHAIN_LABEL =
- new Attribute.LateBoundLabel<BuildConfiguration>(
- "//tools/proto/toolchains:javalite", ProtoConfiguration.class) {
- @Override
- public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
- return configuration.getFragment(ProtoConfiguration.class).protoToolchainForJavaLite();
- }
- };
+ public static Attribute.LateBoundLabel<BuildConfiguration> getProtoToolchainLabel(
+ String defaultValue) {
+ return new Attribute.LateBoundLabel<BuildConfiguration>(
+ defaultValue, ProtoConfiguration.class) {
+ @Override
+ public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
+ return configuration.getFragment(ProtoConfiguration.class).protoToolchainForJavaLite();
+ }
+ };
+ }
private final JavaSemantics javaSemantics;
@Nullable private final String jacocoLabel;
+ private final String defaultProtoToolchainLabel;
- public JavaLiteProtoAspect(JavaSemantics javaSemantics, @Nullable String jacocoLabel) {
+ public JavaLiteProtoAspect(
+ JavaSemantics javaSemantics,
+ @Nullable String jacocoLabel,
+ String defaultProtoToolchainLabel) {
this.javaSemantics = javaSemantics;
this.jacocoLabel = jacocoLabel;
+ this.defaultProtoToolchainLabel = defaultProtoToolchainLabel;
}
@Override
@@ -112,7 +119,7 @@ public class JavaLiteProtoAspect extends NativeAspectClass implements Configured
.mandatoryNativeProviders(
ImmutableList.<Class<? extends TransitiveInfoProvider>>of(
ProtoLangToolchainProvider.class))
- .value(PROTO_TOOLCHAIN_LABEL))
+ .value(getProtoToolchainLabel(defaultProtoToolchainLabel)))
.add(attr(":host_jdk", LABEL).cfg(HOST).value(JavaSemantics.HOST_JDK))
.add(
attr(":java_toolchain", LABEL)