aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-10-15 07:45:54 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2015-10-15 10:59:43 +0000
commitc7106d4f6c0f550ad401ef8d8b3df2a5ec7eeea0 (patch)
tree87b970ff0e58d1f4a7541c5225cbaaaf5bfc6181 /src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java
parent1e2a30b0e4fdcf240b5e8e77e7188f813348e988 (diff)
Make recursive package wildcards work in remote repositories.
Ideally, PrepareDepsOfPatternFunction and maybe even RecursivePkgFunction would also be changed to take a PackageIdentifier instead of RootedPath because the less places we store the set of roots, the better, but I've done enough refactoring in the past weeks to not be thrilled by the idea of doing more. -- MOS_MIGRATED_REVID=105486561
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java b/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java
index e81858e93e..34ab492120 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/EnvironmentBackedRecursivePackageProvider.java
@@ -19,6 +19,7 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.PackageIdentifier.RepositoryName;
+import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.packages.BuildFileContainsErrorsException;
@@ -26,12 +27,17 @@ import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.Target;
+import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.pkgcache.RecursivePackageProvider;
+import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyKey;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* A {@link RecursivePackageProvider} backed by an {@link Environment}. Its methods
* may throw {@link MissingDepException} if the package values this depends on haven't been
@@ -91,26 +97,48 @@ public final class EnvironmentBackedRecursivePackageProvider implements Recursiv
@Override
public Iterable<PathFragment> getPackagesUnderDirectory(
- RepositoryName repository, RootedPath directory,
+ RepositoryName repository, PathFragment directory,
ImmutableSet<PathFragment> excludedSubdirectories)
throws MissingDepException {
- PathFragment rootedPathFragment = directory.getRelativePath();
- PathFragment.checkAllPathsAreUnder(excludedSubdirectories, rootedPathFragment);
- RecursivePkgValue lookup = (RecursivePkgValue) env.getValue(
- RecursivePkgValue.key(repository, directory, excludedSubdirectories));
- if (lookup == null) {
- // Typically a null value from Environment.getValue(k) means that either the key k is missing
- // a dependency or an exception was thrown during evaluation of k. Here, if this getValue
- // call returns null in a keep_going build, it can only mean a missing dependency, because
- // RecursivePkgFunction#compute never throws.
- // In a nokeep_going build, a lower-level exception that RecursivePkgFunction ignored may
- // bubble up to here, but we ignore it and depend on the top-level caller to be flexible in
- // the exception types it can accept.
+ PathPackageLocator packageLocator = PrecomputedValue.PATH_PACKAGE_LOCATOR.get(env);
+ if (packageLocator == null) {
throw new MissingDepException();
}
+
+ List<Path> roots = new ArrayList<>();
+ if (repository.isDefault()) {
+ roots.addAll(packageLocator.getPathEntries());
+ } else {
+ RepositoryValue repositoryValue =
+ (RepositoryValue) env.getValue(RepositoryValue.key(repository));
+ if (repositoryValue == null) {
+ throw new MissingDepException();
+ }
+
+ roots.add(repositoryValue.getPath());
+ }
+
+ NestedSetBuilder<String> packageNames = NestedSetBuilder.stableOrder();
+ for (Path root : roots) {
+ PathFragment.checkAllPathsAreUnder(excludedSubdirectories, directory);
+ RecursivePkgValue lookup = (RecursivePkgValue) env.getValue(RecursivePkgValue.key(
+ repository, RootedPath.toRootedPath(root, directory), excludedSubdirectories));
+ if (lookup == null) {
+ // Typically a null value from Environment.getValue(k) means that either the key k is
+ // missing a dependency or an exception was thrown during evaluation of k. Here, if this
+ // getValue call returns null in a keep_going build, it can only mean a missing dependency
+ // because RecursivePkgFunction#compute never throws.
+ // In a nokeep_going build, a lower-level exception that RecursivePkgFunction ignored may
+ // bubble up to here, but we ignore it and depend on the top-level caller to be flexible in
+ // the exception types it can accept.
+ throw new MissingDepException();
+ }
+
+ packageNames.addTransitive(lookup.getPackages());
+ }
// TODO(bazel-team): Make RecursivePkgValue return NestedSet<PathFragment> so this transform is
// unnecessary.
- return Iterables.transform(lookup.getPackages(), PathFragment.TO_PATH_FRAGMENT);
+ return Iterables.transform(packageNames.build(), PathFragment.TO_PATH_FRAGMENT);
}
@Override