Support configuring cache prefix with an environment variable
The user may want to build with `--sandbox_tmpfs_path=/tmp`, in which case the Zig cache will not be shared between sandboxes, massively slowing down the build. With this feature, the user can pass flags like `--repo_env=BAZEL_ZIG_CC_CACHE_PREFIX=$HOME/.cache/bazel-zig-cc` together with `--sandbox_writable_path=$HOME/.cache/bazel-zig-cc` to put the cache somewhere else which can be shared between sandboxes.
This commit is contained in:
parent
23d9b9d39e
commit
0612c6ed9c
@ -79,7 +79,9 @@ def toolchains(
|
||||
ZIG_TOOL_WRAPPER = """#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [[ -n "$TMPDIR" ]]; then
|
||||
if [[ -n "{cache_prefix}" ]]; then
|
||||
_cache_prefix="{cache_prefix}"
|
||||
elif [[ -n "$TMPDIR" ]]; then
|
||||
_cache_prefix=$TMPDIR
|
||||
elif [[ -n "$HOME" ]]; then
|
||||
if [[ "$(uname)" = Darwin ]]; then
|
||||
@ -149,6 +151,7 @@ def _zig_repository_impl(repository_ctx):
|
||||
zig_tool_wrapper = ZIG_TOOL_WRAPPER.format(
|
||||
zig = str(repository_ctx.path("zig")),
|
||||
zig_tool = zig_tool,
|
||||
cache_prefix = repository_ctx.os.environ.get("BAZEL_ZIG_CC_CACHE_PREFIX", ""),
|
||||
)
|
||||
if os == "windows":
|
||||
zig_tool_wrapper = ZIG_TOOL_WRAPPER_WINDOWS.format(
|
||||
|
Loading…
Reference in New Issue
Block a user