diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java index d1411c70bd..48092a1a70 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java @@ -51,8 +51,6 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.OptionsClassProvider; -import com.google.devtools.common.options.OptionsParser; -import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.OptionsProvider; import java.io.IOException; import java.util.Collection; @@ -553,30 +551,21 @@ public final class CommandEnvironment { /** * Hook method called by the BlazeCommandDispatcher prior to the dispatch of each command. * - * @param options The CommonCommandOptions used by every command. + * @param commonOptions The CommonCommandOptions used by every command. * @throws AbruptExitException if this command is unsuitable to be run as specified */ void beforeCommand( - OptionsParser optionsParser, - CommonCommandOptions options, + OptionsProvider options, + CommonCommandOptions commonOptions, long execStartTimeNanos, long waitTimeInMs, InvocationPolicy invocationPolicy) throws AbruptExitException { - commandStartTime -= options.startupTime; - if (runtime.getStartupOptionsProvider().getOptions(BlazeServerStartupOptions.class).watchFS) { - try { - // TODO(ulfjack): Get rid of the startup option and drop this code. - optionsParser.parse("--watchfs"); - } catch (OptionsParsingException e) { - // This should never happen. - throw new IllegalStateException(e); - } - } - this.options = optionsParser; + commandStartTime -= commonOptions.startupTime; + this.options = options; eventBus.post( - new GotOptionsEvent(runtime.getStartupOptionsProvider(), optionsParser, invocationPolicy)); + new GotOptionsEvent(runtime.getStartupOptionsProvider(), options, invocationPolicy)); throwPendingException(); outputService = null; @@ -604,7 +593,7 @@ public final class CommandEnvironment { Path workspace = getWorkspace(); Path workingDirectory; if (inWorkspace()) { - workingDirectory = workspace.getRelative(options.clientCwd); + workingDirectory = workspace.getRelative(commonOptions.clientCwd); } else { workspace = FileSystemUtils.getWorkingDirectory(getDirectories().getFileSystem()); workingDirectory = workspace; @@ -612,17 +601,17 @@ public final class CommandEnvironment { this.relativeWorkingDirectory = workingDirectory.relativeTo(workspace); this.workingDirectory = workingDirectory; - updateClientEnv(options.clientEnv); + updateClientEnv(commonOptions.clientEnv); // Fail fast in the case where a Blaze command forgets to install the package path correctly. skyframeExecutor.setActive(false); // Let skyframe figure out if it needs to store graph edges for this build. skyframeExecutor.decideKeepIncrementalState( runtime.getStartupOptionsProvider().getOptions(BlazeServerStartupOptions.class).batch, - optionsParser.getOptions(BuildView.Options.class)); + options.getOptions(BuildView.Options.class)); // Start the performance and memory profilers. - runtime.beforeCommand(this, options, execStartTimeNanos); + runtime.beforeCommand(this, commonOptions, execStartTimeNanos); // actionClientEnv contains the environment where values from actionEnvironment are overridden. actionClientEnv.putAll(clientEnv); @@ -631,7 +620,7 @@ public final class CommandEnvironment { // Compute the set of environment variables that are whitelisted on the commandline // for inheritance. for (Map.Entry<String, String> entry : - optionsParser.getOptions(BuildConfiguration.Options.class).actionEnvironment) { + options.getOptions(BuildConfiguration.Options.class).actionEnvironment) { if (entry.getValue() == null) { visibleActionEnv.add(entry.getKey()); } else { @@ -640,7 +629,7 @@ public final class CommandEnvironment { } } for (Map.Entry<String, String> entry : - optionsParser.getOptions(BuildConfiguration.Options.class).testEnvironment) { + options.getOptions(BuildConfiguration.Options.class).testEnvironment) { if (entry.getValue() == null) { visibleTestEnv.add(entry.getKey()); } @@ -649,7 +638,7 @@ public final class CommandEnvironment { eventBus.post(new CommandStartEvent( command.name(), getCommandId(), getClientEnv(), workingDirectory, getDirectories(), - waitTimeInMs + options.waitTime)); + waitTimeInMs + commonOptions.waitTime)); } /** Returns the name of the file system we are writing output to. */ |