From ac5451532ee078f963d1d784155469d6a5d67524 Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Fri, 29 May 2015 11:04:19 +0000 Subject: 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 --- .../build/lib/analysis/RuleConfiguredTargetBuilder.java | 2 +- .../build/lib/rules/proto/ProtoSourcesProvider.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/main/java/com') 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 transitiveImports; private final NestedSet transitiveProtoSources; private final ImmutableList 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 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 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 getProtoSources() { return protoSources; } -- cgit v1.2.3