aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java
index 9a4e5a7ca1..6b89a6ee7a 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java
@@ -202,6 +202,16 @@ public final class RepositoryName implements Serializable {
}
/**
+ * Returns the runfiles path for this repository (relative to the x.runfiles/main-repo/
+ * directory). If we don't know the name of this repo (i.e., it is in the main repository),
+ * return an empty path fragment.
+ */
+ public PathFragment getRunfilesPath() {
+ return isDefault() || isMain()
+ ? PathFragment.EMPTY_FRAGMENT : new PathFragment("..").getRelative(strippedName());
+ }
+
+ /**
* Returns the repository name, with leading "{@literal @}" (or "" for the default repository).
*/
@Override