diff options
author | 2017-02-27 17:17:00 +0000 | |
---|---|---|
committer | 2017-02-28 11:31:47 +0000 | |
commit | 738e5727bab23961c7cc423606f38f8b97a8150e (patch) | |
tree | 58506febf304f6a0da49a977304ea24c22164dba /src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java | |
parent | 4229823937ad6c6395fefd51b5f617a40d4ce46b (diff) |
sandbox should create regular empty files, not symlink to /dev/null.
Adds a test based on our Python rules that makes sure that this actually
fixes the issue. Thanks to @duggelz for the suggestion. It seems like
our Python rules are the only place that actually provides an
EmptyFilesSupplier to Runfiles, so there's probably no simpler way to
test this behavior in an integration test.
Fix #1458. Fix #2394.
--
PiperOrigin-RevId: 148656193
MOS_MIGRATED_REVID=148656193
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java index bc60eae523..173f1cefa6 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/SymlinkedExecRoot.java @@ -48,7 +48,7 @@ public final class SymlinkedExecRoot implements SandboxExecRoot { cleanFileSystem(inputs.keySet()); FileSystemUtils.createDirectoryAndParentsWithCache(createdDirs, sandboxExecRoot); createParentDirectoriesForInputs(createdDirs, inputs.keySet()); - createSymlinksForInputs(inputs); + createInputs(inputs); createWritableDirectories(createdDirs, writableDirs); createDirectoriesForOutputs(createdDirs, outputs); } @@ -97,19 +97,25 @@ public final class SymlinkedExecRoot implements SandboxExecRoot { } } - private void createSymlinksForInputs(Map<PathFragment, Path> inputs) throws IOException { + private void createInputs(Map<PathFragment, Path> inputs) throws IOException { // All input files are relative to the execroot. for (Entry<PathFragment, Path> entry : inputs.entrySet()) { Path key = sandboxExecRoot.getRelative(entry.getKey()); FileStatus keyStat = key.statNullable(Symlinks.NOFOLLOW); if (keyStat != null) { if (keyStat.isSymbolicLink() + && entry.getValue() != null && key.readSymbolicLink().equals(entry.getValue().asFragment())) { continue; } key.delete(); } - key.createSymbolicLink(entry.getValue()); + // A null value means that we're supposed to create an empty file as the input. + if (entry.getValue() != null) { + key.createSymbolicLink(entry.getValue()); + } else { + FileSystemUtils.createEmptyFile(key); + } } } |