aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2016-03-30 11:58:37 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-03-30 15:23:44 +0000
commit94b72db92b54af7a6b1e7a5a48b218b26ac761e5 (patch)
tree383cab0d695759473104b4fcfe36f81889e24baf /src/main/java/com/google/devtools/build/lib/runtime/commands
parent8c4ae6781d79956e891b94d3dea87d761ad78f55 (diff)
Move most BlazeRuntime methods related to workspace directories to CommandEnv.
-- MOS_MIGRATED_REVID=118561661
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java9
6 files changed, 18 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
index c6e3a2a3ee..12630051e6 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java
@@ -86,7 +86,6 @@ public final class CleanCommand implements BlazeCommand {
@Override
public ExitCode exec(CommandEnvironment env, OptionsProvider options)
throws ShutdownBlazeServerException {
- BlazeRuntime runtime = env.getRuntime();
Options cleanOptions = options.getOptions(Options.class);
cleanOptions.expunge_async = cleanOptions.cleanStyle.equals("expunge_async");
cleanOptions.expunge = cleanOptions.cleanStyle.equals("expunge");
@@ -109,7 +108,7 @@ public final class CleanCommand implements BlazeCommand {
try {
String symlinkPrefix =
options.getOptions(BuildRequest.BuildRequestOptions.class).getSymlinkPrefix();
- actuallyClean(env, runtime.getOutputBase(), cleanOptions, symlinkPrefix);
+ actuallyClean(env, env.getOutputBase(), cleanOptions, symlinkPrefix);
return ExitCode.SUCCESS;
} catch (IOException e) {
env.getReporter().handle(Event.error(e.getMessage()));
@@ -167,7 +166,7 @@ public final class CleanCommand implements BlazeCommand {
// In order to be sure that we delete everything, delete the workspace directory both for
// --deep_execroot and for --nodeep_execroot.
for (String directory : new String[] {
- runtime.getWorkspaceName(), "execroot/" + runtime.getWorkspaceName() }) {
+ env.getWorkspaceName(), "execroot/" + env.getWorkspaceName() }) {
Path child = outputBase.getRelative(directory);
if (child.exists()) {
LOG.finest("Cleaning " + child);
@@ -177,7 +176,7 @@ public final class CleanCommand implements BlazeCommand {
}
// remove convenience links
OutputDirectoryLinksUtils.removeOutputDirectoryLinks(
- runtime.getWorkspaceName(), runtime.getWorkspace(), env.getReporter(), symlinkPrefix);
+ env.getWorkspaceName(), env.getWorkspace(), env.getReporter(), symlinkPrefix);
// shutdown on expunge cleans
if (cleanOptions.expunge || cleanOptions.expunge_async) {
throw new ShutdownBlazeServerException(0);
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
index 81e19a0334..6acf54658b 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
@@ -151,7 +151,7 @@ public class DumpCommand implements BlazeCommand {
if (dumpOptions.dumpVfs) {
out.println("Filesystem cache");
- FileSystemUtils.dump(runtime.getOutputBase().getFileSystem(), out);
+ FileSystemUtils.dump(env.getOutputBase().getFileSystem(), out);
out.println();
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
index 93a947a9ff..65d72552f2 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
@@ -284,10 +284,10 @@ public class InfoCommand implements BlazeCommand {
Supplier<BuildConfiguration> configurationSupplier, OptionsProvider options) {
switch (key) {
// directories
- case WORKSPACE : return runtime.getWorkspace();
+ case WORKSPACE : return runtime.getDirectories().getWorkspace();
case INSTALL_BASE : return runtime.getDirectories().getInstallBase();
- case OUTPUT_BASE : return runtime.getOutputBase();
- case EXECUTION_ROOT : return runtime.getExecRoot();
+ case OUTPUT_BASE : return runtime.getDirectories().getOutputBase();
+ case EXECUTION_ROOT : return runtime.getDirectories().getExecRoot();
case OUTPUT_PATH : return runtime.getDirectories().getOutputPath();
// These are the only (non-hidden) info items that require a configuration, because the
// corresponding paths contain the short name. Maybe we should recommend using the symlinks
@@ -297,10 +297,11 @@ public class InfoCommand implements BlazeCommand {
case BLAZE_TESTLOGS : return configurationSupplier.get().getTestLogsDirectory().getPath();
// logs
- case COMMAND_LOG : return BlazeCommandDispatcher.getCommandLogPath(runtime.getOutputBase());
+ case COMMAND_LOG : return BlazeCommandDispatcher.getCommandLogPath(
+ runtime.getDirectories().getOutputBase());
case MESSAGE_LOG :
// NB: Duplicated in EventLogModule
- return runtime.getOutputBase().getRelative("message.log");
+ return runtime.getDirectories().getOutputBase().getRelative("message.log");
// misc
case RELEASE : return BlazeVersionInfo.instance().getReleaseName();
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java
index 9b2cc21bc2..970cb5c007 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProfileCommand.java
@@ -30,7 +30,6 @@ import com.google.devtools.build.lib.profiler.statistics.MultiProfileStatistics;
import com.google.devtools.build.lib.profiler.statistics.PhaseStatistics;
import com.google.devtools.build.lib.profiler.statistics.PhaseSummaryStatistics;
import com.google.devtools.build.lib.runtime.BlazeCommand;
-import com.google.devtools.build.lib.runtime.BlazeRuntime;
import com.google.devtools.build.lib.runtime.Command;
import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.util.ExitCode;
@@ -178,7 +177,6 @@ public final class ProfileCommand implements BlazeCommand {
@Override
public ExitCode exec(final CommandEnvironment env, OptionsProvider options) {
- final BlazeRuntime runtime = env.getRuntime();
ProfileOptions opts =
options.getOptions(ProfileOptions.class);
@@ -194,7 +192,7 @@ public final class ProfileCommand implements BlazeCommand {
MultiProfileStatistics statistics =
new MultiProfileStatistics(
env.getWorkingDirectory(),
- runtime.getWorkspaceName(),
+ env.getWorkspaceName(),
options.getResidue(),
getInfoListener(env),
opts.vfsStatsLimit > 0);
@@ -250,7 +248,7 @@ public final class ProfileCommand implements BlazeCommand {
phaseStatistics.put(
phase,
new PhaseStatistics(
- phase, info, runtime.getWorkspaceName(), opts.vfsStatsLimit > 0));
+ phase, info, env.getWorkspaceName(), opts.vfsStatsLimit > 0));
}
CriticalPathStatistics critPathStats = new CriticalPathStatistics(info);
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
index 240a0ecd5c..cfdabe690e 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
@@ -65,10 +65,10 @@ public final class ProjectFileSupport {
// relative to the cwd instead.
PathFragment projectFilePath = new PathFragment(targets.get(0).substring(1));
List<Path> packagePath = PathPackageLocator.create(
- runtime.getOutputBase(),
+ env.getOutputBase(),
optionsParser.getOptions(PackageCacheOptions.class).packagePath,
env.getReporter(),
- runtime.getWorkspace(),
+ env.getWorkspace(),
env.getWorkingDirectory()).getPathEntries();
ProjectFile projectFile = projectFileProvider.getProjectFile(
env.getWorkingDirectory(), packagePath, projectFilePath);
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
index 34f6819afd..836c154cfa 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
@@ -242,15 +242,14 @@ public class RunCommand implements BlazeCommand {
// replaced with a shorter relative path that uses the symlinks in the workspace.
PathFragment prettyExecutablePath =
OutputDirectoryLinksUtils.getPrettyPath(executablePath,
- runtime.getWorkspaceName(), runtime.getWorkspace(),
+ env.getWorkspaceName(), env.getWorkspace(),
options.getOptions(BuildRequestOptions.class).getSymlinkPrefix());
List<String> cmdLine = new ArrayList<>();
if (runOptions.scriptPath == null) {
PathFragment processWrapperPath = runtime.getBinTools().getExecPath(PROCESS_WRAPPER);
Preconditions.checkNotNull(
processWrapperPath, PROCESS_WRAPPER + " not found in embedded tools");
- cmdLine.add(runtime.getDirectories().getExecRoot()
- .getRelative(processWrapperPath).getPathString());
+ cmdLine.add(env.getExecRoot().getRelative(processWrapperPath).getPathString());
cmdLine.add("-1");
cmdLine.add("15");
cmdLine.add("-");
@@ -356,7 +355,7 @@ public class RunCommand implements BlazeCommand {
Artifact manifest = runfilesSupport.getRunfilesManifest();
PathFragment runfilesDir = runfilesSupport.getRunfilesDirectoryExecPath();
- Path workingDir = env.getRuntime().getExecRoot()
+ Path workingDir = env.getExecRoot()
.getRelative(runfilesDir)
.getRelative(runfilesSupport.getRunfiles().getSuffix());
@@ -372,7 +371,7 @@ public class RunCommand implements BlazeCommand {
manifest.getExecPath(),
runfilesDir,
false);
- helper.createSymlinksUsingCommand(env.getRuntime().getExecRoot(), target.getConfiguration(),
+ helper.createSymlinksUsingCommand(env.getExecRoot(), target.getConfiguration(),
env.getRuntime().getBinTools());
return workingDir;
}