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
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternFunction.java
index cebe429..e776281 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternFunction.java
@@ -42,6 +42,8 @@
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
@@ -214,9 +216,20 @@
ImmutableSet<PathFragment> excludedPathFragments =
TargetPatternResolverUtil.getPathFragments(excludedSubdirectories);
PathFragment pathFragment = TargetPatternResolverUtil.getPathFragment(directory);
- // TODO(bazel-team): This is where we need to depend on the RepositoryValue of a remote
- // repository in order figure out its root and thus support recursive package search in them.
- for (Path root : pkgPath.getPathEntries()) {
+ List<Path> roots = new ArrayList<>();
+ if (repository.isDefault()) {
+ roots.addAll(pkgPath.getPathEntries());
+ } else {
+ RepositoryValue repositoryValue =
+ (RepositoryValue) env.getValue(RepositoryValue.key(repository));
+ if (repositoryValue == null) {
+ throw new MissingDepException();
+ }
+
+ roots.add(repositoryValue.getPath());
+ }
+
+ for (Path root : roots) {
RootedPath rootedPath = RootedPath.toRootedPath(root, pathFragment);
SkyValue token = env.getValue(PrepareDepsOfTargetsUnderDirectoryValue.key(
repository, rootedPath, excludedPathFragments, policy));