Add a reference to the pertinent RunfilesTree to RunfilesArtifactValue.
RELNOTES: None.
PiperOrigin-RevId: 599787221
Change-Id: Id0808314613f8b387fef59f83f76fe0e892fa20f
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
index ec76bfc..cc8e3f2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/RunfilesArtifactValue.java
@@ -20,6 +20,7 @@
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.FileArtifactValue;
+import com.google.devtools.build.lib.actions.RunfilesSupplier.RunfilesTree;
import com.google.devtools.build.lib.util.HashCodes;
import com.google.devtools.build.skyframe.SkyValue;
@@ -32,6 +33,7 @@
}
private final FileArtifactValue metadata;
+ private final RunfilesTree runfilesTree;
// Parallel lists.
private final ImmutableList<Artifact> files;
@@ -43,11 +45,13 @@
RunfilesArtifactValue(
FileArtifactValue metadata,
+ RunfilesTree runfilesTree,
ImmutableList<Artifact> files,
ImmutableList<FileArtifactValue> fileValues,
ImmutableList<Artifact> trees,
ImmutableList<TreeArtifactValue> treeValues) {
this.metadata = checkNotNull(metadata);
+ this.runfilesTree = checkNotNull(runfilesTree);
this.files = checkNotNull(files);
this.fileValues = checkNotNull(fileValues);
this.trees = checkNotNull(trees);
@@ -63,6 +67,11 @@
return metadata;
}
+ /** Returns the runfiles tree this value represents. */
+ RunfilesTree getRunfilesTree() {
+ return runfilesTree;
+ }
+
/** Visits the file artifacts that this runfiles artifact expands to, together with their data. */
void forEachFile(RunfilesConsumer<FileArtifactValue> consumer) throws InterruptedException {
for (int i = 0; i < files.size(); i++) {
@@ -79,6 +88,22 @@
@Override
public boolean equals(Object o) {
+ // This method, seemingly erroneously, does not check whether the runfilesTree of the two
+ // objects is equivalent. This is because it's costly (it involves flattening nested sets and
+ // even if one caches a fingerprint, it's still a fair amount of CPU) and because it's
+ // currently not necessary: RunfilesArtifactValue is only ever created as the SkyValue of
+ // runfiles middlemen and those are special-cased in ActionCacheChecker (see
+ // ActionCacheChecker.checkMiddlemanAction()): the checksum of a middleman artifact is the
+ // function of the checksum of all the artifacts on the inputs of the middleman action, which
+ // includes both the artifacts the runfiles tree links to and the runfiles input manifest,
+ // which in turn encodes the structure of the runfiles tree. The checksum of the middleman
+ // artifact is here as the "metadata" field, which *is* compared here, so the
+ // RunfilesArtifactValues of two runfiles middlemen will be equals iff they represent the same
+ // runfiles tree.
+ //
+ // Eventually, if we ever do away with runfiles input manifests, it will be necessary to change
+ // this (it's weird that one needs to do a round-trip to the file system to determine the
+ // checksum of a runfiles tree), but that's not happening anytime soon.
if (this == o) {
return true;
}