diff options
author | 2018-01-22 07:53:56 -0800 | |
---|---|---|
committer | 2018-01-22 07:56:03 -0800 | |
commit | 28c20f79e3d265f897e8c644a4c31bd2b3d6ac67 (patch) | |
tree | 9bff0a6a653b741228dd352e6324a0f13946155a /src/main/java/com/google/devtools/build/lib/runtime | |
parent | 4c8fa1bab507fa7f0a1cbeac0724751d9b574f89 (diff) |
Add option to optionally wipe state at the end of a build.
This will serve as an alternative to --batch, leaving behind a server without state from the previous build.
RELNOTES: Introduces --[no]keep_state_after_build
PiperOrigin-RevId: 182778500
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index 65e5954fc9..7789605f1d 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -33,6 +33,7 @@ import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory; import com.google.devtools.build.lib.analysis.test.CoverageReportActionFactory; import com.google.devtools.build.lib.buildeventstream.PathConverter; +import com.google.devtools.build.lib.buildtool.BuildRequestOptions; import com.google.devtools.build.lib.clock.BlazeClock; import com.google.devtools.build.lib.clock.Clock; import com.google.devtools.build.lib.events.Event; @@ -424,10 +425,7 @@ public final class BlazeRuntime { workspace.getSkyframeExecutor().getEventBus().post(new CommandCompleteEvent(exitCode)); } - /** - * Hook method called by the BlazeCommandDispatcher after the dispatch of each - * command. - */ + /** Hook method called by the BlazeCommandDispatcher after the dispatch of each command. */ @VisibleForTesting public void afterCommand(CommandEnvironment env, int exitCode) { // Remove any filters that the command might have added to the reporter. @@ -439,6 +437,15 @@ public final class BlazeRuntime { module.afterCommand(); } + // If the command just completed was or inherits from Build, wipe the dependency graph if + // requested. This is sufficient, as this method is always run at the end of commands unless + // the server crashes, in which case no inmemory state will linger for the next build anyway. + BuildRequestOptions buildRequestOptions = + env.getOptions().getOptions(BuildRequestOptions.class); + if (buildRequestOptions != null && !buildRequestOptions.keepStateAfterBuild) { + workspace.getSkyframeExecutor().resetEvaluator(); + } + env.getBlazeWorkspace().clearEventBus(); try { |