|
22 | 22 | import com.google.devtools.build.lib.actions.Spawn;
|
23 | 23 | import com.google.devtools.build.lib.actions.SpawnResult;
|
24 | 24 | import com.google.devtools.build.lib.actions.Spawns;
|
| 25 | +import com.google.devtools.build.lib.events.Event; |
25 | 26 | import com.google.devtools.build.lib.exec.ActionContextProvider;
|
26 | 27 | import com.google.devtools.build.lib.exec.SpawnRunner;
|
27 | 28 | import com.google.devtools.build.lib.exec.apple.XcodeLocalEnvProvider;
|
@@ -71,28 +72,35 @@ public static SandboxActionContextProvider create(CommandEnvironment cmdEnv, Pat
|
71 | 72 | contexts.add(new ProcessWrapperSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner));
|
72 | 73 | }
|
73 | 74 |
|
74 |
| - // This strategy uses Docker to execute spawns. It should work on all platforms that support |
75 |
| - // Docker. |
76 |
| - getPathToDockerClient(cmdEnv) |
77 |
| - .ifPresent( |
78 |
| - dockerClient -> { |
79 |
| - if (DockerSandboxedSpawnRunner.isSupported(cmdEnv, dockerClient)) { |
80 |
| - String defaultImage = options.getOptions(SandboxOptions.class).dockerImage; |
81 |
| - boolean useCustomizedImages = |
82 |
| - options.getOptions(SandboxOptions.class).dockerUseCustomizedImages; |
83 |
| - SpawnRunner spawnRunner = |
84 |
| - withFallback( |
85 |
| - cmdEnv, |
86 |
| - new DockerSandboxedSpawnRunner( |
87 |
| - cmdEnv, |
88 |
| - dockerClient, |
89 |
| - sandboxBase, |
90 |
| - defaultImage, |
91 |
| - timeoutKillDelay, |
92 |
| - useCustomizedImages)); |
93 |
| - contexts.add(new DockerSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner)); |
94 |
| - } |
95 |
| - }); |
| 75 | + SandboxOptions sandboxOptions = options.getOptions(SandboxOptions.class); |
| 76 | + |
| 77 | + if (sandboxOptions.enableDockerSandbox) { |
| 78 | + // This strategy uses Docker to execute spawns. It should work on all platforms that support |
| 79 | + // Docker. |
| 80 | + getPathToDockerClient(cmdEnv) |
| 81 | + .ifPresent( |
| 82 | + dockerClient -> { |
| 83 | + if (DockerSandboxedSpawnRunner.isSupported(cmdEnv, dockerClient)) { |
| 84 | + String defaultImage = sandboxOptions.dockerImage; |
| 85 | + boolean useCustomizedImages = sandboxOptions.dockerUseCustomizedImages; |
| 86 | + SpawnRunner spawnRunner = |
| 87 | + withFallback( |
| 88 | + cmdEnv, |
| 89 | + new DockerSandboxedSpawnRunner( |
| 90 | + cmdEnv, |
| 91 | + dockerClient, |
| 92 | + sandboxBase, |
| 93 | + defaultImage, |
| 94 | + timeoutKillDelay, |
| 95 | + useCustomizedImages)); |
| 96 | + contexts.add(new DockerSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner)); |
| 97 | + } |
| 98 | + }); |
| 99 | + } else if (sandboxOptions.dockerVerbose) { |
| 100 | + cmdEnv.getReporter().handle(Event.info( |
| 101 | + "Docker sandboxing disabled. Use the '--experimental_enable_docker_sandbox' command " |
| 102 | + + "line option to enable it")); |
| 103 | + } |
96 | 104 |
|
97 | 105 | // This is the preferred sandboxing strategy on Linux.
|
98 | 106 | if (LinuxSandboxedSpawnRunner.isSupported(cmdEnv)) {
|
|
0 commit comments