aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java
diff options
context:
space:
mode:
authorGravatar kchodorow <kchodorow@google.com>2017-07-11 18:12:55 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-11 18:26:24 +0200
commit937350211dcd55a4714ec32ebbf33fffcc42cdf2 (patch)
tree77f2cb3d5b6c4fe1e66691a3f0bc4041593168c4 /src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java
parenta334363a500fb9df953fe2c70184ee013ff77ccb (diff)
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 change of behavior and is already tested in https://github.com/bazelbuild/bazel/blob/master/src/test/shell/bazel/workspace_test.sh#L176. PiperOrigin-RevId: 161536466
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java
index c0a115ad6c..d264cea205 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelValidator;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.packages.BuildFileNotFoundException;
import com.google.devtools.build.lib.packages.ErrorDeterminingRepositoryException;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
@@ -294,8 +295,20 @@ public class PackageLookupFunction implements SkyFunction {
private PackageLookupValue computeExternalPackageLookupValue(
SkyKey skyKey, Environment env, PackageIdentifier packageIdentifier)
throws PackageLookupFunctionException, InterruptedException {
+ // Check if this is the main repository.
PackageIdentifier id = (PackageIdentifier) skyKey.argument();
- SkyKey repositoryKey = RepositoryValue.key(id.getRepository());
+ RepositoryName repositoryName = id.getRepository();
+ WorkspaceNameValue workspaceNameValue = (WorkspaceNameValue)
+ env.getValue(WorkspaceNameValue.firstChunk());
+ if (workspaceNameValue == null) {
+ return null;
+ }
+ if (repositoryName.strippedName().equals(workspaceNameValue.getName())) {
+ return (PackageLookupValue) env.getValue(PackageLookupValue.key(
+ PackageIdentifier.createInMainRepo(id.getPackageFragment())));
+ }
+ // Otherwise look up the repository.
+ SkyKey repositoryKey = RepositoryValue.key(repositoryName);
RepositoryValue repositoryValue;
try {
repositoryValue = (RepositoryValue) env.getValueOrThrow(