From 883a1bf2c09be0b335e067059ffc84f3a676048d Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Tue, 7 Jun 2022 22:00:59 +0000 Subject: [PATCH] Generate ccache wrapper scripts instead of symlink Tested with Bazel 5.2. It is a workaround for issue https://github.com/bazelbuild/rules_cc/issues/130 --- scripts/toolchain.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/toolchain.sh b/scripts/toolchain.sh index 9e5e39f4..db952d32 100755 --- a/scripts/toolchain.sh +++ b/scripts/toolchain.sh @@ -14,10 +14,16 @@ pushd "$(dirname "$0")/.." if which ccache >/dev/null 2>&1 && ([ -d 'run' ] && [ -w 'run' ] || [ -w '.' ]); then rm -rf 'run/toolchain' mkdir -p 'run/toolchain' - ln -sf "$(which ccache)" "run/toolchain/$CC" - ln -sf "$(which ccache)" "run/toolchain/$CXX" - export CC="$( realpath -e "run/toolchain")/$CC" - export CXX="$(realpath -e "run/toolchain")/$CXX" + NEW_CC_DIR="$( realpath -e "run/toolchain")" + + for compiler in $CC $CXX; do + echo """#!/bin/bash +$(which ccache) $(which $compiler) \$@ + """ > "$NEW_CC_DIR"/$compiler + done + + chmod +x "$NEW_CC_DIR"/* + export PATH="$NEW_CC_DIR":$PATH fi popd