-
-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compiler cache and fix CMake deprecation warnings (#2132)
- Fix use of deprecated `exec_program`. - Reformat 'UninstallConky.cmake.in' file. - Separate BUILD_TESTS (now BUILD_TESTING to shadow CTest variable) from MAINTAINER_MODE flag. - Remove BUILD_TESTS flag from CI, default it already true. - Add support for (s)ccache, enable it by default. - Add REPRODUCIBLE_BUILD to disable (s)ccache default. - Set REPRODUCIBLE_BUILD=ON in nix flake. - Add sccache to CI. - Add CI detection for possible future use, stored in ENV_IS_CI variable. - Minor formatting tweaks. Signed-off-by: Tin Švagelj <[email protected]>
- Loading branch information
Showing
16 changed files
with
252 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/sh | ||
|
||
export SCCACHE_VERSION="${SCCACHE_VERSION:=0.9.0}" | ||
|
||
export sccache_arch="x86_64" | ||
if [ "$RUNNER_ARCH" = "X86" ]; then | ||
export sccache_arch="i686" | ||
elif [ "$RUNNER_ARCH" = "X64" ]; then | ||
export sccache_arch="x86_64" | ||
elif [ "$RUNNER_ARCH" = "ARM" ]; then | ||
export sccache_arch="armv7" | ||
elif [ "$RUNNER_ARCH" = "ARM64" ]; then | ||
export sccache_arch="aarch64" | ||
fi | ||
|
||
install_sccache() { | ||
export sccache_archive="sccache-v$SCCACHE_VERSION-$sccache_arch-$sccache_os" | ||
export sccache_url="https://github.com/mozilla/sccache/releases/download/v$SCCACHE_VERSION/$sccache_archive.tar.gz" | ||
|
||
echo "Downloading $sccache_url..." | ||
if ! wget -q "$sccache_url"; then | ||
echo "Can't download $sccache_url.">2 | ||
exit 1 | ||
fi | ||
echo "Extracting $sccache_archive.tar.gz..." | ||
if ! tar -xzf "$sccache_archive.tar.gz" >/dev/null; then | ||
echo "Can't extract $sccache_archive.tar.gz">2 | ||
exit 1 | ||
fi | ||
chmod +x "$sccache_archive/sccache" | ||
sudo cp "$sccache_archive/sccache" "/usr/local/bin/sccache" | ||
rm -rf "$sccache_archive.tar.gz" | ||
rm -rf "$sccache_archive" | ||
} | ||
|
||
export sccache_os="unknown-linux-musl" | ||
if [ "$RUNNER_OS" = "Linux" ]; then | ||
export sccache_os="unknown-linux-musl" | ||
if [ "$RUNNER_ARCH" = "ARM" ]; then | ||
export sccache_os="unknown-linux-musleabi" | ||
fi | ||
if ! install_sccache; then | ||
echo "Unable to install sccache!" >2 | ||
exit 1 | ||
fi | ||
elif [ "$RUNNER_OS" = "macOS" ]; then | ||
export sccache_os="apple-darwin" | ||
if ! install_sccache; then | ||
echo "Unable to install sccache!" >2 | ||
exit 1 | ||
fi | ||
elif [ "$RUNNER_OS" = "Windows" ]; then | ||
export sccache_os="pc-windows-msvc" | ||
if ! install_sccache; then | ||
echo "Unable to install sccache!" >2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "sccache installed." | ||
|
||
# Configure | ||
mkdir $HOME/.sccache | ||
echo "SCCACHE_DIR=$HOME/.sccache" >> $GITHUB_ENV | ||
if [ "$RUNNER_DEBUG" = "1" ]; then | ||
echo "Running with debug output; cached binary artifacts will be ignored to produce a cleaner build" | ||
echo "SCCACHE_RECACHE=true" >> $GITHUB_ENV | ||
fi | ||
|
||
echo "sccache configured." |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if(NOT USE_CCACHE) | ||
return() | ||
endif() | ||
|
||
find_program(CCACHE_COMMAND sccache) | ||
if(CCACHE_COMMAND) | ||
mark_as_advanced(CCACHE_COMMAND) | ||
message(STATUS "Using sccache; disable with '-DUSE_CCACHE=OFF'") | ||
else() | ||
find_program(CCACHE_COMMAND ccache) | ||
if(CCACHE_COMMAND) | ||
mark_as_advanced(CCACHE_COMMAND) | ||
message(STATUS "Using ccache; disable with '-DUSE_CCACHE=OFF'") | ||
else() | ||
message(WARNING "Neither sccache nor ccache found") | ||
return() | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_COMMAND}") | ||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}") | ||
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_COMMAND}") |
Oops, something went wrong.