aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-07-09 12:16:24 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-09 12:18:00 -0700
commite8956648d1c94a3a51e1aba5d229d1f27bdf8e35 (patch)
treef0549f7f73ceeefc1635e4f2f746da14b096e3ef /src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
parent68e92b45a37f2142c768a56eb7ecfa484b8b22df (diff)
[Reland] Accept proto paths relative to proto_source_root as direct dependencies.
This is a reland of https://github.com/bazelbuild/bazel/commit/5deca4cf88f5568771f2c836a9b8c693b88bd749. This will make protoc see as direct dependencies the .proto files that were included using the proto_source_root flag. Until now, Bazel passed to protoc the direct dependencies of a target as the path relative to the WORKSPACE, which made it fail when a shorter path, relative to the package was used. Progress on #4544. RELNOTES: None. PiperOrigin-RevId: 203808292
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
index e3687be773..1c8a7d52cb 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
@@ -45,10 +45,14 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
NestedSet<Artifact> transitiveImports =
ProtoCommon.collectTransitiveImports(ruleContext, protoSources);
- NestedSet<String> protoPathFlags = ProtoCommon.collectTransitiveProtoPathFlags(ruleContext);
-
NestedSet<Artifact> protosInDirectDeps = ProtoCommon.computeProtosInDirectDeps(ruleContext);
+ String protoSourceRoot = ProtoCommon.getProtoSourceRoot(ruleContext);
+ NestedSet<String> directProtoSourceRoots =
+ ProtoCommon.getProtoSourceRootsOfDirectDependencies(ruleContext, protoSourceRoot);
+ NestedSet<String> protoPathFlags =
+ ProtoCommon.collectTransitiveProtoPathFlags(ruleContext, protoSourceRoot);
+
final SupportData supportData =
SupportData.create(
/* nonWeakDepsPredicate= */ Predicates.<TransitiveInfoCollection>alwaysTrue(),
@@ -56,6 +60,7 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
protosInDirectDeps,
transitiveImports,
protoPathFlags,
+ directProtoSourceRoots,
!protoSources.isEmpty());
Artifact descriptorSetOutput =
@@ -75,7 +80,8 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
descriptorSetOutput,
/* allowServices= */ true,
dependenciesDescriptorSets,
- protoPathFlags);
+ protoPathFlags,
+ directProtoSourceRoots);
Runfiles dataRunfiles =
ProtoCommon.createDataRunfilesProvider(transitiveImports, ruleContext)
@@ -91,7 +97,8 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
checkDepsProtoSources,
descriptorSetOutput,
transitiveDescriptorSetOutput,
- protoPathFlags);
+ protoPathFlags,
+ protoSourceRoot);
return new RuleConfiguredTargetBuilder(ruleContext)
.setFilesToBuild(NestedSetBuilder.create(STABLE_ORDER, descriptorSetOutput))