diff options
author | 2015-11-09 18:08:51 +0000 | |
---|---|---|
committer | 2015-11-10 10:23:10 +0000 | |
commit | adab27ed11f824db43277eec05278c5d583cd430 (patch) | |
tree | 96adb01c5d30d4fd7a8a2171cebd23ebf08068ec /src | |
parent | bca82ad9c0a4b69ae1598d8a1a3eab0d088ed6e9 (diff) |
Change ProtoSourcesProvider to only export direct sources. Add a method, getCheckDepsProtoSources(), to get any indirect sources from alias library cases.
--
MOS_MIGRATED_REVID=107395192
Diffstat (limited to 'src')
4 files changed, 30 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java index 59a54702e9..529bc4a29e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AbstractJ2ObjcProtoAspect.java @@ -82,7 +82,7 @@ public abstract class AbstractJ2ObjcProtoAspect implements ConfiguredNativeAspec } ProtoSourcesProvider protoSourcesProvider = base.getProvider(ProtoSourcesProvider.class); - ImmutableList<Artifact> protoSources = protoSourcesProvider.getProtoSources(); + ImmutableList<Artifact> protoSources = protoSourcesProvider.getDirectProtoSources(); NestedSet<Artifact> transitiveImports = protoSourcesProvider.getTransitiveImports(); J2ObjcSrcsProvider.Builder srcsBuilder = new J2ObjcSrcsProvider.Builder(); 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 478a676d87..cada50761e 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 @@ -33,7 +33,7 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory { public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { ImmutableList<Artifact> protoSources = ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list(); - ImmutableList<Artifact> directProtoSources = ProtoCommon.getDirectProtoSources( + ImmutableList<Artifact> checkDepsProtoSources = ProtoCommon.getCheckDepsProtoSources( ruleContext, protoSources); ProtoCommon.checkSourceFilesAreInSamePackage(ruleContext); @@ -44,7 +44,8 @@ public class BazelProtoLibrary implements RuleConfiguredTargetFactory { ProtoCommon.createRunfilesProvider(transitiveImports, ruleContext); // TODO(bazel-team): this second constructor argument is superfluous and should be removed. ProtoSourcesProvider sourcesProvider = - new ProtoSourcesProvider(transitiveImports, transitiveImports, directProtoSources); + new ProtoSourcesProvider( + transitiveImports, transitiveImports, protoSources, checkDepsProtoSources); return new RuleConfiguredTargetBuilder(ruleContext) .add(RunfilesProvider.class, runfilesProvider) diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java index fec82f3719..42e02980e6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java @@ -46,7 +46,7 @@ public class ProtoCommon { * @return the direct sources of a proto library. */ // TODO(bazel-team): Proto sources should probably be a NestedSet. - public static ImmutableList<Artifact> getDirectProtoSources( + public static ImmutableList<Artifact> getCheckDepsProtoSources( RuleContext ruleContext, ImmutableList<Artifact> protoSources) { if (protoSources.isEmpty()) { @@ -56,7 +56,7 @@ public class ProtoCommon { .getPrerequisites("deps", Mode.TARGET)) { ProtoSourcesProvider sources = provider.getProvider(ProtoSourcesProvider.class); if (sources != null) { - builder.addAll(sources.getProtoSources()); + builder.addAll(sources.getCheckDepsProtoSources()); } } return builder.build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java index 97c1f538dc..84f26d0729 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java @@ -34,15 +34,19 @@ public final class ProtoSourcesProvider implements TransitiveInfoProvider { private final NestedSet<Artifact> transitiveImports; private final NestedSet<Artifact> transitiveProtoSources; + // TODO(bazel-team): Both of these should be NestedSets. private final ImmutableList<Artifact> protoSources; + private final ImmutableList<Artifact> checkDepsProtoSources; public ProtoSourcesProvider( NestedSet<Artifact> transitiveImports, NestedSet<Artifact> transitiveProtoSources, - ImmutableList<Artifact> protoSources) { + ImmutableList<Artifact> protoSources, + ImmutableList<Artifact> checkDepsProtoSources) { this.transitiveImports = transitiveImports; this.transitiveProtoSources = transitiveProtoSources; this.protoSources = protoSources; + this.checkDepsProtoSources = checkDepsProtoSources; } /** @@ -66,20 +70,35 @@ public final class ProtoSourcesProvider implements TransitiveInfoProvider { name = "transitive_sources", doc = "Proto sources for this rule and all its dependent protocol buffer rules.", structField = true) + // TODO(bazel-team): The difference between transitive imports and transitive proto sources + // should never be used by Skylark or by an Aspect. One of these two should be removed, + // preferably soon, before Skylark users start depending on them. public NestedSet<Artifact> getTransitiveProtoSources() { return transitiveProtoSources; } /** + * Returns the proto sources from the 'srcs' attribute. + */ + @SkylarkCallable( + name = "direct_sources", + doc = "Proto sources from the 'srcs' attribute.", + structField = true) + public ImmutableList<Artifact> getDirectProtoSources() { + return protoSources; + } + + /** * Returns the proto sources from the 'srcs' attribute. If the library is a proxy library * that has no sources, return the sources from the direct deps. */ @SkylarkCallable( - name = "sources", + name = "check_deps_sources", doc = "Proto sources from the 'srcs' attribute. If the library is a proxy library " - + "that has no sources, it contains the sources from the direct deps.", + + "that has no sources, it contains the check_deps_sources" + + "from this library's direct deps.", structField = true) - public ImmutableList<Artifact> getProtoSources() { - return protoSources; + public ImmutableList<Artifact> getCheckDepsProtoSources() { + return checkDepsProtoSources; } } |