From 4795564177d5fe62a10bf69acbd6a4f925a0022e Mon Sep 17 00:00:00 2001 From: Yue Gan Date: Tue, 20 Sep 2016 13:21:51 +0000 Subject: Add flag --nosandbox/--no_sandbox/--no-sandbox to disable sandbox. -- MOS_MIGRATED_REVID=133697962 --- .../devtools/build/lib/actions/BaseSpawn.java | 80 ++++++++++++---------- 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java') diff --git a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java index 697645d730..dd2d5de509 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java @@ -31,9 +31,7 @@ import java.util.Map; import java.util.Set; import javax.annotation.concurrent.Immutable; -/** - * Base implementation of a Spawn. - */ +/** Base implementation of a Spawn. */ @Immutable public class BaseSpawn implements Spawn { private final ImmutableList arguments; @@ -72,12 +70,13 @@ public class BaseSpawn implements Spawn { * Returns a new Spawn. The caller must not modify the parameters after the call; neither will * this method. */ - public BaseSpawn(List arguments, - Map environment, - Map executionInfo, - RunfilesSupplier runfilesSupplier, - ActionExecutionMetadata action, - ResourceSet localResources) { + public BaseSpawn( + List arguments, + Map environment, + Map executionInfo, + RunfilesSupplier runfilesSupplier, + ActionExecutionMetadata action, + ResourceSet localResources) { this( arguments, environment, @@ -93,7 +92,8 @@ public class BaseSpawn implements Spawn { * Returns a new Spawn. The caller must not modify the parameters after the call; neither will * this method. */ - public BaseSpawn(List arguments, + public BaseSpawn( + List arguments, Map environment, Map executionInfo, Map runfilesManifests, @@ -110,10 +110,9 @@ public class BaseSpawn implements Spawn { ImmutableSet.of()); } - /** - * Returns a new Spawn. - */ - public BaseSpawn(List arguments, + /** Returns a new Spawn. */ + public BaseSpawn( + List arguments, Map environment, Map executionInfo, ActionExecutionMetadata action, @@ -150,6 +149,11 @@ public class BaseSpawn implements Spawn { return pathFragment.getParentDirectory().getChild(pathFragment.getBaseName() + ".runfiles"); } + @Override + public boolean hasNoSandbox() { + return executionInfo.containsKey("nosandbox"); + } + @Override public boolean isRemotable() { return !executionInfo.containsKey("local"); @@ -186,9 +190,11 @@ public class BaseSpawn implements Spawn { info.addAllArgument(getArguments()); for (Map.Entry variable : getEnvironment().entrySet()) { - info.addVariable(EnvironmentVariable.newBuilder() - .setName(variable.getKey()) - .setValue(variable.getValue()).build()); + info.addVariable( + EnvironmentVariable.newBuilder() + .setName(variable.getKey()) + .setValue(variable.getValue()) + .build()); } for (ActionInput input : getInputFiles()) { // Explicitly ignore middleman artifacts here. @@ -268,38 +274,38 @@ public class BaseSpawn implements Spawn { } @Override - public ActionOwner getOwner() { return action.getOwner(); } + public ActionOwner getOwner() { + return action.getOwner(); + } @Override - public String getMnemonic() { return action.getMnemonic(); } + public String getMnemonic() { + return action.getMnemonic(); + } - /** - * Convert a working dir + environment map + arg list into a Bourne shell - * command. - */ - public static String asShellCommand(Collection arguments, - Path workingDirectory, - Map environment) { + /** Convert a working dir + environment map + arg list into a Bourne shell command. */ + public static String asShellCommand( + Collection arguments, Path workingDirectory, Map environment) { // We print this command out in such a way that it can safely be // copied+pasted as a Bourne shell command. This is extremely valuable for // debugging. - return CommandFailureUtils.describeCommand(CommandDescriptionForm.COMPLETE, - arguments, environment, workingDirectory.getPathString()); + return CommandFailureUtils.describeCommand( + CommandDescriptionForm.COMPLETE, arguments, environment, workingDirectory.getPathString()); } - /** - * A local spawn requiring zero resources. - */ + /** A local spawn requiring zero resources. */ public static class Local extends BaseSpawn { - public Local(List arguments, Map environment, - ActionExecutionMetadata action) { + public Local( + List arguments, Map environment, ActionExecutionMetadata action) { this(arguments, environment, ImmutableMap.of(), action); } - public Local(List arguments, Map environment, - Map executionInfo, ActionExecutionMetadata action) { - super(arguments, environment, buildExecutionInfo(executionInfo), - action, ResourceSet.ZERO); + public Local( + List arguments, + Map environment, + Map executionInfo, + ActionExecutionMetadata action) { + super(arguments, environment, buildExecutionInfo(executionInfo), action, ResourceSet.ZERO); } private static ImmutableMap buildExecutionInfo( -- cgit v1.2.3