diff options
author | 2015-09-25 16:01:47 +0000 | |
---|---|---|
committer | 2015-09-28 11:39:14 +0000 | |
commit | 7e04a668235f90f02d64e3133ab6c3f1d363fdfd (patch) | |
tree | 2227633330f2f0548d6e494b584e11aa1062a1a6 /src/main/java/com/google/devtools/build/lib/skyframe | |
parent | a00b8b51926c67d572b9a1d28560669b80b7afc6 (diff) |
Move BuildView.getActionGraph to SkyframeExecutor.
This is another case of uninterruptible evaluation, which directly accesses
SkyframeExecutor.errorEventListener.
--
MOS_MIGRATED_REVID=103946310
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java | 74 |
1 files changed, 43 insertions, 31 deletions
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 0ff269d2bd..bc3d0771e1 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 @@ -38,6 +38,7 @@ import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.ActionCacheChecker; import com.google.devtools.build.lib.actions.ActionExecutionContextFactory; import com.google.devtools.build.lib.actions.ActionExecutionStatusReporter; +import com.google.devtools.build.lib.actions.ActionGraph; import com.google.devtools.build.lib.actions.ActionInputFileCache; import com.google.devtools.build.lib.actions.ActionLogBufferPathGenerator; import com.google.devtools.build.lib.actions.Artifact; @@ -1451,44 +1452,55 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { } /** - * Returns the generating {@link Action} of the given {@link Artifact}. - * - * <p>For use for legacy support from {@code BuildView} only. + * Returns the generating action of a given artifact ({@code null} if it's a source artifact). */ - @ThreadSafety.ThreadSafe - public Action getGeneratingAction(final Artifact artifact) { + private Action getGeneratingAction(Artifact artifact) throws InterruptedException { if (artifact.isSourceArtifact()) { return null; } - try { - return callUninterruptibly(new Callable<Action>() { - @Override - public Action call() throws InterruptedException { - ArtifactOwner artifactOwner = artifact.getArtifactOwner(); - Preconditions.checkState(artifactOwner instanceof ActionLookupValue.ActionLookupKey, - "%s %s", artifact, artifactOwner); - SkyKey actionLookupKey = - ActionLookupValue.key((ActionLookupValue.ActionLookupKey) artifactOwner); + ArtifactOwner artifactOwner = artifact.getArtifactOwner(); + Preconditions.checkState(artifactOwner instanceof ActionLookupValue.ActionLookupKey, + "%s %s", artifact, artifactOwner); + SkyKey actionLookupKey = + ActionLookupValue.key((ActionLookupValue.ActionLookupKey) artifactOwner); + + synchronized (valueLookupLock) { + // Note that this will crash (attempting to run a configured target value builder after + // analysis) after a failed --nokeep_going analysis in which the configured target that + // failed was a (transitive) dependency of the configured target that should generate + // this action. We don't expect callers to query generating actions in such cases. + EvaluationResult<ActionLookupValue> result = buildDriver.evaluate( + ImmutableList.of(actionLookupKey), false, ResourceUsage.getAvailableProcessors(), + errorEventListener); + return result.hasError() + ? null + : result.get(actionLookupKey).getGeneratingAction(artifact); + } + } - synchronized (valueLookupLock) { - // Note that this will crash (attempting to run a configured target value builder after - // analysis) after a failed --nokeep_going analysis in which the configured target that - // failed was a (transitive) dependency of the configured target that should generate - // this action. We don't expect callers to query generating actions in such cases. - EvaluationResult<ActionLookupValue> result = buildDriver.evaluate( - ImmutableList.of(actionLookupKey), false, ResourceUsage.getAvailableProcessors(), - errorEventListener); - return result.hasError() - ? null - : result.get(actionLookupKey).getGeneratingAction(artifact); - } + /** + * Returns an action graph. + * + * <p>For legacy compatibility only. + */ + public ActionGraph getActionGraph() { + return new ActionGraph() { + @Override + public Action getGeneratingAction(final Artifact artifact) { + try { + return callUninterruptibly(new Callable<Action>() { + @Override + public Action call() throws InterruptedException { + return SkyframeExecutor.this.getGeneratingAction(artifact); + } + }); + } catch (Exception e) { + throw new IllegalStateException("Error getting generating action: " + + artifact.prettyPrint(), e); } - }); - } catch (Exception e) { - throw new IllegalStateException("Error getting generating action: " + artifact.prettyPrint(), - e); - } + } + }; } public PackageManager getPackageManager() { |