aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java
diff options
context:
space:
mode:
authorGravatar Brian Silverman <bsilver16384@gmail.com>2015-08-27 13:40:02 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-08-27 14:45:37 +0000
commit2ccd056fd911f821520c97dc8d064a42672a6056 (patch)
tree823ac18b6924d54e67b0af13aec5fcd32e8906e0 /src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java
parenta37e86c720dcb4a18368b5594676faceb5050e2e (diff)
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/FilesToRunProvider.java23
1 files changed, 21 insertions, 2 deletions
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<Artifact> 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;
}