diff options
author | 2015-05-29 11:04:19 +0000 | |
---|---|---|
committer | 2015-06-01 15:46:55 +0000 | |
commit | ac5451532ee078f963d1d784155469d6a5d67524 (patch) | |
tree | d11e84183a0e9cef754ab949b9d1fb055b0a1a87 /src/main/java/com | |
parent | 662166f30f3827e1a025a7d58b000d1cc12cab9f (diff) |
Skylark: Expose proto providers in a cleaner way.
Example:
for target in ctx.attr.deps:
print(target.proto.sources)
print(target.proto.transitive_imports)
print(target.proto.transitive_sources)
--
MOS_MIGRATED_REVID=94747961
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/proto/ProtoSourcesProvider.java | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java index 2a47fd927e..47d0eb3449 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleConfiguredTargetBuilder.java @@ -363,7 +363,7 @@ public final class RuleConfiguredTargetBuilder { private void checkSkylarkObjectSafe(Object value) { if (!isSimpleSkylarkObjectSafe(value.getClass()) // Java transitive Info Providers are accessible from Skylark. - || value instanceof TransitiveInfoProvider) { + && !(value instanceof TransitiveInfoProvider)) { checkCompositeSkylarkObjectSafe(value); } } 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 a06fa4cedf..9a9fc745b4 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 @@ -29,6 +29,9 @@ import com.google.devtools.build.lib.syntax.SkylarkModule; @Immutable @SkylarkModule(name = "ProtoSourcesProvider", doc = "") public final class ProtoSourcesProvider implements TransitiveInfoProvider { + /** The name of the field in Skylark used to access this class. */ + public static final String SKYLARK_NAME = "proto"; + private final NestedSet<Artifact> transitiveImports; private final NestedSet<Artifact> transitiveProtoSources; private final ImmutableList<Artifact> protoSources; @@ -47,7 +50,10 @@ public final class ProtoSourcesProvider implements TransitiveInfoProvider { * This determines the order of "-I" arguments to the protocol compiler, and * that is probably important */ - @SkylarkCallable(name = "transitive_imports", doc = "", structField = true) + @SkylarkCallable( + name = "transitive_imports", + doc = "Transitive imports including weak dependencies", + structField = true) public NestedSet<Artifact> getTransitiveImports() { return transitiveImports; } @@ -56,7 +62,10 @@ public final class ProtoSourcesProvider implements TransitiveInfoProvider { * Returns the proto sources for this rule and all its dependent protocol * buffer rules. */ - @SkylarkCallable(name = "transitive_proto_sources", doc = "", structField = true) + @SkylarkCallable( + name = "transitive_sources", + doc = "Proto sources for this rule and all its dependent protocol buffer rules.", + structField = true) public NestedSet<Artifact> getTransitiveProtoSources() { return transitiveProtoSources; } @@ -65,7 +74,6 @@ public final class ProtoSourcesProvider implements TransitiveInfoProvider { * 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 = "proto_sources", doc = "", structField = true) public ImmutableList<Artifact> getProtoSources() { return protoSources; } |