aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-09-30 11:44:20 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-09-30 14:11:25 +0000
commite898023ffc6c47a27312c4d3659dbeeccdb3cd37 (patch)
tree09ee6e816484b8789cbe46ae1a402bcd562576df /src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java
parentd59bcb6333be731d82c51c20211ecabebe194f19 (diff)
Fix #1849: Sandboxing on OS X should be turned off by default for 0.3.2.
This restructures the way we set the default Spawn strategy so that each BlazeModule supplying a SpawnActionContext has an ActionContextConsumer that sets its own SpawnActionContext as the default, with the BazelRulesModule being put as the last module loaded in BazelMain, so that it can override that decision - it only does, if the user explicitly specifies a --spawn_strategy flag. IMHO this is a much saner approach than the older one. So the flow is essentially this: - StandaloneActionContextConsumer sets the default strategy to "standalone". - SandboxActionContextConsumer sets the default strategy to "sandboxed", but only on Linux - BazelRulesModule sets the default strategy to the value of the --spawn_strategy flag, if it is set. -- MOS_MIGRATED_REVID=134770427
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java
index cd468fd1f9..403b8b9837 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextConsumer.java
@@ -30,22 +30,33 @@ import com.google.devtools.build.lib.util.OS;
final class SandboxActionContextConsumer implements ActionContextConsumer {
private final ImmutableMultimap<Class<? extends ActionContext>, String> contexts;
+ private final ImmutableMap<String, String> spawnContexts;
public SandboxActionContextConsumer(CommandEnvironment env) {
ImmutableMultimap.Builder<Class<? extends ActionContext>, String> contexts =
ImmutableMultimap.builder();
+ ImmutableMap.Builder<String, String> spawnContexts = ImmutableMap.builder();
+ // This makes the "sandboxed" strategy available via --spawn_strategy=sandboxed,
+ // but it is not necessarily the default.
if ((OS.getCurrent() == OS.LINUX && LinuxSandboxedStrategy.isSupported(env))
|| (OS.getCurrent() == OS.DARWIN && DarwinSandboxRunner.isSupported())) {
contexts.put(SpawnActionContext.class, "sandboxed");
+
+ // This makes the "sandboxed" strategy the default Spawn strategy on Linux, unless it is
+ // overridden by a later BlazeModule.
+ if (OS.getCurrent() == OS.LINUX) {
+ spawnContexts.put("", "sandboxed");
+ }
}
this.contexts = contexts.build();
+ this.spawnContexts = spawnContexts.build();
}
@Override
public ImmutableMap<String, String> getSpawnActionContexts() {
- return ImmutableMap.of();
+ return spawnContexts;
}
@Override