aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2016-09-30 14:16:29 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-10-04 08:52:56 +0000
commit96c047c430c1569fdfc649de358b34aeaff1f6bb (patch)
treeeede9d4db91c96be387f36093bf143660f0c5cf3 /src/main/java/com/google/devtools/build/lib/analysis
parenta6b4cbbd4a4bbb42eefe8fb0e646cd30780394e4 (diff)
cc_inc_library deletes its output directory before execution.
This ensures that stale outputs from prior builds do not remain to confuse the compiler. Fixes #1778. -- Change-Id: I31b5c3e7e5970cf45c3ff10144ddfc73540ef9af Reviewed-on: https://bazel-review.googlesource.com/6250 MOS_MIGRATED_REVID=134780501
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkAction.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkAction.java
index 06d353dfc1..6bbbbd85d2 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/CreateIncSymlinkAction.java
@@ -27,8 +27,9 @@ import com.google.devtools.build.lib.actions.Executor;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.util.Fingerprint;
+import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
-
+import com.google.devtools.build.lib.vfs.Symlinks;
import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;
@@ -39,14 +40,26 @@ import java.util.SortedMap;
@Immutable
public final class CreateIncSymlinkAction extends AbstractAction {
private final ImmutableSortedMap<Artifact, Artifact> symlinks;
+ private final Path includePath;
/**
* Creates a new instance. The symlinks map maps symlinks to their targets, i.e. the symlink paths
- * must be unique, but several of them can point to the same target.
+ * must be unique, but several of them can point to the same target. All outputs must be under
+ * {@code includePath}.
*/
- public CreateIncSymlinkAction(ActionOwner owner, Map<Artifact, Artifact> symlinks) {
+ public CreateIncSymlinkAction(
+ ActionOwner owner, Map<Artifact, Artifact> symlinks, Path includePath) {
super(owner, ImmutableList.copyOf(symlinks.values()), ImmutableList.copyOf(symlinks.keySet()));
this.symlinks = ImmutableSortedMap.copyOf(symlinks, Artifact.EXEC_PATH_COMPARATOR);
+ this.includePath = includePath;
+ }
+
+ @Override
+ public void prepare(Path execRoot) throws IOException {
+ if (includePath.isDirectory(Symlinks.NOFOLLOW)) {
+ FileSystemUtils.deleteTree(includePath);
+ }
+ super.prepare(execRoot);
}
@Override