Skip to content

Commit

Permalink
Generate ccache wrapper scripts instead of symlink
Browse files Browse the repository at this point in the history
Tested with Bazel 5.2. It is a workaround for issue
bazelbuild/rules_cc#130
  • Loading branch information
chenhao94 committed Jun 9, 2022
1 parent 1f4ae16 commit 883a1bf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 883a1bf

Please sign in to comment.