aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/pkgcache
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/pkgcache')
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/PackageManager.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluator.java45
-rw-r--r--src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternPreloader.java46
3 files changed, 48 insertions, 45 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageManager.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageManager.java
index 0bbfae7ced..13f38cd1e5 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageManager.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageManager.java
@@ -59,7 +59,7 @@ public interface PackageManager extends PackageProvider, CachingPackageLocator {
/**
* Retrieve a target pattern parser that works with this package manager.
*/
- TargetPatternEvaluator newTargetPatternEvaluator();
+ TargetPatternPreloader newTargetPatternPreloader();
/**
* Construct a new {@link TransitivePackageLoader}.
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluator.java b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluator.java
index a9e69bd5b4..ea2651d6ab 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluator.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternEvaluator.java
@@ -14,17 +14,13 @@
package com.google.devtools.build.lib.pkgcache;
-import com.google.common.annotations.VisibleForTesting;
import com.google.devtools.build.lib.cmdline.ResolvedTargets;
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.concurrent.ThreadSafety;
-import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadHostile;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.packages.Target;
import com.google.devtools.build.lib.vfs.PathFragment;
-import java.util.Collection;
import java.util.List;
-import java.util.Map;
/**
* A parser for target patterns. Target patterns are a generalisation of
@@ -50,49 +46,10 @@ public interface TargetPatternEvaluator {
* computed. Implements the specification described in the class-level comment.
*/
ResolvedTargets<Target> parseTargetPatternList(
+ PathFragment relativeWorkingDirectory,
ExtendedEventHandler eventHandler,
List<String> targetPatterns,
FilteringPolicy policy,
boolean keepGoing)
throws TargetParsingException, InterruptedException;
-
- /**
- * Attempts to parse a single target pattern while consulting the package cache to check for the
- * existence of packages and directories and the build targets in them. Implements the
- * specification described in the class-level comment. Returns a {@link ResolvedTargets} object.
- *
- * <p>If an error is encountered, a {@link TargetParsingException} is thrown, unless {@code
- * keepGoing} is set to true. In that case, the returned object will have its error bit set.
- */
- ResolvedTargets<Target> parseTargetPattern(
- ExtendedEventHandler eventHandler, String pattern, boolean keepGoing)
- throws TargetParsingException, InterruptedException;
-
- /**
- * Attempts to parse and load the given collection of patterns; the returned map contains the
- * results for each pattern successfully parsed.
- *
- * <p>If an error is encountered, a {@link TargetParsingException} is thrown, unless {@code
- * keepGoing} is set to true. In that case, the patterns that failed to load have the error flag
- * set.
- */
- Map<String, ResolvedTargets<Target>> preloadTargetPatterns(
- ExtendedEventHandler eventHandler, Collection<String> patterns, boolean keepGoing)
- throws TargetParsingException, InterruptedException;
-
- /**
- * Update the parser's offset, given the workspace and working directory.
- *
- * @param relativeWorkingDirectory the working directory relative to the workspace
- */
- @ThreadHostile
- void updateOffset(PathFragment relativeWorkingDirectory);
-
- /**
- * @return the offset of this parser from the root of the workspace.
- * Non-absolute package-names will be resolved relative
- * to this offset.
- */
- @VisibleForTesting
- String getOffset();
}
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternPreloader.java b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternPreloader.java
new file mode 100644
index 0000000000..3b89098be2
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternPreloader.java
@@ -0,0 +1,46 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.pkgcache;
+
+import com.google.devtools.build.lib.cmdline.ResolvedTargets;
+import com.google.devtools.build.lib.cmdline.TargetParsingException;
+import com.google.devtools.build.lib.concurrent.ThreadSafety;
+import com.google.devtools.build.lib.events.ExtendedEventHandler;
+import com.google.devtools.build.lib.packages.Target;
+import com.google.devtools.build.lib.vfs.PathFragment;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * A preloader for target patterns. See {@link TargetPatternEvaluator} for more details.
+ */
+@ThreadSafety.ThreadSafe
+public interface TargetPatternPreloader {
+ /**
+ * Attempts to parse and load the given collection of patterns; the returned map contains the
+ * results for each pattern successfully parsed. As a side effect, calling this method populates
+ * the Skyframe graph, so subsequent calls are faster.
+ *
+ * <p>If an error is encountered, a {@link TargetParsingException} is thrown, unless {@code
+ * keepGoing} is set to true. In that case, the patterns that failed to load have the error flag
+ * set.
+ */
+ Map<String, ResolvedTargets<Target>> preloadTargetPatterns(
+ ExtendedEventHandler eventHandler,
+ PathFragment relativeWorkingDirectory,
+ Collection<String> patterns,
+ boolean keepGoing)
+ throws TargetParsingException, InterruptedException;
+}