diff options
author | tomlu <tomlu@google.com> | 2017-09-22 03:22:50 +0200 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2017-09-22 12:16:05 +0200 |
commit | 5059a43047c12de54caf09e30c0e38364840a3b8 (patch) | |
tree | fe3ec4dae091754edbead1b1891177f0cd0c249c /src/main/java/com/google/devtools/build/lib/actions/Artifact.java | |
parent | 70d018bb64f2192d82d08990ffd369733c83e9aa (diff) |
Internal change
PiperOrigin-RevId: 169631693
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 1bde580120..9e05d2ec44 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; } |