diff options
author | elenairina <elenairina@google.com> | 2018-02-20 06:26:33 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-20 06:27:57 -0800 |
commit | 5deca4cf88f5568771f2c836a9b8c693b88bd749 (patch) | |
tree | 1ab038e4bf10301e0e8878c21e9693091b78e304 /src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java | |
parent | 9ac10696da052d1327b3f1cd276b2ab50fe1fee1 (diff) |
Accept proto paths relative to proto_source_root as direct dependencies.
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: 186294997
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.java | 15 |
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 d1cd914016..a4fd57525b 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 @@ -44,10 +44,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( Predicates.<TransitiveInfoCollection>alwaysTrue() /* nonWeakDepsPredicate */, @@ -55,6 +59,7 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory { protosInDirectDeps, transitiveImports, protoPathFlags, + directProtoSourceRoots, !protoSources.isEmpty()); Artifact descriptorSetOutput = @@ -74,7 +79,8 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory { descriptorSetOutput, true /* allowServices */, dependenciesDescriptorSets, - protoPathFlags); + protoPathFlags, + directProtoSourceRoots); Runfiles dataRunfiles = ProtoCommon.createDataRunfilesProvider(transitiveImports, ruleContext) @@ -90,7 +96,8 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory { checkDepsProtoSources, descriptorSetOutput, transitiveDescriptorSetOutput, - protoPathFlags); + protoPathFlags, + protoSourceRoot); return new RuleConfiguredTargetBuilder(ruleContext) .setFilesToBuild(NestedSetBuilder.create(STABLE_ORDER, descriptorSetOutput)) |