Skip to content

Commit

Permalink
Allow blacklisted package prefixes to be passed in lazily via a Suppl…
Browse files Browse the repository at this point in the history
…ier.

--
MOS_MIGRATED_REVID=123424674
  • Loading branch information
ericfelly authored and dslomov committed May 30, 2016
1 parent c02ed17 commit f37daa0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public void getTargetsMatchingPattern(
provider, eventHandler, targetPatternKey.getPolicy(), threadPool);
TargetPattern parsedPattern = targetPatternKey.getParsedPattern();
ImmutableSet<PathFragment> subdirectoriesToExclude =
targetPatternKey.getAllSubdirectoriesToExclude(blacklistPatternsSupplier.get());
targetPatternKey.getAllSubdirectoriesToExclude(blacklistPatternsSupplier);
FilteringBatchingUniquifyingCallback wrapper =
new FilteringBatchingUniquifyingCallback(callback);
parsedPattern.eval(resolver, subdirectoriesToExclude, wrapper, QueryException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
Expand All @@ -23,6 +25,7 @@
import com.google.devtools.build.lib.cmdline.ResolvedTargets.Builder;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.cmdline.TargetPattern;
import com.google.devtools.build.lib.cmdline.TargetPattern.Type;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
import com.google.devtools.build.lib.pkgcache.FilteringPolicies;
Expand Down Expand Up @@ -208,14 +211,21 @@ public ImmutableSet<PathFragment> getExcludedSubdirectories() {

public ImmutableSet<PathFragment> getAllSubdirectoriesToExclude(
Iterable<PathFragment> blacklistedPackagePrefixes) {
return getAllSubdirectoriesToExclude(Suppliers.ofInstance(blacklistedPackagePrefixes));
}

public ImmutableSet<PathFragment> getAllSubdirectoriesToExclude(
Supplier<? extends Iterable<PathFragment>> blacklistedPackagePrefixes) {
ImmutableSet.Builder<PathFragment> excludedPathsBuilder = ImmutableSet.builder();
excludedPathsBuilder.addAll(getExcludedSubdirectories());
for (PathFragment blacklistedPackagePrefix : blacklistedPackagePrefixes) {
PackageIdentifier pkgIdForBlacklistedDirectorPrefix = PackageIdentifier.create(
parsedPattern.getDirectory().getRepository(),
blacklistedPackagePrefix);
if (parsedPattern.containsBelowDirectory(pkgIdForBlacklistedDirectorPrefix)) {
excludedPathsBuilder.add(blacklistedPackagePrefix);
if (parsedPattern.getType() == Type.TARGETS_BELOW_DIRECTORY) {
for (PathFragment blacklistedPackagePrefix : blacklistedPackagePrefixes.get()) {
PackageIdentifier pkgIdForBlacklistedDirectorPrefix = PackageIdentifier.create(
parsedPattern.getDirectory().getRepository(),
blacklistedPackagePrefix);
if (parsedPattern.containsBelowDirectory(pkgIdForBlacklistedDirectorPrefix)) {
excludedPathsBuilder.add(blacklistedPackagePrefix);
}
}
}
return excludedPathsBuilder.build();
Expand Down

0 comments on commit f37daa0

Please sign in to comment.