diff options
author | Jon Brandvein <brandjon@google.com> | 2016-12-28 17:04:37 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-12-28 18:35:13 +0000 |
commit | 8d10034638509ae9915a652a02c1051f4f2aedae (patch) | |
tree | 74f1913f0718fd88f65c45d7032956066a817ecd /src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java | |
parent | 969d1071441979d980f2995bef1287b58cf57945 (diff) |
Expose to Skylark a merge() method for runfiles objects
This is a quick way to make it possible for Skylark rules to aggregate
and pass on symlinks from their dependencies.
--
PiperOrigin-RevId: 143111353
MOS_MIGRATED_REVID=143111353
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java index 80d67573b2..25fc4ca865 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java @@ -784,7 +784,18 @@ public final class Runfiles { * created. */ public Builder(String workspace, boolean legacyExternalRunfiles) { - this.suffix = new PathFragment(workspace); + this(new PathFragment(workspace), legacyExternalRunfiles); + } + + /** + * Creates a builder with the given suffix. + * @param suffix is the PathFragment wrapping the string specified in workspace() in the + * WORKSPACE file. + * @param legacyExternalRunfiles if the wsname/external/repo symlinks should also be + * created. + */ + private Builder(PathFragment suffix, boolean legacyExternalRunfiles) { + this.suffix = suffix; this.legacyExternalRunfiles = legacyExternalRunfiles; } @@ -1106,4 +1117,19 @@ public final class Runfiles { } } } + + /** + * Provides a Skylark-visible way to merge two Runfiles objects. + */ + @SkylarkCallable( + name = "merge", + doc = "Returns a new runfiles object that includes all the contents of this one and the " + + "argument." + ) + public Runfiles merge(Runfiles other) { + Runfiles.Builder builder = new Runfiles.Builder(suffix, false); + builder.merge(this); + builder.merge(other); + return builder.build(); + } } |