diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java | 17 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java | 40 |
2 files changed, 11 insertions, 46 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java index 5c0537c127..f13e35757c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java @@ -327,8 +327,6 @@ public final class Runfiles { /** * Returns the symlinks as a map from PathFragment to Artifact, with PathFragments relativized * and rooted at the specified points. - * @param root The root the PathFragment is computed relative to (before it is - * rooted again). May be null. * @param eventHandler Used for throwing an error if we have an obscuring runlink. * May be null, in which case obscuring symlinks are silently discarded. * @param location Location for eventHandler warnings. Ignored if eventHandler is null. @@ -336,12 +334,12 @@ public final class Runfiles { * entries, the second of any elements that live outside the source tree. */ public Pair<Map<PathFragment, Artifact>, Map<PathFragment, Artifact>> getRunfilesInputs( - PathFragment root, EventHandler eventHandler, Location location) + EventHandler eventHandler, Location location) throws IOException { Map<PathFragment, Artifact> manifest = getSymlinksAsMap(); // Add unconditional artifacts (committed to inclusion on construction of runfiles). for (Artifact artifact : getUnconditionalArtifactsWithoutMiddlemen()) { - addToManifest(manifest, artifact, root); + manifest.put(artifact.getRootRelativePath(), artifact); } // Add conditional artifacts (only included if they appear in a pruning manifest). @@ -357,7 +355,7 @@ public final class Runfiles { while ((line = reader.readLine()) != null) { Artifact artifact = allowedRunfiles.get(line); if (artifact != null) { - addToManifest(manifest, artifact, root); + manifest.put(artifact.getRootRelativePath(), artifact); } } } @@ -372,15 +370,6 @@ public final class Runfiles { return Pair.of(result, (Map<PathFragment, Artifact>) new HashMap<>(getRootSymlinksAsMap())); } - @VisibleForTesting - protected static void addToManifest(Map<PathFragment, Artifact> manifest, Artifact artifact, - PathFragment root) { - PathFragment rootRelativePath = root != null - ? artifact.getRootRelativePath().relativeTo(root) - : artifact.getRootRelativePath(); - manifest.put(rootRelativePath, artifact); - } - /** * Returns the root symlinks. */ diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java index 20b13b8f83..7929dbc0b2 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java @@ -93,11 +93,6 @@ public class SourceManifestAction extends AbstractFileWriteAction { private final Runfiles runfiles; /** - * If non-null, the paths should be computed relative to this path fragment. - */ - private final PathFragment root; - - /** * Creates a new AbstractSourceManifestAction instance using latin1 encoding * to write the manifest file and with a specified root path for manifest entries. * @@ -105,27 +100,25 @@ public class SourceManifestAction extends AbstractFileWriteAction { * @param owner the action owner * @param output the file to which to write the manifest * @param runfiles runfiles - * @param root the artifacts' root-relative path is relativized to this before writing it out */ private SourceManifestAction(ManifestWriter manifestWriter, ActionOwner owner, Artifact output, - Runfiles runfiles, PathFragment root) { + Runfiles runfiles) { super(owner, getDependencies(runfiles), output, false); this.manifestWriter = manifestWriter; this.runfiles = runfiles; - this.root = root; } @VisibleForTesting public void writeOutputFile(OutputStream out, EventHandler eventHandler) throws IOException { - writeFile(out, runfiles.getRunfilesInputs(root, eventHandler, getOwner().getLocation())); + writeFile(out, runfiles.getRunfilesInputs(eventHandler, getOwner().getLocation())); } @Override public DeterministicWriter newDeterministicWriter(EventHandler eventHandler, Executor executor) throws IOException { final Pair<Map<PathFragment, Artifact>, Map<PathFragment, Artifact>> runfilesInputs = - runfiles.getRunfilesInputs(root, eventHandler, getOwner().getLocation()); + runfiles.getRunfilesInputs(eventHandler, getOwner().getLocation()); return new DeterministicWriter() { @Override public void writeOutputFile(OutputStream out) throws IOException { @@ -215,16 +208,9 @@ public class SourceManifestAction extends AbstractFileWriteAction { f.addPath(rootSymlink.getValue().getPath()); } - if (root != null) { - for (Artifact artifact : runfiles.getArtifactsWithoutMiddlemen()) { - f.addPath(artifact.getRootRelativePath().relativeTo(root)); - f.addPath(artifact.getPath()); - } - } else { - for (Artifact artifact : runfiles.getArtifactsWithoutMiddlemen()) { - f.addPath(artifact.getRootRelativePath()); - f.addPath(artifact.getPath()); - } + for (Artifact artifact : runfiles.getArtifactsWithoutMiddlemen()) { + f.addPath(artifact.getRootRelativePath()); + f.addPath(artifact.getPath()); } return f.hexDigestAndReset(); } @@ -299,7 +285,7 @@ public class SourceManifestAction extends AbstractFileWriteAction { /** Creates an action for the given runfiles. */ public static SourceManifestAction forRunfiles(ManifestType manifestType, ActionOwner owner, Artifact output, Runfiles runfiles) { - return new SourceManifestAction(manifestType, owner, output, runfiles, null); + return new SourceManifestAction(manifestType, owner, output, runfiles); } /** @@ -309,7 +295,6 @@ public class SourceManifestAction extends AbstractFileWriteAction { private final ManifestWriter manifestWriter; private final ActionOwner owner; private final Artifact output; - private PathFragment top; private final Runfiles.Builder runfilesBuilder = new Runfiles.Builder(); public Builder(ManifestType manifestType, ActionOwner owner, Artifact output) { @@ -326,16 +311,7 @@ public class SourceManifestAction extends AbstractFileWriteAction { } public SourceManifestAction build() { - return new SourceManifestAction(manifestWriter, owner, output, runfilesBuilder.build(), top); - } - - /** - * Sets the path fragment which is used to relativize the artifacts' root - * relative paths further. Most likely, you don't need this. - */ - public Builder setTopLevel(PathFragment top) { - this.top = top; - return this; + return new SourceManifestAction(manifestWriter, owner, output, runfilesBuilder.build()); } /** |