diff options
author | John Cater <jcater@google.com> | 2016-12-12 17:01:03 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-12-12 20:35:32 +0000 |
commit | fcc0801601f238858bc335eb3f25f66a4eee1909 (patch) | |
tree | 0b1c481f076b23d73ec41d9b0dc4340791168498 /src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java | |
parent | 022748861e12268441f8519ed63a4a31e79b5e4a (diff) |
Fixed PackageLookupFunction to check for all possible build file names when loading external repositories.
Fixes #2198.
--
Change-Id: Ife0232f8e4652a90bc3b7dceec6e67312a142879
Reviewed-on: https://cr.bazel.build/7691
PiperOrigin-RevId: 141771126
MOS_MIGRATED_REVID=141771126
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.java | 26 |
1 files changed, 15 insertions, 11 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 f96ca84d57..2723c6aa21 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 @@ -291,7 +291,7 @@ public class PackageLookupFunction implements SkyFunction { * <p>To do this, it looks up the "external" package and finds a path mapping for the repository * name. */ - private static PackageLookupValue computeExternalPackageLookupValue( + private PackageLookupValue computeExternalPackageLookupValue( SkyKey skyKey, Environment env, PackageIdentifier packageIdentifier) throws PackageLookupFunctionException, InterruptedException { PackageIdentifier id = (PackageIdentifier) skyKey.argument(); @@ -307,17 +307,21 @@ public class PackageLookupFunction implements SkyFunction { throw new PackageLookupFunctionException(new BuildFileNotFoundException(id, e.getMessage()), Transience.PERSISTENT); } - BuildFileName buildFileName = BuildFileName.BUILD; - PathFragment buildFileFragment = id.getPackageFragment().getChild(buildFileName.getFilename()); - RootedPath buildFileRootedPath = RootedPath.toRootedPath(repositoryValue.getPath(), - buildFileFragment); - FileValue fileValue = getFileValue(buildFileRootedPath, env, packageIdentifier); - if (fileValue == null) { - return null; - } - if (fileValue.isFile()) { - return PackageLookupValue.success(repositoryValue.getPath(), buildFileName); + // This checks for the build file names in the correct precedence order. + for (BuildFileName buildFileName : buildFilesByPriority) { + PathFragment buildFileFragment = + id.getPackageFragment().getChild(buildFileName.getFilename()); + RootedPath buildFileRootedPath = + RootedPath.toRootedPath(repositoryValue.getPath(), buildFileFragment); + FileValue fileValue = getFileValue(buildFileRootedPath, env, packageIdentifier); + if (fileValue == null) { + return null; + } + + if (fileValue.isFile()) { + return PackageLookupValue.success(repositoryValue.getPath(), buildFileName); + } } return PackageLookupValue.NO_BUILD_FILE_VALUE; |