From 2ccd056fd911f821520c97dc8d064a42672a6056 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Thu, 27 Aug 2015 13:40:02 +0000 Subject: Expose FilesToRun provider to Skylark. It is now possible to get the main executable of *_binary rules with target.files_to_run.executable. -- Change-Id: I4a81f216bdd237fc5b0e7dbd7d0a312558f3cf2c Reviewed-on: https://bazel-review.googlesource.com/#/c/1760/ MOS_MIGRATED_REVID=101675365 --- .../build/lib/analysis/FilesToRunProvider.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java b/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java index 216a782e92..287593403f 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java @@ -20,6 +20,8 @@ import com.google.devtools.build.lib.actions.EmptyRunfilesSupplier; import com.google.devtools.build.lib.actions.RunfilesSupplier; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.syntax.Label; +import com.google.devtools.build.lib.syntax.SkylarkCallable; +import com.google.devtools.build.lib.syntax.SkylarkModule; import javax.annotation.Nullable; @@ -27,7 +29,10 @@ import javax.annotation.Nullable; * Returns information about executables produced by a target and the files needed to run it. */ @Immutable +@SkylarkModule(name = "FilesToRunProvider", doc = "") public final class FilesToRunProvider implements TransitiveInfoProvider { + /** The name of the field in Skylark used to access this class. */ + public static final String SKYLARK_NAME = "files_to_run"; private final Label label; private final ImmutableList filesToRun; @@ -75,7 +80,14 @@ public final class FilesToRunProvider implements TransitiveInfoProvider { /** * Returns the Executable or null if it does not exist. */ - @Nullable public Artifact getExecutable() { + @SkylarkCallable( + name = "executable", + doc = "The main executable or None if it does not exist", + structField = true, + allowReturnNones = true + ) + @Nullable + public Artifact getExecutable() { return executable; } @@ -83,7 +95,14 @@ public final class FilesToRunProvider implements TransitiveInfoProvider { * Returns the RunfilesManifest or null if it does not exist. It is a shortcut to * getRunfilesSupport().getRunfilesManifest(). */ - @Nullable public Artifact getRunfilesManifest() { + @SkylarkCallable( + name = "runfiles_manifest", + doc = "The runfiles manifest or None if it does not exist", + structField = true, + allowReturnNones = true + ) + @Nullable + public Artifact getRunfilesManifest() { return runfilesSupport != null ? runfilesSupport.getRunfilesManifest() : null; } -- cgit v1.2.3