diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
3 files changed, 24 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java index f04eab4f96..182b74cd14 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java @@ -152,7 +152,7 @@ public final class BuildTool { BuildConfigurationCollection configurations = null; boolean catastrophe = false; try { - env.getEventBus().post(new BuildStartingEvent(env.getOutputFileSystem(), request)); + env.getEventBus().post(new BuildStartingEvent(env.determineOutputFileSystem(), request)); LOG.info("Build identifier: " + request.getId()); executionTool = new ExecutionTool(env, request); if (needsExecutionPhase(request.getBuildOptions())) { 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 aa98d3b98a..6652bd74ab 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 @@ -69,6 +69,8 @@ public final class BlazeWorkspace { @Nullable private Range<Long> lastExecutionRange = null; + private final String outputBaseFilesystemTypeName; + public BlazeWorkspace(BlazeRuntime runtime, BlazeDirectories directories, SkyframeExecutor skyframeExecutor, SubscriberExceptionHandler eventBusExceptionHandler, WorkspaceStatusAction.Factory workspaceStatusActionFactory, BinTools binTools) { @@ -85,6 +87,9 @@ public final class BlazeWorkspace { writeDoNotBuildHereFile(runtime.getStartupOptionsProvider()); } setupExecRoot(); + // Here we use outputBase instead of outputPath because we need a file system to create the + // latter. + this.outputBaseFilesystemTypeName = FileSystemUtils.getFileSystem(getOutputBase()); } /** @@ -126,6 +131,15 @@ public final class BlazeWorkspace { } /** + * Returns the cached value of + * {@code getOutputBase().getFilesystem().getFileSystemType(getOutputBase())}, which is assumed + * to be constant for a fixed workspace for the life of the Blaze server. + */ + public String getOutputBaseFilesystemTypeName() { + return outputBaseFilesystemTypeName; + } + + /** * Returns the output path associated with this Blaze server process.. */ public Path getOutputPath() { 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 0900086aca..38eac7f230 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 @@ -87,7 +87,6 @@ public final class CommandEnvironment { private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT; private long commandStartTime; private OutputService outputService; - private String outputFileSystem; private Path workingDirectory; private AtomicReference<AbruptExitException> pendingException = new AtomicReference<>(); @@ -413,10 +412,6 @@ public final class CommandEnvironment { this.workingDirectory = workingDirectory; } - public String getOutputFileSystem() { - return outputFileSystem; - } - /** * Hook method called by the BlazeCommandDispatcher prior to the dispatch of * each command. @@ -450,8 +445,6 @@ public final class CommandEnvironment { SkyframeExecutor skyframeExecutor = getSkyframeExecutor(); skyframeExecutor.setOutputService(outputService); - this.outputFileSystem = determineOutputFileSystem(); - // Ensure that the working directory will be under the workspace directory. Path workspace = getWorkspace(); Path workingDirectory; @@ -507,16 +500,16 @@ public final class CommandEnvironment { new CommandStartEvent(command.name(), commandId, getClientEnv(), workingDirectory)); } - /** - * Figures out what file system we are writing output to. Here we use - * outputBase instead of outputPath because we need a file system to create the latter. - */ - private String determineOutputFileSystem() { + /** Returns the name of the file system we are writing output to. */ + public String determineOutputFileSystem() { + // If we have a fancy OutputService, this may be different between consecutive Blaze commands + // and so we need to compute it freshly. Otherwise, we can used the immutable value that's + // precomputed by our BlazeWorkspace. if (getOutputService() != null) { - return getOutputService().getFilesSystemName(); - } - try (AutoProfiler p = profiled("Finding output file system", ProfilerTask.INFO)) { - return FileSystemUtils.getFileSystem(getOutputBase()); + try (AutoProfiler p = profiled("Finding output file system", ProfilerTask.INFO)) { + return getOutputService().getFilesSystemName(); + } } + return workspace.getOutputBaseFilesystemTypeName(); } } |