aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/cmdline
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2017-02-17 14:48:48 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2017-02-17 14:57:32 +0000
commite36a66cd6e35e5b4b276f2b6ce63e1c691bcb02c (patch)
tree7d2b273bf2948aa350147a91da3a6b4ad0111e34 /src/main/java/com/google/devtools/build/lib/cmdline
parent75639985d593f683ba13d2ceb38ec310662fb56b (diff)
*** Reason for rollback *** Broke tests on CI: http://ci.bazel.io/job/bazel-tests/570/ *** Original change description *** Roll forward execroot change RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Cust... -- PiperOrigin-RevId: 147833177 MOS_MIGRATED_REVID=147833177
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/cmdline')
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/Label.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/cmdline/RepositoryName.java14
3 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
index 7e3649102c..0fb7a08b10 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
@@ -72,7 +72,7 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin
public static final PackageIdentifier EXTERNAL_PACKAGE_IDENTIFIER =
PackageIdentifier.createInMainRepo(EXTERNAL_PACKAGE_NAME);
- public static final String EXTERNAL_PATH_PREFIX = "..";
+ public static final String EXTERNAL_PATH_PREFIX = "external";
private static final Interner<Label> LABEL_INTERNER = BlazeInterners.newWeakInterner();
@@ -336,12 +336,12 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin
* it will returns an empty string.
*/
@SkylarkCallable(name = "workspace_root", structField = true,
- doc = "Returns the execution root for the workspace of this label, relative to the "
- + "execroot. For instance:<br>"
+ doc = "Returns the execution root for the workspace of this label, relative to the execroot. "
+ + "For instance:<br>"
+ "<pre class=language-python>Label(\"@repo//pkg/foo:abc\").workspace_root =="
- + " \"../repo\"</pre>")
+ + " \"external/repo\"</pre>")
public String getWorkspaceRoot() {
- return packageIdentifier.getRepository().getPathUnderExecRoot().toString();
+ return packageIdentifier.getRepository().getSourceRoot().toString();
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
index f8dda81582..1e2e3d0385 100644
--- a/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
+++ b/src/main/java/com/google/devtools/build/lib/cmdline/PackageIdentifier.java
@@ -20,8 +20,10 @@ import com.google.devtools.build.lib.concurrent.BlazeInterners;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.vfs.Canonicalizer;
import com.google.devtools.build.lib.vfs.PathFragment;
+
import java.io.Serializable;
import java.util.Objects;
+
import javax.annotation.concurrent.Immutable;
/**
@@ -125,6 +127,14 @@ public final class PackageIdentifier implements Comparable<PackageIdentifier>, S
return repository.getPathUnderExecRoot().getRelative(pkgName);
}
+ /**
+ * Returns the runfiles/execRoot path for this repository (relative to the x.runfiles/main-repo/
+ * directory).
+ */
+ public PathFragment getRunfilesPath() {
+ return repository.getRunfilesPath().getRelative(pkgName);
+ }
+
public PackageIdentifier makeAbsolute() {
if (!repository.isDefault()) {
return this;
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 5f1421f9c6..ba0f6b407b 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
@@ -22,6 +22,7 @@ import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.StringCanonicalizer;
import com.google.devtools.build.lib.util.StringUtilities;
import com.google.devtools.build.lib.vfs.PathFragment;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -213,8 +214,8 @@ public final class RepositoryName implements Serializable {
}
/**
- * Returns the runfiles/execRoot path for this repository: ../reponame. If we don't know the name
- * of this repo (i.e., it is in the main repository), return an empty path fragment.
+ * Returns the runfiles/execRoot path for this repository. 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 getPathUnderExecRoot() {
return isDefault() || isMain()
@@ -223,6 +224,15 @@ public final class RepositoryName implements Serializable {
}
/**
+ * Returns the runfiles path relative to the x.runfiles/main-repo directory.
+ */
+ // TODO(kchodorow): remove once execroot is reorg-ed.
+ 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