diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-08-03 15:06:56 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-08-03 15:43:24 +0200 |
commit | 0abf5fa2d64c76def5a8fa0f960b73ce0566af4d (patch) | |
tree | 7bcb9c3bed3c7121a4179f490b4b5ca8abc4193c /src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java | |
parent | 3774341ff0544497e6e71f405cb222e87f98eb4c (diff) |
Android BusyBox: actions use the default shell env
SpawnActions that run the Android BusyBox now use
the default shell environment.
This has the following benefits:
- Bazel propagates the PATH, TMPDIR envvars to the
action
- Bazel propagates the --action_env envvars to the
action
This allows the Bazel client to pass
--action_env=TMP or --action_env=TEMP (whichever
of the envvars is defined) to the server, so the
BusyBox actions will have TMP/TEMP set (to the
same value as the clientenv), so they can create
temp directories using
java.nio.file.Files.createTempDirectory.
This method seems to be calling the GetTempPath
WinAPI function, which needs the TMP or TEMP
envvar, otherwise it falls back to returning
c:\windows which is non-writable.
There's one drawback of using the default shell
environment, although @ulfjack is working on it:
- PATH is now also part of the action's cache key.
However in a single-machine environment (no
remote execution) and assuming PATH isn't likely
to change between builds, this probably doesn't
poision the action cache in practice.
This change is a short-term solution. Propagating
the client env's TMP/TEMP means we make that part
of the action's cache key.
The ideal long-term solution will be to not
propagate this envvar, and instead let the
execution strategy set it to some
client-env-independent value.
See https://github.com/bazelbuild/bazel/issues/3264
Change-Id: I756a4203b5d86c881bc36cc089e35cde0d419914
PiperOrigin-RevId: 164114502
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java index f0862629d4..bd866ee778 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/LibraryRGeneratorActionBuilder.java @@ -87,9 +87,10 @@ public class LibraryRGeneratorActionBuilder { SpawnAction.Builder spawnActionBuilder = new SpawnAction.Builder(); ruleContext.registerAction( spawnActionBuilder + .useParameterFile(ParameterFileType.UNQUOTED) + .useDefaultShellEnvironment() .addTransitiveInputs(inputs.build()) .addOutputs(ImmutableList.<Artifact>of(rJavaClassJar)) - .useParameterFile(ParameterFileType.UNQUOTED) .setCommandLine(builder.build()) .setExecutable(executable) .setProgressMessage("Generating Library R Classes: %s", ruleContext.getLabel()) |