aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-11-07 11:15:09 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-11-07 11:36:36 +0000
commitb043fafb957ae8038088e427ff27a5c9f951c979 (patch)
tree606daf12e860ab66a5e4e19108d5c8bd8641b0cb
parentf2d3caccd91b098d0dc1c7ddad308dfbfb61f1c7 (diff)
*** Reason for rollback *** Breaks tests on latest, as proto_lang_toolchain didn't make it into the 0.4.0 release see http://ci.bazel.io/job/bazel-tests/306/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64/console *** Original change description *** Use proto_lang_toolchain() in java_proto_library. -- MOS_MIGRATED_REVID=138372522
-rw-r--r--WORKSPACE1
-rw-r--r--src/main/java/com/google/devtools/build/lib/BUILD1
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java26
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java100
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/proto/RpcSupport.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java34
-rw-r--r--third_party/protobuf/3.0.0/BUILD6
-rw-r--r--third_party/protobuf/BUILD2
-rw-r--r--tools/proto/toolchains/BUILD5
9 files changed, 21 insertions, 163 deletions
diff --git a/WORKSPACE b/WORKSPACE
index cace908c64..b06d57f180 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -52,7 +52,6 @@ bind(name = "xcrunwrapper", actual = "@bazel_tools//tools/objc:xcrunwrapper")
bind(name = "protobuf/java_runtime", actual = "//third_party/protobuf:protobuf")
bind(name = "protobuf/javalite_runtime", actual = "//third_party/protobuf:protobuf-lite")
-bind(name = "proto/toolchains/java", actual = "//third_party/protobuf:java_toolchain")
# For Skylark tests at //src/test/shell/bazel:maven_skylark_test
# Uncomment the following lines, and the test in src/test/shell/bazel/BUILD to run it.
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD
index c68d72f66b..c5bc348bdc 100644
--- a/src/main/java/com/google/devtools/build/lib/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -812,7 +812,6 @@ java_library(
srcs = ["rules/java/proto/RpcSupport.java"],
deps = [
":build-base",
- ":collect",
":java-compilation",
":packages-internal",
":proto-rules",
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java
index 8dd2ae2e07..ab062dd254 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/proto/BazelJavaProtoAspect.java
@@ -14,21 +14,15 @@
package com.google.devtools.build.lib.bazel.rules.java.proto;
-import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
-
-import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.bazel.rules.java.BazelJavaSemantics;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.rules.java.JavaLibraryHelper;
import com.google.devtools.build.lib.rules.java.proto.JavaProtoAspect;
import com.google.devtools.build.lib.rules.java.proto.RpcSupport;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder;
-import java.util.List;
/** An Aspect which BazelJavaProtoLibrary injects to build Java SPEED protos. */
public class BazelJavaProtoAspect extends JavaProtoAspect {
@@ -43,24 +37,8 @@ public class BazelJavaProtoAspect extends JavaProtoAspect {
private static class NoopRpcSupport
implements RpcSupport {
@Override
- public List<ProtoCompileActionBuilder.ToolchainInvocation> getToolchainInvocation(
- RuleContext ruleContext, Artifact sourceJar) {
- return ImmutableList.of();
- }
-
- @Override
- public boolean allowServices(RuleContext ruleContext) {
- return true;
- }
-
- @Override
- public NestedSet<Artifact> getBlacklist(RuleContext ruleContext) {
- return NestedSetBuilder.emptySet(STABLE_ORDER);
- }
-
- @Override
- public void mutateProtoCompileAction(RuleContext ruleContext, Artifact sourceJar,
- ProtoCompileActionBuilder actionBuilder) {
+ public void mutateProtoCompileAction(
+ RuleContext ruleContext, Artifact sourceJar, ProtoCompileActionBuilder actionBuilder) {
// Intentionally left empty.
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
index f66749f941..ba6184eb61 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/JavaProtoAspect.java
@@ -33,7 +33,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMap;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
@@ -55,9 +54,7 @@ import com.google.devtools.build.lib.rules.java.JavaLibraryHelper;
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder;
-import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.ToolchainInvocation;
import com.google.devtools.build.lib.rules.proto.ProtoConfiguration;
-import com.google.devtools.build.lib.rules.proto.ProtoLangToolchainProvider;
import com.google.devtools.build.lib.rules.proto.ProtoSourceFileBlacklist;
import com.google.devtools.build.lib.rules.proto.ProtoSourcesProvider;
import com.google.devtools.build.lib.rules.proto.ProtoSupportDataProvider;
@@ -68,8 +65,6 @@ import javax.annotation.Nullable;
/** An Aspect which JavaProtoLibrary injects to build Java SPEED protos. */
public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspectFactory {
- private static final String SPEED_PROTO_TOOLCHAIN_ATTR = ":aspect_java_proto_toolchain";
-
private static final String SPEED_PROTO_RUNTIME_ATTR = "$aspect_java_lib";
private static final String SPEED_PROTO_RUNTIME_LABEL = "//external:protobuf/java_runtime";
@@ -96,15 +91,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
}
};
- private static final Attribute.LateBoundLabel<BuildConfiguration> SPEED_PROTO_TOOLCHAIN_LABEL =
- new Attribute.LateBoundLabel<BuildConfiguration>(
- "//tools/proto/toolchains:java", ProtoConfiguration.class) {
- @Override
- public Label resolve(Rule rule, AttributeMap attributes, BuildConfiguration configuration) {
- return configuration.getFragment(ProtoConfiguration.class).protoToolchainForJava();
- }
- };
-
private final JavaSemantics javaSemantics;
@Nullable private final String jacocoLabel;
@@ -142,8 +128,7 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
.getFragment(ProtoConfiguration.class, ConfigurationTransition.HOST)
.protoCompilerJavaFlags(),
javaSemantics,
- rpcSupport,
- ruleContext.getFragment(ProtoConfiguration.class).useToolchainForJavaProto())
+ rpcSupport)
.createProviders());
return aspect.build();
@@ -164,12 +149,6 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
attr(PROTO_SOURCE_FILE_BLACKLIST_ATTR, LABEL_LIST)
.cfg(HOST)
.value(BLACKLISTED_PROTOS))
- .add(
- attr(SPEED_PROTO_TOOLCHAIN_ATTR, LABEL)
- .mandatoryNativeProviders(
- ImmutableList.<Class<? extends TransitiveInfoProvider>>of(
- ProtoLangToolchainProvider.class))
- .value(SPEED_PROTO_TOOLCHAIN_LABEL))
.add(attr(":host_jdk", LABEL).cfg(HOST).value(JavaSemantics.HOST_JDK))
.add(
attr(":java_toolchain", LABEL)
@@ -200,21 +179,18 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
*/
private final JavaCompilationArgsProvider dependencyCompilationArgs;
private final String protoCompilerPluginOptions;
- private final boolean useToolchainForJavaProto;
Impl(
final RuleContext ruleContext,
final SupportData supportData,
String protoCompilerPluginOptions,
JavaSemantics javaSemantics,
- RpcSupport rpcSupport,
- boolean useToolchainForJavaProto) {
+ RpcSupport rpcSupport) {
this.ruleContext = ruleContext;
this.supportData = supportData;
this.protoCompilerPluginOptions = protoCompilerPluginOptions;
this.javaSemantics = javaSemantics;
this.rpcSupport = rpcSupport;
- this.useToolchainForJavaProto = useToolchainForJavaProto;
dependencyCompilationArgs =
JavaCompilationArgsProvider.merge(
@@ -274,49 +250,24 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
return false;
}
- final ProtoSourceFileBlacklist protoBlackList;
- if (useToolchainForJavaProto) {
- NestedSetBuilder<Artifact> blacklistedProtos = NestedSetBuilder.stableOrder();
- blacklistedProtos.addTransitive(getProtoToolchainProvider().blacklistedProtos());
- blacklistedProtos.addTransitive(rpcSupport.getBlacklist(ruleContext));
-
- protoBlackList = new ProtoSourceFileBlacklist(ruleContext, blacklistedProtos.build());
- } else {
- protoBlackList =
- new ProtoSourceFileBlacklist(
- ruleContext,
- ruleContext
- .getPrerequisiteArtifacts(PROTO_SOURCE_FILE_BLACKLIST_ATTR, Mode.HOST)
- .list());
- }
-
+ ProtoSourceFileBlacklist protoBlackList =
+ new ProtoSourceFileBlacklist(
+ ruleContext,
+ ruleContext
+ .getPrerequisiteArtifacts(PROTO_SOURCE_FILE_BLACKLIST_ATTR, Mode.HOST)
+ .list());
return protoBlackList.checkSrcs(supportData.getDirectProtoSources(), "java_proto_library");
}
private void createProtoCompileAction(Artifact sourceJar) {
- if (useToolchainForJavaProto) {
- ImmutableList.Builder<ToolchainInvocation> invocations = ImmutableList.builder();
- invocations.add(
- new ToolchainInvocation(
- "java", checkNotNull(getProtoToolchainProvider()), sourceJar.getExecPathString()));
- invocations.addAll(rpcSupport.getToolchainInvocation(ruleContext, sourceJar));
- ProtoCompileActionBuilder.registerActions(
- ruleContext,
- invocations.build(),
- supportData,
- ImmutableList.of(sourceJar),
- "Java (Immutable)",
- rpcSupport.allowServices(ruleContext));
- } else {
- ProtoCompileActionBuilder actionBuilder =
- new ProtoCompileActionBuilder(
- ruleContext, supportData, "Java", "java", ImmutableList.of(sourceJar))
- .allowServices(true)
- .setLangParameter(
- String.format(protoCompilerPluginOptions, sourceJar.getExecPathString()));
- rpcSupport.mutateProtoCompileAction(ruleContext, sourceJar, actionBuilder);
- ruleContext.registerAction(actionBuilder.build());
- }
+ ProtoCompileActionBuilder actionBuilder =
+ new ProtoCompileActionBuilder(
+ ruleContext, supportData, "Java", "java", ImmutableList.of(sourceJar))
+ .allowServices(true)
+ .setLangParameter(
+ String.format(protoCompilerPluginOptions, sourceJar.getExecPathString()));
+ rpcSupport.mutateProtoCompileAction(ruleContext, sourceJar, actionBuilder);
+ ruleContext.registerAction(actionBuilder.build());
}
private JavaCompilationArgsProvider createJavaCompileAction(
@@ -328,28 +279,15 @@ public class JavaProtoAspect extends NativeAspectClass implements ConfiguredAspe
.setJavacOpts(ProtoJavacOpts.constructJavacOpts(ruleContext));
helper
.addDep(dependencyCompilationArgs)
+ .addDep(
+ ruleContext.getPrerequisite(
+ SPEED_PROTO_RUNTIME_ATTR, Mode.TARGET, JavaCompilationArgsProvider.class))
.setCompilationStrictDepsMode(StrictDepsMode.OFF);
- if (useToolchainForJavaProto) {
- TransitiveInfoCollection runtime = getProtoToolchainProvider().runtime();
- if (runtime != null) {
- helper.addDep(runtime.getProvider(JavaCompilationArgsProvider.class));
- }
- } else {
- helper.addDep(
- ruleContext.getPrerequisite(
- SPEED_PROTO_RUNTIME_ATTR, Mode.TARGET, JavaCompilationArgsProvider.class));
- }
-
rpcSupport.mutateJavaCompileAction(ruleContext, helper);
return helper.buildCompilationArgsProvider(
helper.build(javaSemantics), true /* isReportedAsStrict */);
}
- private ProtoLangToolchainProvider getProtoToolchainProvider() {
- return ruleContext.getPrerequisite(
- SPEED_PROTO_TOOLCHAIN_ATTR, TARGET, ProtoLangToolchainProvider.class);
- }
-
private Artifact getSourceJarArtifact() {
return ruleContext.getGenfilesArtifact(ruleContext.getLabel().getName() + "-speed-src.jar");
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/proto/RpcSupport.java b/src/main/java/com/google/devtools/build/lib/rules/java/proto/RpcSupport.java
index 44a1c06579..0840311155 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/proto/RpcSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/proto/RpcSupport.java
@@ -16,24 +16,15 @@ package com.google.devtools.build.lib.rules.java.proto;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.rules.java.JavaLibraryHelper;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder;
-import java.util.List;
/**
* Used by java_proto_library to support Google-specific features.
*/
public interface RpcSupport {
- List<ProtoCompileActionBuilder.ToolchainInvocation> getToolchainInvocation(
- RuleContext ruleContext, Artifact sourceJar);
-
- boolean allowServices(RuleContext ruleContext);
-
- NestedSet<Artifact> getBlacklist(RuleContext ruleContext);
-
void mutateProtoCompileAction(
RuleContext ruleContext, Artifact sourceJar, ProtoCompileActionBuilder actionBuilder);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java
index 39b854b86c..48be2587bc 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoConfiguration.java
@@ -113,26 +113,6 @@ public class ProtoConfiguration extends Fragment {
)
public Label protoToolchainForJavaLite;
- @Option(
- name = "proto_toolchain_for_java",
- defaultValue = "//tools/proto/toolchains:java",
- category = "flags",
- converter = BuildConfiguration.EmptyToNullLabelConverter.class,
- help = "Label of proto_lang_toolchain() which describes how to compile Java protos"
- )
- public Label protoToolchainForJava;
-
- @Option(
- name = "use_toolchain_for_java_proto",
- defaultValue = "false",
- category = "experimental",
- help =
- "If true, --proto_toolchain_for_java will be used for java_proto_library. "
- + "This flag is an escape-hatch and should be removed once toolchain-based builds "
- + "are tested."
- )
- public boolean useToolchainForJavaProto;
-
@Override
public FragmentOptions getHost(boolean fallback) {
Options host = (Options) super.getHost(fallback);
@@ -144,9 +124,7 @@ public class ProtoConfiguration extends Fragment {
host.protoCompilerJavaBlacklistedProtos = protoCompilerJavaBlacklistedProtos;
host.protoCompilerJavaLiteFlags = protoCompilerJavaLiteFlags;
host.protoCompilerJavaLitePlugin = protoCompilerJavaLitePlugin;
- host.protoToolchainForJava = protoToolchainForJava;
host.protoToolchainForJavaLite = protoToolchainForJavaLite;
- host.useToolchainForJavaProto = useToolchainForJavaProto;
return host;
}
}
@@ -179,9 +157,7 @@ public class ProtoConfiguration extends Fragment {
private final List<Label> protoCompilerJavaBlacklistedProtos;
private final String protoCompilerJavaLiteFlags;
private final Label protoCompilerJavaLitePlugin;
- private final Label protoToolchainForJava;
private final Label protoToolchainForJavaLite;
- private final boolean useToolchainForJavaProto;
public ProtoConfiguration(Options options) {
this.experimentalProtoExtraActions = options.experimentalProtoExtraActions;
@@ -191,9 +167,7 @@ public class ProtoConfiguration extends Fragment {
this.protoCompilerJavaLiteFlags = options.protoCompilerJavaLiteFlags;
this.protoCompilerJavaLitePlugin = options.protoCompilerJavaLitePlugin;
this.protoCompilerJavaBlacklistedProtos = options.protoCompilerJavaBlacklistedProtos;
- this.protoToolchainForJava = options.protoToolchainForJava;
this.protoToolchainForJavaLite = options.protoToolchainForJavaLite;
- this.useToolchainForJavaProto = options.useToolchainForJavaProto;
}
public ImmutableList<String> protocOpts() {
@@ -229,15 +203,7 @@ public class ProtoConfiguration extends Fragment {
return protoCompilerJavaBlacklistedProtos;
}
- public Label protoToolchainForJava() {
- return protoToolchainForJava;
- }
-
public Label protoToolchainForJavaLite() {
return protoToolchainForJavaLite;
}
-
- public boolean useToolchainForJavaProto() {
- return useToolchainForJavaProto;
- }
}
diff --git a/third_party/protobuf/3.0.0/BUILD b/third_party/protobuf/3.0.0/BUILD
index 9da9f25212..767ebd7306 100644
--- a/third_party/protobuf/3.0.0/BUILD
+++ b/third_party/protobuf/3.0.0/BUILD
@@ -311,9 +311,3 @@ cc_library(
visibility = ["//visibility:public"],
deps = [":protobuf_clib"],
)
-
-proto_lang_toolchain(
- name = "java_toolchain",
- command_line = "--java_out=shared,immutable:$(OUT)",
- runtime = ":protobuf",
-)
diff --git a/third_party/protobuf/BUILD b/third_party/protobuf/BUILD
index f6e1ea9fda..0f39107b93 100644
--- a/third_party/protobuf/BUILD
+++ b/third_party/protobuf/BUILD
@@ -29,5 +29,3 @@ proto_alias("protobuf_lite", PROTOBUF_VERSION)
proto_alias("protobuf_clib", PROTOBUF_VERSION)
proto_alias("protoc_lib", PROTOBUF_VERSION)
-
-proto_alias("java_toolchain", PROTOBUF_VERSION)
diff --git a/tools/proto/toolchains/BUILD b/tools/proto/toolchains/BUILD
index 671a84ef1c..f5f4a5e3c4 100644
--- a/tools/proto/toolchains/BUILD
+++ b/tools/proto/toolchains/BUILD
@@ -5,11 +5,6 @@ alias(
actual = "//external:proto/toolchains/javalite",
)
-alias(
- name = "java",
- actual = "//external:proto/toolchains/java",
-)
-
filegroup(
name = "srcs",
srcs = [