aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java
diff options
context:
space:
mode:
authorGravatar kchodorow <kchodorow@google.com>2017-07-11 22:22:22 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-12 08:50:25 +0200
commit63570924746274c128e80d3a43558e0d3fad3051 (patch)
tree5e08769586efd9efd87a926d47bc9770e68f2c24 /src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java
parent3e36d7a88a39d3bb3442c6c2e67c6d83cf0ae0e4 (diff)
Automated rollback of commit 937350211dcd55a4714ec32ebbf33fffcc42cdf2.
*** Reason for rollback *** Broke the go rules (of course) See http://ci.bazel.io/job/rules_go/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/1044/console. *** Original change description *** Resolve references to @main-repo//foo to //foo Bazel was creating an dummy external repository for @main-repo, which doesn't work with package paths and will cause conflicts once @main-repo//foo and //foo refer to the same path. This adds a "soft pull" option to WorkspaceNameFunction: it can either parse the entire WORKSPACE file to find the name or just the first section. That way PackageLookupFunction can find the repository name without causing a circular dependency. This should have no ch... *** PiperOrigin-RevId: 161572272
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java
index 98fe8b2416..4da943b6ab 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/WorkspaceNameValue.java
@@ -28,6 +28,9 @@ import java.util.Objects;
* the WORKSPACE file.
*/
public class WorkspaceNameValue implements SkyValue {
+ private static final SkyKey KEY =
+ LegacySkyKey.create(SkyFunctions.WORKSPACE_NAME, DummyArgument.INSTANCE);
+
private final String workspaceName;
private WorkspaceNameValue(String workspaceName) {
@@ -41,21 +44,9 @@ public class WorkspaceNameValue implements SkyValue {
return workspaceName;
}
- /** Returns the {@link SkyKey} for {@link WorkspaceNameValue}s. */
+ /** Returns the (singleton) {@link SkyKey} for {@link WorkspaceNameValue}s. */
public static SkyKey key() {
- return createKey(false);
- }
-
- /**
- * Returns the {@link SkyKey} for a less-aggressive {@link WorkspaceNameValue} query, when
- * we don't want to parse the whole WORKSPACE file.
- */
- public static SkyKey firstChunk() {
- return createKey(true);
- }
-
- private static SkyKey createKey(boolean firstChunk) {
- return LegacySkyKey.create(SkyFunctions.WORKSPACE_NAME, firstChunk);
+ return KEY;
}
/** Returns a {@link WorkspaceNameValue} for a workspace with the given name. */
@@ -81,4 +72,28 @@ public class WorkspaceNameValue implements SkyValue {
public String toString() {
return String.format("WorkspaceNameValue[name=%s]", workspaceName);
}
+
+ /** Singleton class used as the {@link SkyKey#argument} for {@link WorkspaceNameValue#key}. */
+ public static final class DummyArgument {
+ static final int HASHCODE = DummyArgument.class.getCanonicalName().hashCode();
+ public static final DummyArgument INSTANCE = new DummyArgument();
+
+ private DummyArgument() {
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof DummyArgument;
+ }
+
+ @Override
+ public int hashCode() {
+ return HASHCODE;
+ }
+
+ @Override
+ public String toString() {
+ return "#";
+ }
+ }
}