diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
7 files changed, 20 insertions, 31 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java index 98c56c48c8..3246f2fe26 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java @@ -150,15 +150,6 @@ public final class BlazeWorkspace { } /** - * Returns the execution root directory associated with this Blaze server - * process. This is where all input and output files visible to the actual - * build reside. - */ - public Path getExecRoot() { - return directories.getExecRoot(); - } - - /** * Returns path to the cache directory. Path must be inside output base to * ensure that users can run concurrent instances of blaze in different * clients without attempting to concurrently write to the same action cache 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 84d5a20825..fea9d72b1d 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 @@ -91,6 +91,7 @@ public final class CommandEnvironment { private long commandStartTime; private OutputService outputService; private Path workingDirectory; + private String workspaceName; private String commandName; private OptionsProvider options; @@ -143,6 +144,7 @@ public final class CommandEnvironment { // TODO(ulfjack): We don't call beforeCommand() in tests, but rely on workingDirectory being set // in setupPackageCache(). This leads to NPE if we don't set it here. this.workingDirectory = directories.getWorkspace(); + this.workspaceName = null; workspace.getSkyframeExecutor().setEventBus(eventBus); } @@ -292,13 +294,14 @@ public final class CommandEnvironment { } public String getWorkspaceName() { - Path workspace = getDirectories().getWorkspace(); - if (workspace == null) { - return ""; - } - return workspace.getBaseName(); + Preconditions.checkNotNull(workspaceName); + return workspaceName; } + public void setWorkspaceName(String workspaceName) { + Preconditions.checkState(this.workspaceName == null, "workspace name can only be set once"); + this.workspaceName = workspaceName; + } /** * Returns if the client passed a valid workspace to be used for the build. */ @@ -321,7 +324,8 @@ public final class CommandEnvironment { * build reside. */ public Path getExecRoot() { - return getDirectories().getExecRoot(); + Preconditions.checkNotNull(workspaceName); + return getDirectories().getExecRoot(workspaceName); } /** diff --git a/src/main/java/com/google/devtools/build/lib/runtime/TestResultAnalyzer.java b/src/main/java/com/google/devtools/build/lib/runtime/TestResultAnalyzer.java index 8206527d4f..d23b7e5b5a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/TestResultAnalyzer.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/TestResultAnalyzer.java @@ -30,9 +30,7 @@ import com.google.devtools.build.lib.rules.test.TestResult; import com.google.devtools.build.lib.runtime.TerminalTestResultNotifier.TestSummaryOptions; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.Path; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -45,7 +43,6 @@ import java.util.Set; */ @ThreadCompatible public class TestResultAnalyzer { - private final Path execRoot; private final TestSummaryOptions summaryOptions; private final ExecutionOptions executionOptions; private final EventBus eventBus; @@ -59,11 +56,9 @@ public class TestResultAnalyzer { * @param executionOptions Parsed build/test execution options. * @param eventBus For reporting failed to build and cached tests. */ - public TestResultAnalyzer(Path execRoot, - TestSummaryOptions summaryOptions, + public TestResultAnalyzer(TestSummaryOptions summaryOptions, ExecutionOptions executionOptions, EventBus eventBus) { - this.execRoot = execRoot; this.summaryOptions = summaryOptions; this.executionOptions = executionOptions; this.eventBus = eventBus; @@ -211,10 +206,9 @@ public class TestResultAnalyzer { numLocalActionCached++; } - PathFragment coverageData = result.getCoverageData(); + Path coverageData = result.getCoverageData(); if (coverageData != null) { - summaryBuilder.addCoverageFiles( - Collections.singletonList(execRoot.getRelative(coverageData))); + summaryBuilder.addCoverageFiles(Collections.singletonList(coverageData)); } if (!executionOptions.runsPerTestDetectsFlakes) { 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 368529e804..0a0cec59be 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 @@ -202,6 +202,7 @@ public final class CleanCommand implements BlazeCommand { private void actuallyClean(CommandEnvironment env, Path outputBase, Options cleanOptions, String symlinkPrefix) throws IOException, ShutdownBlazeServerException, CommandException, ExecException, InterruptedException { + String workspaceDirectory = env.getWorkspace().getBaseName(); if (env.getOutputService() != null) { env.getOutputService().clean(); } @@ -225,7 +226,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[] { - env.getWorkspaceName(), "execroot/" + env.getWorkspaceName() }) { + workspaceDirectory, "execroot/" + workspaceDirectory }) { Path child = outputBase.getRelative(directory); if (child.exists()) { LOG.finest("Cleaning " + child + (cleanOptions.async ? " asynchronously..." : "")); @@ -239,8 +240,8 @@ public final class CleanCommand implements BlazeCommand { } // remove convenience links OutputDirectoryLinksUtils.removeOutputDirectoryLinks( - env.getWorkspaceName(), env.getWorkspace(), env.getReporter(), symlinkPrefix, - env.getRuntime().getProductName()); + workspaceDirectory, env.getWorkspace(), env.getReporter(), + symlinkPrefix, env.getRuntime().getProductName()); // 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/InfoItem.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java index 3f0ba6202f..bf47b1487d 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java @@ -181,7 +181,7 @@ public abstract class InfoItem { public byte[] get(Supplier<BuildConfiguration> configurationSupplier, CommandEnvironment env) throws AbruptExitException { checkNotNull(env); - return print(env.getRuntime().getWorkspace().getExecRoot()); + return print(env.getDirectories().getExecRoot()); } } 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 970cb5c007..bbc7a02c4d 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 @@ -192,7 +192,7 @@ public final class ProfileCommand implements BlazeCommand { MultiProfileStatistics statistics = new MultiProfileStatistics( env.getWorkingDirectory(), - env.getWorkspaceName(), + env.getWorkspace().getBaseName(), options.getResidue(), getInfoListener(env), opts.vfsStatsLimit > 0); @@ -248,7 +248,7 @@ public final class ProfileCommand implements BlazeCommand { phaseStatistics.put( phase, new PhaseStatistics( - phase, info, env.getWorkspaceName(), opts.vfsStatsLimit > 0)); + phase, info, env.getWorkspace().getBaseName(), opts.vfsStatsLimit > 0)); } CriticalPathStatistics critPathStats = new CriticalPathStatistics(info); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java index cd31c7d396..94b71d8df3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java @@ -85,7 +85,6 @@ public class TestCommand implements BlazeCommand { @Override public ExitCode exec(CommandEnvironment env, OptionsProvider options) { TestResultAnalyzer resultAnalyzer = new TestResultAnalyzer( - env.getDirectories().getExecRoot(), options.getOptions(TestSummaryOptions.class), options.getOptions(ExecutionOptions.class), env.getEventBus()); |