aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java31
1 files changed, 20 insertions, 11 deletions
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 2cea7155d4..037f47b1ad 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
@@ -43,6 +43,19 @@ import javax.annotation.Nullable;
*/
public class ActionExecutionContext implements Closeable {
+ /** Enum for --subcommands flag */
+ public enum ShowSubcommands {
+ TRUE(true, false), PRETTY_PRINT(true, true), FALSE(false, false);
+
+ private final boolean shouldShowSubcommands;
+ private final boolean prettyPrintArgs;
+
+ private ShowSubcommands(boolean shouldShowSubcommands, boolean prettyPrintArgs) {
+ this.shouldShowSubcommands = shouldShowSubcommands;
+ this.prettyPrintArgs = prettyPrintArgs;
+ }
+ }
+
private final Executor executor;
private final MetadataProvider actionInputFileCache;
private final ActionInputPrefetcher actionInputPrefetcher;
@@ -236,19 +249,15 @@ public class ActionExecutionContext implements Closeable {
}
/**
- * Whether this Executor reports subcommands. If not, reportSubcommand has no effect.
- * This is provided so the caller of reportSubcommand can avoid wastefully constructing the
- * subcommand string.
- */
- public boolean reportsSubcommands() {
- return executor.reportsSubcommands();
- }
-
- /**
* Report a subcommand event to this Executor's Reporter and, if action
* logging is enabled, post it on its EventBus.
*/
- public void reportSubcommand(Spawn spawn) {
+ public void maybeReportSubcommand(Spawn spawn) {
+ ShowSubcommands showSubcommands = executor.reportsSubcommands();
+ if (!showSubcommands.shouldShowSubcommands) {
+ return;
+ }
+
String reason;
ActionOwner owner = spawn.getResourceOwner().getOwner();
if (owner == null) {
@@ -257,7 +266,7 @@ public class ActionExecutionContext implements Closeable {
reason = Label.print(owner.getLabel())
+ " [" + spawn.getResourceOwner().prettyPrint() + "]";
}
- String message = Spawns.asShellCommand(spawn, getExecRoot());
+ String message = Spawns.asShellCommand(spawn, getExecRoot(), showSubcommands.prettyPrintArgs);
getEventHandler().handle(Event.of(EventKind.SUBCOMMAND, null, "# " + reason + "\n" + message));
}