diff options
author | Eric Fellheimer <felly@google.com> | 2015-08-14 21:49:16 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2015-08-17 09:08:53 +0000 |
commit | 2cca702674fbfc7ff4cac44b4997f69f9512698e (patch) | |
tree | 55f1b9a512a4a437574edc5128c05161d0bc3c58 /src/main/java/com | |
parent | c4893c39d747c7ac9152da76a9a626e7cdacb456 (diff) |
Allow for metadata lookup alongside the existing #prepareAndGet() graph construction.
--
MOS_MIGRATED_REVID=100709648
Diffstat (limited to 'src/main/java/com')
4 files changed, 55 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java index 0c8b174802..e250eba121 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java @@ -151,13 +151,15 @@ public class PathPackageLocator implements Serializable { * @param eventHandler The eventHandler. * @param workspace The nearest enclosing package root directory. * @param clientWorkingDirectory The client's working directory. + * @param checkExistence If true, verify that the element exists before adding it to the locator. * @return a list of {@link Path}s. */ public static PathPackageLocator create(Path outputBase, List<String> pathElements, EventHandler eventHandler, Path workspace, - Path clientWorkingDirectory) { + Path clientWorkingDirectory, + boolean checkExistence) { List<Path> resolvedPaths = new ArrayList<>(); final String workspaceWildcard = "%workspace%"; @@ -179,13 +181,36 @@ public class PathPackageLocator implements Serializable { + "If so, please use the '" + workspaceWildcard + "' wildcard.")); } - if (rootPath.exists()) { + if (!checkExistence || rootPath.exists()) { resolvedPaths.add(rootPath); } } return new PathPackageLocator(outputBase, resolvedPaths); } + /** + * A factory of PathPackageLocators from a list of path elements. Elements + * may contain "%workspace%", indicating the workspace. + * + * @param outputBase the output base. Can be null if remote repositories are not in use. + * @param pathElements Each element must be an absolute path, relative path, + * or some string "%workspace%" + relative, where relative is itself a + * relative path. The special symbol "%workspace%" means to interpret + * the path relative to the nearest enclosing workspace. Relative + * paths are interpreted relative to the client's working directory, + * which may be below the workspace. + * @param eventHandler The eventHandler. + * @param workspace The nearest enclosing package root directory. + * @param clientWorkingDirectory The client's working directory. + * @return a list of {@link Path}s. + */ + public static PathPackageLocator create(Path outputBase, + List<String> pathElements, EventHandler eventHandler, Path workspace, + Path clientWorkingDirectory) { + return create(outputBase, pathElements, eventHandler, workspace, clientWorkingDirectory, + /*checkExistence=*/true); + } + /** * Returns the path to the WORKSPACE file for this build. * diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index 93c0ce898f..8b482e5aa2 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -1255,10 +1255,7 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { @Override public EvaluationResult<SkyValue> prepareAndGet(Collection<String> patterns, int numThreads, EventHandler eventHandler) throws InterruptedException { - SkyframeTargetPatternEvaluator patternEvaluator = - (SkyframeTargetPatternEvaluator) packageManager.getTargetPatternEvaluator(); - String offset = patternEvaluator.getOffset(); - SkyKey skyKey = PrepareDepsOfPatternsValue.key(ImmutableList.copyOf(patterns), offset); + SkyKey skyKey = getPrepareDepsKey(patterns); EvaluationResult<SkyValue> evaluationResult = buildDriver.evaluate(ImmutableList.of(skyKey), true, numThreads, eventHandler); Preconditions.checkNotNull(evaluationResult.getWalkableGraph(), patterns); @@ -1266,6 +1263,21 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { } /** + * Get metadata related to the prepareAndGet() lookup. Resulting data is specific to the + * underlying evaluation implementation. + */ + public String prepareAndGetMetadata(Collection<String> patterns) { + return buildDriver.meta(ImmutableList.of(getPrepareDepsKey(patterns))); + } + + private SkyKey getPrepareDepsKey(Collection<String> patterns) { + SkyframeTargetPatternEvaluator patternEvaluator = + (SkyframeTargetPatternEvaluator) packageManager.getTargetPatternEvaluator(); + String offset = patternEvaluator.getOffset(); + return PrepareDepsOfPatternsValue.key(ImmutableList.copyOf(patterns), offset); + } + + /** * Returns the generating {@link Action} of the given {@link Artifact}. * * <p>For use for legacy support from {@code BuildView} only. diff --git a/src/main/java/com/google/devtools/build/skyframe/BuildDriver.java b/src/main/java/com/google/devtools/build/skyframe/BuildDriver.java index 938735be94..16c2d9dd26 100644 --- a/src/main/java/com/google/devtools/build/skyframe/BuildDriver.java +++ b/src/main/java/com/google/devtools/build/skyframe/BuildDriver.java @@ -28,5 +28,11 @@ public interface BuildDriver { Iterable<SkyKey> roots, boolean keepGoing, int numThreads, EventHandler reporter) throws InterruptedException; + /** + * Retrieve metadata about the computation over the given roots. Data returned is specific to the + * underlying evaluator implementation. + */ + String meta(Iterable<SkyKey> roots); + MemoizingEvaluator getGraphForTesting(); } diff --git a/src/main/java/com/google/devtools/build/skyframe/SequentialBuildDriver.java b/src/main/java/com/google/devtools/build/skyframe/SequentialBuildDriver.java index 9b7f0366d2..5eee3a38a4 100644 --- a/src/main/java/com/google/devtools/build/skyframe/SequentialBuildDriver.java +++ b/src/main/java/com/google/devtools/build/skyframe/SequentialBuildDriver.java @@ -39,7 +39,12 @@ public class SequentialBuildDriver implements BuildDriver { } } - @Override + @Override + public String meta(Iterable<SkyKey> of) { + return ""; + } + + @Override public MemoizingEvaluator getGraphForTesting() { return memoizingEvaluator; } |