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>2016-12-21 19:04:39 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-12-22 09:55:42 +0000
commitafa8d0b4076bb42dbac9f4e2459a7cef7442a6d8 (patch)
tree81d93717966ac47c92743469eaf64cf779d896e5 /src/main/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibrary.java
parentcf582615487a3dd541f073479f2a26a9376887b2 (diff)
Move the descriptorset output to the ProtoSourcesProvider and expose it to skylark.
This does mean that the type name 'ProtoSourcesProvider' is a little inaccurate, since descriptorSet() is an output. Alternatively we could expose the DescriptorSetProvider to skylark. RELNOTES: expose proto_library descriptor set to skylark via <dep>.proto.descriptor_set -- PiperOrigin-RevId: 142680666 MOS_MIGRATED_REVID=142680666
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.java18
1 files changed, 11 insertions, 7 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 3557c5f95c..c524829ce9 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
@@ -46,11 +46,6 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
NestedSet<Artifact> transitiveImports =
ProtoCommon.collectTransitiveImports(ruleContext, protoSources);
- // TODO(bazel-team): this second constructor argument is superfluous and should be removed.
- ProtoSourcesProvider sourcesProvider =
- ProtoSourcesProvider.create(
- transitiveImports, transitiveImports, protoSources, checkDepsProtoSources);
-
NestedSet<Artifact> protosInDirectDeps =
areDepsStrict(ruleContext) ? ProtoCommon.computeProtosInDirectDeps(ruleContext) : null;
@@ -67,10 +62,11 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
RuleConfiguredTargetBuilder result = new RuleConfiguredTargetBuilder(ruleContext);
+ Artifact descriptorSetOutput = null;
if (checkDepsProtoSources.isEmpty() || !outputDescriptorSetFlagEnabled(ruleContext)) {
result.setFilesToBuild(NestedSetBuilder.<Artifact>create(STABLE_ORDER));
} else {
- Artifact descriptorSetOutput =
+ descriptorSetOutput =
ruleContext.getGenfilesArtifact(
ruleContext.getLabel().getName() + "-descriptor-set.proto.bin");
ProtoCompileActionBuilder.writeDescriptorSet(
@@ -85,9 +81,17 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory {
dataRunfiles.addArtifact(descriptorSetOutput);
result.setFilesToBuild(NestedSetBuilder.create(STABLE_ORDER, descriptorSetOutput));
- result.addProvider(DescriptorSetProvider.create(descriptorSetOutput));
}
+ // TODO(bazel-team): this second constructor argument is superfluous and should be removed.
+ ProtoSourcesProvider sourcesProvider =
+ ProtoSourcesProvider.create(
+ transitiveImports,
+ transitiveImports,
+ protoSources,
+ checkDepsProtoSources,
+ descriptorSetOutput);
+
return result
.addProvider(RunfilesProvider.withData(Runfiles.EMPTY, dataRunfiles.build()))
.addProvider(ProtoSourcesProvider.class, sourcesProvider)