diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java index f3f7e09049..b68930e492 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java @@ -120,6 +120,7 @@ public class ActionMetadataHandler implements MetadataHandler { * Use {@link #getTimestampGranularityMonitor(Artifact)} to fetch this member. */ private final TimestampGranularityMonitor tsgm; + private final ArtifactPathResolver artifactPathResolver; /** * Whether the action is being executed or not; this flag is set to true in @@ -131,10 +132,12 @@ public class ActionMetadataHandler implements MetadataHandler { public ActionMetadataHandler( InputArtifactData inputArtifactData, Iterable<Artifact> outputs, - TimestampGranularityMonitor tsgm) { + TimestampGranularityMonitor tsgm, + ArtifactPathResolver artifactPathResolver) { this.inputArtifactData = Preconditions.checkNotNull(inputArtifactData); this.outputs = ImmutableSet.copyOf(outputs); this.tsgm = tsgm; + this.artifactPathResolver = artifactPathResolver; } /** @@ -390,7 +393,8 @@ public class ActionMetadataHandler implements MetadataHandler { throws IOException { Preconditions.checkState(artifact.isTreeArtifact(), artifact); - if (!artifact.getPath().isDirectory() || artifact.getPath().isSymbolicLink()) { + if (!artifactPathResolver.toPath(artifact).isDirectory() + || artifactPathResolver.toPath(artifact).isSymbolicLink()) { return TreeArtifactValue.MISSING_TREE_ARTIFACT; } @@ -580,7 +584,7 @@ public class ActionMetadataHandler implements MetadataHandler { setPathReadOnlyAndExecutable(artifact); } - FileValue value = fileValueFromArtifact(artifact, statNoFollow, + FileValue value = fileValueFromArtifact(artifact, artifactPathResolver, statNoFollow, getTimestampGranularityMonitor(artifact)); FileValue oldFsValue = outputArtifactData.putIfAbsent(artifact, value); checkInconsistentData(artifact, oldFsValue, value); @@ -591,9 +595,18 @@ public class ActionMetadataHandler implements MetadataHandler { static FileValue fileValueFromArtifact(Artifact artifact, @Nullable FileStatusWithDigest statNoFollow, @Nullable TimestampGranularityMonitor tsgm) throws IOException { - Path path = artifact.getPath(); + return fileValueFromArtifact(artifact, ArtifactPathResolver.IDENTITY, statNoFollow, tsgm); + } + + private static FileValue fileValueFromArtifact(Artifact artifact, + ArtifactPathResolver artifactPathResolver, + @Nullable FileStatusWithDigest statNoFollow, @Nullable TimestampGranularityMonitor tsgm) + throws IOException { + Path path = artifactPathResolver.toPath(artifact); RootedPath rootedPath = - RootedPath.toRootedPath(artifact.getRoot().getRoot(), artifact.getRootRelativePath()); + RootedPath.toRootedPath( + artifactPathResolver.transformRoot(artifact.getRoot().getRoot()), + artifact.getRootRelativePath()); if (statNoFollow == null) { statNoFollow = FileStatusWithDigestAdapter.adapt(path.statIfFound(Symlinks.NOFOLLOW)); if (statNoFollow == null) { @@ -614,7 +627,8 @@ public class ActionMetadataHandler implements MetadataHandler { } RootedPath realRootedPath = RootedPath.toRootedPathMaybeUnderRoot( - realPath, ImmutableList.of(artifact.getRoot().getRoot())); + realPath, + ImmutableList.of(artifactPathResolver.transformRoot(artifact.getRoot().getRoot()))); FileStateValue fileStateValue = FileStateValue.createWithStatNoFollow(rootedPath, statNoFollow, tsgm); // TODO(bazel-team): consider avoiding a 'stat' here when the symlink target hasn't changed @@ -631,7 +645,7 @@ public class ActionMetadataHandler implements MetadataHandler { if (injectedFiles.contains(artifact)) { return; } - Path path = artifact.getPath(); + Path path = artifactPathResolver.toPath(artifact); if (path.isFile(Symlinks.NOFOLLOW)) { // i.e. regular files only. // We trust the files created by the execution engine to be non symlinks with expected // chmod() settings already applied. @@ -641,7 +655,7 @@ public class ActionMetadataHandler implements MetadataHandler { private void setTreeReadOnlyAndExecutable(SpecialArtifact parent, PathFragment subpath) throws IOException { - Path path = parent.getPath().getRelative(subpath); + Path path = artifactPathResolver.toPath(parent).getRelative(subpath); if (path.isDirectory()) { path.chmod(0555); for (Path child : path.getDirectoryEntries()) { |