diff options
author | tomlu <tomlu@google.com> | 2017-09-13 21:36:39 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-14 18:46:54 +0200 |
commit | ec944965b85aa0367fa8adda2359cb5fbd5a294d (patch) | |
tree | 7a0b19c39dd01092020d9bb42747fac1f9ed604e /src/main/java/com/google/devtools/build/lib/actions/Artifact.java | |
parent | b30b3de23a7fa01b8290ace0e688d75405689825 (diff) |
Internal change
PiperOrigin-RevId: 168579567
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/Artifact.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/actions/Artifact.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java index 5847445c1f..971601436e 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java @@ -156,6 +156,7 @@ public class Artifact public static final Predicate<Artifact> MIDDLEMAN_FILTER = input -> !input.isMiddlemanArtifact(); private final int hashCode; + private final Path path; private final Root root; private final PathFragment execPath; private final PathFragment rootRelativePath; @@ -189,6 +190,7 @@ public class Artifact + " (root: " + root + ")"); } this.hashCode = path.hashCode(); + this.path = path; this.root = root; this.execPath = execPath; // These two lines establish the invariant that @@ -244,7 +246,7 @@ public class Artifact } public final Path getPath() { - return root.getPath().getRelative(rootRelativePath); + return path; } public boolean hasParent() { @@ -587,9 +589,10 @@ public class Artifact if (!(other instanceof Artifact)) { return false; } + // We don't bother to check root in the equivalence relation, because we + // assume that no root is an ancestor of another one. Artifact that = (Artifact) other; - return Objects.equals(this.rootRelativePath, that.rootRelativePath) - && Objects.equals(this.root, that.root); + return Objects.equals(this.path, that.path); } @Override @@ -623,7 +626,7 @@ public class Artifact return "[" + root + "]" + rootRelativePath; } else { // Derived Artifact: path and root are under execRoot - PathFragment execRoot = trimTail(getPath().asFragment(), execPath); + PathFragment execRoot = trimTail(path.asFragment(), execPath); return "[[" + execRoot + "]" + root.getPath().asFragment().relativeTo(execRoot) + "]" + rootRelativePath; } |