diff options
author | shahan <shahan@google.com> | 2018-06-18 08:14:01 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-18 08:15:26 -0700 |
commit | e35e8cfabd33e2e35b88d3693083350cf3c9d006 (patch) | |
tree | 2e05bb4f65801724b43fb6908cbdcb71438012f2 /src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | |
parent | 200837c2368d6b3383eb9dbcd25e293f818637bd (diff) |
Refactoring: uses OutputService for ActionFileSystem injection
Moves more Action-oriented from skyframe package, which has become very unwieldy, to action package. This is needed to avoid circular dependencies caused when build-base is needed for skyframe.
PiperOrigin-RevId: 200996982
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java index 6f5044fbbf..b740a490c3 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java @@ -32,8 +32,10 @@ import com.google.devtools.build.lib.actions.ActionLookupValue.ActionLookupKey; import com.google.devtools.build.lib.actions.AlreadyReportedActionExecutionException; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactPathResolver; +import com.google.devtools.build.lib.actions.ArtifactSkyKey; import com.google.devtools.build.lib.actions.FileArtifactValue; import com.google.devtools.build.lib.actions.FilesetOutputSymlink; +import com.google.devtools.build.lib.actions.MissingDepException; import com.google.devtools.build.lib.actions.MissingInputFileException; import com.google.devtools.build.lib.actions.NotifyOnActionCacheHit; import com.google.devtools.build.lib.actions.PackageRootResolver; @@ -48,6 +50,7 @@ import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.rules.cpp.IncludeScannable; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; +import com.google.devtools.build.lib.vfs.FileSystem; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.Root; import com.google.devtools.build.skyframe.SkyFunction; @@ -210,11 +213,8 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver optionalInputs = ImmutableList.of(); } state.actionFileSystem = - new ActionFileSystem( - skyframeActionExecutor.getExecutorFileSystem(), - skyframeActionExecutor.getExecRoot().asFragment(), + skyframeActionExecutor.createActionFileSystem( directories.getRelativeOutputPath(), - skyframeActionExecutor.getSourceRoots(), checkedInputs.first, optionalInputs, action.getOutputs()); @@ -429,7 +429,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver if (action.discoversInputs()) { if (state.discoveredInputs == null) { try { - state.updateFileSystemContext(env, metadataHandler); + state.updateFileSystemContext(skyframeActionExecutor, env, metadataHandler); state.discoveredInputs = skyframeActionExecutor.discoverInputs( action, perActionFileCache, metadataHandler, env, state.actionFileSystem); @@ -495,7 +495,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver filesetMappings.put(actionInput.getExecPath(), filesetValue.getOutputSymlinks()); } - state.updateFileSystemContext(env, metadataHandler); + state.updateFileSystemContext(skyframeActionExecutor, env, metadataHandler); try (ActionExecutionContext actionExecutionContext = skyframeActionExecutor.getContext( perActionFileCache, @@ -550,12 +550,9 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver return state.value; } - private ArtifactPathResolver pathResolver(ActionFileSystem actionFileSystem) { - if (actionFileSystem != null) { - return ArtifactPathResolver.withTransformedFileSystem( - actionFileSystem.getPath(skyframeActionExecutor.getExecRoot().asFragment())); - } - return ArtifactPathResolver.forExecRoot(skyframeActionExecutor.getExecRoot()); + private ArtifactPathResolver pathResolver(@Nullable FileSystem actionFileSystem) { + return ArtifactPathResolver.createPathResolver( + actionFileSystem, skyframeActionExecutor.getExecRoot()); } private static final Function<Artifact, SkyKey> TO_NONMANDATORY_SKYKEY = @@ -774,12 +771,6 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver } /** - * Exception to be thrown if an action is missing Skyframe dependencies that it finds are missing - * during execution/input discovery. - */ - public static class MissingDepException extends RuntimeException {} - - /** * Should be called once execution is over, and the intra-build cache of in-progress computations * should be discarded. If the cache is non-empty (due to an interrupted/failed build), failure to * call complete() can both cause a memory leak and incorrect results on the subsequent build. @@ -824,7 +815,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver Iterable<Artifact> discoveredInputs = null; Iterable<Artifact> discoveredInputsStage2 = null; ActionExecutionValue value = null; - ActionFileSystem actionFileSystem = null; + FileSystem actionFileSystem = null; boolean hasCollectedInputs() { return allInputs != null; @@ -848,9 +839,12 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver /** Must be called to assign values to the given variables as they change. */ void updateFileSystemContext( - SkyFunction.Environment env, ActionMetadataHandler metadataHandler) { + SkyframeActionExecutor executor, + SkyFunction.Environment env, + ActionMetadataHandler metadataHandler) { if (actionFileSystem != null) { - actionFileSystem.updateContext(env, metadataHandler::injectOutputData); + executor.updateActionFileSystemContext( + actionFileSystem, env, metadataHandler::injectOutputData); } } |