aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
diff options
context:
space:
mode:
authorGravatar Carmi Grushko <carmi@google.com>2017-02-01 07:49:29 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-02-01 08:57:49 +0000
commitbef4fbed3d22a976b895a3f75ad41699747c286e (patch)
tree47c4d589ab86d0a63eca302cdc51e9fa5bb26022 /src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
parent28bf873a45e9787cbaa8dcffeedc4b98fa8fc2c2 (diff)
Do not crash when a strict proto_library depends on a non-strict one.
(strictness in the sense of strict proto deps) The reason for the crash was that a non-strict proto_library would put 'null' in its SupportData.protosInDirectDeps, and then a strict proto_library that consumes it would choke on the null. This rearranges things so that protosInDirectDeps will never be null. -- PiperOrigin-RevId: 146210040 MOS_MIGRATED_REVID=146210040
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
index 7cae194729..f6b515f912 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.rules.proto;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.isEmpty;
import static com.google.devtools.build.lib.collect.nestedset.Order.STABLE_ORDER;
+import static com.google.devtools.build.lib.rules.proto.ProtoCommon.areDepsStrict;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
@@ -287,12 +288,15 @@ public class ProtoCompileActionBuilder {
result.add(ruleContext.getFragment(ProtoConfiguration.class).protocOpts());
+ boolean areDepsStrict = areDepsStrict(ruleContext);
+
// Add include maps
result.add(
new ProtoCommandLineArgv(
- supportData.getProtosInDirectDeps(), supportData.getTransitiveImports()));
+ areDepsStrict ? supportData.getProtosInDirectDeps() : null,
+ supportData.getTransitiveImports()));
- if (supportData.getProtosInDirectDeps() != null) {
+ if (areDepsStrict) {
// Note: the %s in the line below is used by proto-compiler. That is, the string we create
// here should have a literal %s in it.
result.add(
@@ -412,7 +416,7 @@ public class ProtoCompileActionBuilder {
List<ToolchainInvocation> toolchainInvocations,
Iterable<Artifact> protosToCompile,
NestedSet<Artifact> transitiveSources,
- @Nullable NestedSet<Artifact> protosInDirectDeps,
+ NestedSet<Artifact> protosInDirectDeps,
String ruleLabel,
Iterable<Artifact> outputs,
String flavorName,
@@ -447,7 +451,7 @@ public class ProtoCompileActionBuilder {
toolchainInvocations,
protosToCompile,
transitiveSources,
- protosInDirectDeps,
+ areDepsStrict(ruleContext) ? protosInDirectDeps : null,
ruleLabel,
allowServices,
ruleContext.getFragment(ProtoConfiguration.class).protocOpts()))