aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java22
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Action.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Executor.java5
4 files changed, 27 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
index 477baa15da..0ace01b68b 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
@@ -36,6 +36,7 @@ import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import com.google.devtools.build.lib.util.Preconditions;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.Symlinks;
@@ -369,23 +370,22 @@ public abstract class AbstractAction implements Action, SkylarkValue {
}
/**
- * Deletes all of the action's output files, if they exist. If any of the
- * Artifacts refers to a directory recursively removes the contents of the
- * directory.
+ * Deletes all of the action's output files, if they exist. If any of the Artifacts refers to a
+ * directory recursively removes the contents of the directory.
*
* @param execRoot the exec root in which this action is executed
*/
- protected void deleteOutputs(Path execRoot) throws IOException {
+ protected void deleteOutputs(FileSystem fileSystem, Path execRoot) throws IOException {
for (Artifact output : getOutputs()) {
- deleteOutput(output);
+ deleteOutput(fileSystem, output);
}
}
/**
- * Helper method to remove an Artifact. If the Artifact refers to a directory
- * recursively removes the contents of the directory.
+ * Helper method to remove an Artifact. If the Artifact refers to a directory recursively removes
+ * the contents of the directory.
*/
- protected void deleteOutput(Artifact output) throws IOException {
+ protected void deleteOutput(FileSystem fileSystem, Artifact output) throws IOException {
Path path = output.getPath();
try {
// Optimize for the common case: output artifacts are files.
@@ -405,7 +405,7 @@ public abstract class AbstractAction implements Action, SkylarkValue {
if (!parentDir.isWritable() && parentDir.getPathString().startsWith(outputRootDir)) {
// Retry deleting after making the parent writable.
parentDir.setWritable(true);
- deleteOutput(output);
+ deleteOutput(fileSystem, output);
} else if (path.isDirectory(Symlinks.NOFOLLOW)) {
FileSystemUtils.deleteTree(path);
} else {
@@ -465,8 +465,8 @@ public abstract class AbstractAction implements Action, SkylarkValue {
}
@Override
- public void prepare(Path execRoot) throws IOException {
- deleteOutputs(execRoot);
+ public void prepare(FileSystem fileSystem, Path execRoot) throws IOException {
+ deleteOutputs(fileSystem, execRoot);
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Action.java b/src/main/java/com/google/devtools/build/lib/actions/Action.java
index e87d79edcf..524c20aa94 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Action.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Action.java
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.actions;
import com.google.devtools.build.lib.actions.extra.ExtraActionInfo;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ConditionallyThreadCompatible;
import com.google.devtools.build.lib.profiler.Describable;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.skyframe.SkyFunction;
import java.io.IOException;
@@ -77,16 +78,14 @@ import javax.annotation.Nullable;
public interface Action extends ActionExecutionMetadata, Describable {
/**
- * Prepares for executing this action; called by the Builder prior to
- * executing the Action itself. This method should prepare the file system, so
- * that the execution of the Action can write the output files. At a minimum
- * any pre-existing and write protected output files should be removed or the
- * permissions should be changed, so that they can be safely overwritten by
- * the action.
+ * Prepares for executing this action; called by the Builder prior to executing the Action itself.
+ * This method should prepare the file system, so that the execution of the Action can write the
+ * output files. At a minimum any pre-existing and write protected output files should be removed
+ * or the permissions should be changed, so that they can be safely overwritten by the action.
*
* @throws IOException if there is an error deleting the outputs.
*/
- void prepare(Path execRoot) throws IOException;
+ void prepare(FileSystem fileSystem, Path execRoot) throws IOException;
/**
* Executes this action; called by the Builder when all of this Action's inputs have been
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
index d48da8f6dc..9898b658a7 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.events.EventKind;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.io.FileOutErr;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunction.Environment;
@@ -118,6 +119,10 @@ public class ActionExecutionContext implements Closeable {
return metadataHandler;
}
+ public FileSystem getFileSystem() {
+ return executor.getFileSystem();
+ }
+
public Path getExecRoot() {
return executor.getExecRoot();
}
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Executor.java b/src/main/java/com/google/devtools/build/lib/actions/Executor.java
index 673c7bedae..292e78fcf5 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Executor.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Executor.java
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.actions;
import com.google.common.eventbus.EventBus;
import com.google.devtools.build.lib.clock.Clock;
import com.google.devtools.build.lib.events.EventHandler;
+import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.common.options.OptionsClassProvider;
@@ -36,6 +37,10 @@ import com.google.devtools.common.options.OptionsClassProvider;
* they both provide services to actions being executed and are passed to almost the same places.
*/
public interface Executor {
+
+ /** Returns the file system of blaze. */
+ FileSystem getFileSystem();
+
/**
* Returns the execution root. This is the directory underneath which Blaze builds its entire
* output working tree, including the source symlink forest. All build actions are executed