Skip to content

Commit

Permalink
Use a relative path for the runfiles tree
Browse files Browse the repository at this point in the history
Add preconditions to enforce this and remove some now unnecessary code.

A small step towards bazelbuild#1593.

--
PiperOrigin-RevId: 150625693
MOS_MIGRATED_REVID=150625693
  • Loading branch information
ulfjack authored and hermione521 committed Mar 21, 2017
1 parent 4475bf1 commit edd531d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public RunfilesSupplierImpl(
PathFragment runfilesDir,
Runfiles runfiles,
@Nullable Artifact manifest) {
Preconditions.checkArgument(!runfilesDir.isAbsolute());
this.runfilesDir = Preconditions.checkNotNull(runfilesDir);
this.runfiles = Preconditions.checkNotNull(runfiles);
this.manifest = manifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void exec(TestRunnerAction action, ActionExecutionContext actionExecution
ImmutableMap.copyOf(env),
ImmutableMap.copyOf(info),
new RunfilesSupplierImpl(
runfilesDir.asFragment(), action.getExecutionSettings().getRunfiles()),
runfilesDir.relativeTo(execRoot), action.getExecutionSettings().getRunfiles()),
/*inputs=*/ImmutableList.copyOf(action.getInputs()),
/*tools=*/ImmutableList.<Artifact>of(),
/*filesetManifests=*/ImmutableList.<Artifact>of(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ void mountRunfilesFromSuppliers(Map<PathFragment, Path> mounts, Spawn spawn) thr
for (Map.Entry<PathFragment, Map<PathFragment, Artifact>> rootAndMappings :
rootsAndMappings.entrySet()) {
PathFragment root = rootAndMappings.getKey();
if (root.isAbsolute()) {
root = root.relativeTo(execRoot.asFragment());
}
Preconditions.checkState(!root.isAbsolute());
for (Map.Entry<PathFragment, Artifact> mapping : rootAndMappings.getValue().entrySet()) {
Artifact sourceArtifact = mapping.getValue();
Path source =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public void testInputManifestsRemovedIfSupplied() throws Exception {
Action[] actions = builder()
.addInput(manifest)
.addRunfilesSupplier(
new RunfilesSupplierImpl(new PathFragment("/destination/"), Runfiles.EMPTY, manifest))
new RunfilesSupplierImpl(new PathFragment("destination"), Runfiles.EMPTY, manifest))
.addOutput(getBinArtifactWithNoOwner("output"))
.setExecutable(scratch.file("/bin/xxx").asFragment())
.setProgressMessage("Test")
Expand Down

0 comments on commit edd531d

Please sign in to comment.