aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java b/src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java
index f08cf7d4dd..1140754ed5 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BlazeDirectories.java
@@ -16,6 +16,8 @@ package com.google.devtools.build.lib.analysis;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+import com.google.common.hash.HashCode;
+import com.google.common.hash.Hashing;
import com.google.devtools.build.lib.Constants;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
@@ -57,20 +59,23 @@ public final class BlazeDirectories {
@VisibleForTesting
static final String DEFAULT_EXEC_ROOT = "default-exec-root";
- private final Path installBase; // Where Blaze gets unpacked
- private final Path workspace; // Workspace root and server CWD
- private final Path outputBase; // The root of the temp and output trees
- private final Path execRoot; // the root of all build actions
+ private final Path installBase; // Where Blaze gets unpacked
+ private final HashCode installMD5; // The content hash of everything in installBase
+ private final Path workspace; // Workspace root and server CWD
+ private final Path outputBase; // The root of the temp and output trees
+ private final Path execRoot; // the root of all build actions
// These two are kept to avoid creating new objects every time they are accessed. This showed up
// in a profiler.
private final Path outputPath;
private final Path localOutputPath;
- public BlazeDirectories(Path installBase, Path outputBase, @Nullable Path workspace) {
+ public BlazeDirectories(Path installBase, Path outputBase, @Nullable Path workspace,
+ @Nullable String installMD5) {
this.installBase = installBase;
this.workspace = workspace;
this.outputBase = outputBase;
+ this.installMD5 = installMD5 == null ? null : checkMD5(HashCode.fromString(installMD5));
boolean useDefaultExecRootName = this.workspace == null || this.workspace.isRootDirectory();
if (useDefaultExecRootName) {
// TODO(bazel-team): if workspace is null execRoot should be null, but at the moment there is
@@ -86,6 +91,17 @@ public final class BlazeDirectories {
this.localOutputPath = outputBase.getRelative(BlazeDirectories.RELATIVE_OUTPUT_PATH);
}
+ private static HashCode checkMD5(HashCode hash) {
+ Preconditions.checkArgument(hash.bits() == Hashing.md5().bits(),
+ "Hash '%s' has %s bits", hash, hash.bits());
+ return hash;
+ }
+
+ @VisibleForTesting
+ public BlazeDirectories(Path installBase, Path outputBase, @Nullable Path workspace) {
+ this(installBase, outputBase, workspace, null);
+ }
+
/**
* Returns the Filesystem that all of our directories belong to. Handy for
* resolving absolute paths.
@@ -183,4 +199,12 @@ public final class BlazeDirectories {
public Root getBuildDataDirectory() {
return Root.asDerivedRoot(getExecRoot(), getOutputPath());
}
+
+ /**
+ * Returns the MD5 content hash of the blaze binary (includes deploy JAR, embedded binaries, and
+ * anything else that ends up in the install_base).
+ */
+ public HashCode getInstallMD5() {
+ return installMD5;
+ }
}