-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable CCache if installation or setup fails
On MacOS 13 the Homebrew CCache installation was seen to error with a segmentation fault. As CCache is not essential for building just show a (very) visibile error message and disable it.
- Loading branch information
Showing
2 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,41 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2021 Alexander Grund | ||
# Copyright 2021-2024 Alexander Grund | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# (See accompanying file LICENSE_1_0.txt or copy at | ||
# http://www.boost.org/LICENSE_1_0.txt) | ||
# | ||
# Installs and sets up ccache | ||
|
||
set -ex | ||
set -eu | ||
set +x | ||
|
||
if ! command -v ccache &> /dev/null; then | ||
if [ -f "/etc/debian_version" ]; then | ||
sudo apt-get install ${NET_RETRY_COUNT:+ -o Acquire::Retries=$NET_RETRY_COUNT} -y ccache | ||
elif command -v brew &> /dev/null; then | ||
brew update > /dev/null | ||
if ! brew install ccache; then | ||
if ! brew install ccache 2>&1; then | ||
echo "Installing CCache via Homebrew failed." | ||
echo "Cleaning up Python binaries and trying again" | ||
# Workaround issue with unexpected symlinks: https://github.com/actions/runner-images/issues/6817 | ||
for f in 2to3 idle3 pydoc3 python3 python3-config; do | ||
rm /usr/local/bin/$f || true | ||
done | ||
# Try again | ||
brew install ccache | ||
brew install ccache 2>&1 | ||
fi | ||
fi | ||
fi | ||
ccache --set-config=cache_dir=${B2_CCACHE_DIR:-~/.ccache} | ||
ccache --set-config=max_size=${B2_CCACHE_SIZE:-500M} | ||
|
||
# Sanity check that CCache is installed, executable and works at all | ||
ccache --version | ||
|
||
# This also sets the default values | ||
echo "Using cache directory of size ${B2_CCACHE_SIZE:=500M} at '${B2_CCACHE_DIR:=$HOME/.ccache}'" | ||
|
||
|
||
ccache --set-config=cache_dir="$B2_CCACHE_DIR" | ||
ccache --set-config=max_size="$B2_CCACHE_SIZE" | ||
ccache -z | ||
echo "CCache config: $(ccache -p)" |