aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
diff options
context:
space:
mode:
authorGravatar nharmata <nharmata@google.com>2017-07-25 17:39:09 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-07-26 10:34:53 +0200
commitde0c535f123acd5344723ca128ead5d4491aed9c (patch)
tree327e964f18d2c7b9eab765b94b2f30eafd1ab4c1 /src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
parente24c97e4fd999ebf566fe30f614c569856a999b2 (diff)
Generalize some of methods in TargetPattern, PrepareDepsOfPatternValue, and RecursivePackageProvider dealing with the concept of "excluded directories".
RELNOTES: None PiperOrigin-RevId: 163074794
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java b/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
index b5ba1da184..0cc2097bf0 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/GraphBackedRecursivePackageProvider.java
@@ -166,10 +166,16 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
ExtendedEventHandler eventHandler,
RepositoryName repository,
PathFragment directory,
+ ImmutableSet<PathFragment> blacklistedSubdirectories,
ImmutableSet<PathFragment> excludedSubdirectories)
throws InterruptedException {
+ PathFragment.checkAllPathsAreUnder(blacklistedSubdirectories, directory);
PathFragment.checkAllPathsAreUnder(excludedSubdirectories, directory);
+ if (excludedSubdirectories.contains(directory)) {
+ return ImmutableList.of();
+ }
+
// Check that this package is covered by at least one of our universe patterns.
boolean inUniverse = false;
for (TargetPatternKey patternKey : universeTargetPatternKeys) {
@@ -206,7 +212,8 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
ImmutableList.Builder<PathFragment> builder = ImmutableList.builder();
for (Path root : roots) {
RootedPath rootedDir = RootedPath.toRootedPath(root, directory);
- TraversalInfo info = new TraversalInfo(rootedDir, excludedSubdirectories);
+ TraversalInfo info =
+ new TraversalInfo(rootedDir, blacklistedSubdirectories, excludedSubdirectories);
collectPackagesUnder(eventHandler, repository, ImmutableSet.of(info), builder);
}
return builder.build();
@@ -225,7 +232,7 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
@Override
public SkyKey apply(TraversalInfo traversalInfo) {
return CollectPackagesUnderDirectoryValue.key(
- repository, traversalInfo.rootedDir, traversalInfo.excludedSubdirectories);
+ repository, traversalInfo.rootedDir, traversalInfo.blacklistedSubdirectories);
}
});
Map<SkyKey, SkyValue> values = graph.getSuccessfulValues(traversalToKeyMap.values());
@@ -251,11 +258,19 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
for (RootedPath subdirectory : subdirectoryTransitivelyContainsPackages.keySet()) {
if (subdirectoryTransitivelyContainsPackages.get(subdirectory)) {
PathFragment subdirectoryRelativePath = subdirectory.getRelativePath();
+ ImmutableSet<PathFragment> blacklistedSubdirectoriesBeneathThisSubdirectory =
+ PathFragment.filterPathsStartingWith(
+ info.blacklistedSubdirectories, subdirectoryRelativePath);
ImmutableSet<PathFragment> excludedSubdirectoriesBeneathThisSubdirectory =
PathFragment.filterPathsStartingWith(
info.excludedSubdirectories, subdirectoryRelativePath);
- subdirTraversalBuilder.add(
- new TraversalInfo(subdirectory, excludedSubdirectoriesBeneathThisSubdirectory));
+ if (!excludedSubdirectoriesBeneathThisSubdirectory.contains(subdirectoryRelativePath)) {
+ subdirTraversalBuilder.add(
+ new TraversalInfo(
+ subdirectory,
+ blacklistedSubdirectoriesBeneathThisSubdirectory,
+ excludedSubdirectoriesBeneathThisSubdirectory));
+ }
}
}
}
@@ -275,16 +290,28 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
private static final class TraversalInfo {
private final RootedPath rootedDir;
+ // Set of blacklisted directories. The graph is assumed to be prepopulated with
+ // CollectPackagesUnderDirectoryValue nodes whose keys have blacklisted packages embedded in
+ // them. Therefore, we need to be careful to request and use the same sort of keys here in our
+ // traversal.
+ private final ImmutableSet<PathFragment> blacklistedSubdirectories;
+ // Set of directories, targets under which should be excluded from the traversal results.
+ // Excluded directory information isn't part of the graph keys in the prepopulated graph, so we
+ // need to perform the filtering ourselves.
private final ImmutableSet<PathFragment> excludedSubdirectories;
- private TraversalInfo(RootedPath rootedDir, ImmutableSet<PathFragment> excludedSubdirectories) {
+ private TraversalInfo(
+ RootedPath rootedDir,
+ ImmutableSet<PathFragment> blacklistedSubdirectories,
+ ImmutableSet<PathFragment> excludedSubdirectories) {
this.rootedDir = rootedDir;
+ this.blacklistedSubdirectories = blacklistedSubdirectories;
this.excludedSubdirectories = excludedSubdirectories;
}
@Override
public int hashCode() {
- return Objects.hashCode(rootedDir, excludedSubdirectories);
+ return Objects.hashCode(rootedDir, blacklistedSubdirectories, excludedSubdirectories);
}
@Override
@@ -295,6 +322,7 @@ public final class GraphBackedRecursivePackageProvider implements RecursivePacka
if (obj instanceof TraversalInfo) {
TraversalInfo otherTraversal = (TraversalInfo) obj;
return Objects.equal(rootedDir, otherTraversal.rootedDir)
+ && Objects.equal(blacklistedSubdirectories, otherTraversal.blacklistedSubdirectories)
&& Objects.equal(excludedSubdirectories, otherTraversal.excludedSubdirectories);
}
return false;