diff options
Diffstat (limited to 'src/main')
5 files changed, 35 insertions, 19 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 7035472d94..0b6ec47b9e 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -494,6 +494,8 @@ static vector<string> GetArgumentArray( result.push_back("--connect_timeout_secs=" + ToString(globals->options->connect_timeout_secs)); + result.push_back("--output_user_root=" + + blaze::ConvertPath(globals->options->output_user_root)); result.push_back("--install_base=" + blaze::ConvertPath(globals->options->install_base)); result.push_back("--install_md5=" + globals->install_md5); diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ServerDirectories.java b/src/main/java/com/google/devtools/build/lib/analysis/ServerDirectories.java index 0e34cf3067..9b25f7a997 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ServerDirectories.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/ServerDirectories.java @@ -26,17 +26,16 @@ import java.util.Objects; import javax.annotation.Nullable; /** - * Represents the server install directory, which contains the Bazel installation and embedded - * binaries. - * - * <p>The <code>installBase</code> is the directory where the Blaze binary has been installed. The - * <code>outputBase</code> is the directory below which Blaze puts all its state. + * Represents the relevant directories for the server: the location of the embedded binaries + * and the output directories. */ @AutoCodec @Immutable public final class ServerDirectories { public static final ObjectCodec<ServerDirectories> CODEC = new ServerDirectories_AutoCodec(); + /** Top-level user output directory; used, e.g., as default location for caches. */ + private final Path outputUserRoot; /** Where Blaze gets unpacked. */ private final Path installBase; /** The content hash of everything in installBase. */ @@ -44,22 +43,25 @@ public final class ServerDirectories { /** The root of the temp and output trees. */ private final Path outputBase; - public ServerDirectories(Path installBase, Path outputBase, @Nullable String installMD5) { + public ServerDirectories( + Path installBase, Path outputBase, Path outputUserRoot, @Nullable String installMD5) { this( installBase, outputBase, + outputUserRoot, Strings.isNullOrEmpty(installMD5) ? null : checkMD5(HashCode.fromString(installMD5))); } @AutoCodec.Instantiator - ServerDirectories(Path installBase, Path outputBase, HashCode installMD5) { + ServerDirectories(Path installBase, Path outputBase, Path outputUserRoot, HashCode installMD5) { + this.outputUserRoot = outputUserRoot; this.installBase = installBase; this.outputBase = outputBase; this.installMD5 = installMD5; } - public ServerDirectories(Path installBase, Path outputBase) { - this(installBase, outputBase, (HashCode) null); + public ServerDirectories(Path installBase, Path outputBase, Path outputUserRoot) { + this(installBase, outputBase, outputUserRoot, (HashCode) null); } private static HashCode checkMD5(HashCode hash) { @@ -81,6 +83,13 @@ public final class ServerDirectories { return outputBase; } + /** + * Returns the root directory for user output. In particular default caches will be located here. + */ + public Path getOutputUserRoot() { + return outputUserRoot; + } + /** Returns the installed embedded binaries directory, under the shared installBase location. */ public Path getEmbeddedBinariesRoot() { return installBase.getChild("_embedded_binaries"); @@ -96,7 +105,7 @@ public final class ServerDirectories { @Override public int hashCode() { - return Objects.hash(installBase, installMD5, outputBase); + return Objects.hash(installBase, installMD5, outputBase, outputUserRoot); } @Override @@ -110,6 +119,7 @@ public final class ServerDirectories { ServerDirectories that = (ServerDirectories) obj; return this.installBase.equals(that.installBase) && Objects.equals(this.installMD5, that.installMD5) - && this.outputBase.equals(that.outputBase); + && this.outputBase.equals(that.outputBase) + && this.outputUserRoot.equals(that.outputUserRoot); } } 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 a27b9b6078..df1692fdd5 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 @@ -977,17 +977,22 @@ public final class BlazeRuntime { String productName = startupOptions.productName.toLowerCase(Locale.US); PathFragment workspaceDirectory = startupOptions.workspaceDirectory; + PathFragment outputUserRoot = startupOptions.outputUserRoot; PathFragment installBase = startupOptions.installBase; PathFragment outputBase = startupOptions.outputBase; maybeForceJNIByGettingPid(installBase); // Must be before first use of JNI. - // From the point of view of the Java program --install_base and --output_base - // are mandatory options, despite the comment in their declarations. + // From the point of view of the Java program --install_base, --output_base, and + // --output_user_root are mandatory options, despite the comment in their declarations. if (installBase == null || !installBase.isAbsolute()) { // (includes "" default case) throw new IllegalArgumentException( "Bad --install_base option specified: '" + installBase + "'"); } + if (outputUserRoot != null && !outputUserRoot.isAbsolute()) { // (includes "" default case) + throw new IllegalArgumentException( + "Bad --output_user_root option specified: '" + outputUserRoot + "'"); + } if (outputBase != null && !outputBase.isAbsolute()) { // (includes "" default case) throw new IllegalArgumentException( "Bad --output_base option specified: '" + outputBase + "'"); @@ -1009,6 +1014,7 @@ public final class BlazeRuntime { Path.setFileSystemForSerialization(fs); SubprocessBuilder.setSubprocessFactory(subprocessFactoryImplementation()); + Path outputUserRootPath = fs.getPath(outputUserRoot); Path installBasePath = fs.getPath(installBase); Path outputBasePath = fs.getPath(outputBase); Path workspaceDirectoryPath = null; @@ -1017,7 +1023,8 @@ public final class BlazeRuntime { } ServerDirectories serverDirectories = - new ServerDirectories(installBasePath, outputBasePath, startupOptions.installMD5); + new ServerDirectories( + installBasePath, outputBasePath, outputUserRootPath, startupOptions.installMD5); Clock clock = BlazeClock.instance(); BlazeRuntime.Builder runtimeBuilder = new BlazeRuntime.Builder() diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java index 8cccbacbfe..e8eafbc667 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java @@ -128,10 +128,6 @@ public class BlazeServerStartupOptions extends OptionsBase { ) public PathFragment outputBase; - /* Note: This option is only used by the C++ client, never by the Java server. - * It is included here to make sure that the option is documented in the help - * output, which is auto-generated by Java code. - */ @Option( name = "output_user_root", defaultValue = "null", // NOTE: purely decorative! See class docstring. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java index 850687dcc1..5613c87ab1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java @@ -143,7 +143,8 @@ public abstract class AbstractPackageLoader implements PackageLoader { // TODO(nharmata): Refactor WorkspaceFileFunction to make this a non-issue. Path devNull = workspaceDir.getFileSystem().getPath("/dev/null"); directories = - new BlazeDirectories(new ServerDirectories(devNull, devNull), workspaceDir, "blaze"); + new BlazeDirectories( + new ServerDirectories(devNull, devNull, devNull), workspaceDir, "blaze"); } public Builder setRuleClassProvider(RuleClassProvider ruleClassProvider) { |