aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java
diff options
context:
space:
mode:
authorGravatar Mark Schaller <mschaller@google.com>2015-06-18 16:51:03 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-06-19 11:03:47 +0000
commit20c2d03115b249154fb67e8d9b022267239d8357 (patch)
tree91040458dfb9799d1340d22cbc457bda3310362c /src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java
parent9523bb90d784b60833e262d5453f3d1927aa87ef (diff)
*** Reason for rollback *** [] *** Original change description *** Implement smart negation for target pattern sequences This change uses the types of target patterns, and the order they appear in the sequence, to construct a more efficiently processable sequence of target pattern keys. Redundant patterns are eliminated and negated TargetsBelowDirectory patterns are excluded from higher-up positive patterns. -- MOS_MIGRATED_REVID=96317483
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java
index 1f1b369396..1f665e0152 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternValue.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.cmdline.TargetPattern;
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;
import com.google.devtools.build.lib.pkgcache.FilteringPolicy;
import com.google.devtools.build.lib.syntax.Label;
import com.google.devtools.build.lib.syntax.Label.SyntaxException;
@@ -111,14 +112,9 @@ public final class TargetPatternValue implements SkyValue {
/**
* Returns an iterable of {@link TargetPatternSkyKeyOrException}, with {@link TargetPatternKey}
- * arguments. If a provided pattern fails to parse, an element in the returned iterable will
- * throw when its {@link TargetPatternSkyKeyOrException#getSkyKey} method is called and will
- * return the failing pattern when its {@link
- * TargetPatternSkyKeyOrException#getOriginalPattern} method is called.
- *
- * <p>There may be fewer returned elements than patterns provided as input. This function may
- * combine patterns to return an iterable of SkyKeys that is equivalent but more efficient to
- * evaluate.
+ * arguments, in the same order as the list of patterns provided as input. If a provided pattern
+ * fails to parse, the element in the returned iterable corresponding to it will throw when its
+ * {@link TargetPatternSkyKeyOrException#getSkyKey} method is called.
*
* @param patterns The list of patterns, eg "-foo/biz...". If a pattern's first character is "-",
* it is treated as a negative pattern.
@@ -129,24 +125,23 @@ public final class TargetPatternValue implements SkyValue {
public static Iterable<TargetPatternSkyKeyOrException> keys(List<String> patterns,
FilteringPolicy policy, String offset) {
TargetPattern.Parser parser = new TargetPattern.Parser(offset);
- AggregatedPatterns aggregatedPatterns = new AggregatedPatterns(policy, offset);
ImmutableList.Builder<TargetPatternSkyKeyOrException> builder = ImmutableList.builder();
for (String pattern : patterns) {
boolean positive = !pattern.startsWith("-");
String absoluteValueOfPattern = positive ? pattern : pattern.substring(1);
+ TargetPattern targetPattern;
try {
- aggregatedPatterns.addPattern(
- new SignedPattern(positive, parser.parse(absoluteValueOfPattern)));
+ targetPattern = parser.parse(absoluteValueOfPattern);
} catch (TargetParsingException e) {
builder.add(new TargetPatternSkyKeyException(e, absoluteValueOfPattern));
+ continue;
}
+ TargetPatternKey targetPatternKey = new TargetPatternKey(targetPattern,
+ positive ? policy : FilteringPolicies.NO_FILTER, /*isNegative=*/!positive, offset,
+ ImmutableSet.<String>of());
+ SkyKey skyKey = new SkyKey(SkyFunctions.TARGET_PATTERN, targetPatternKey);
+ builder.add(new TargetPatternSkyKeyValue(skyKey));
}
-
- for (TargetPatternKey patternKey : aggregatedPatterns.build()) {
- builder.add(
- new TargetPatternSkyKeyValue(new SkyKey(SkyFunctions.TARGET_PATTERN, patternKey)));
- }
-
return builder.build();
}