From e19d4fc16f54bbd70d8482ad411ee13ed7dd2096 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 15 Jan 2025 10:10:28 +0900 Subject: [PATCH] BUILD_LOCALLY: added ccache support --- automation_tools/flatpak_build_only.sh | 2 +- developer_toolbox/build_retrodeck_locally.sh | 24 +++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/automation_tools/flatpak_build_only.sh b/automation_tools/flatpak_build_only.sh index 5f0c632f..21d50ee4 100755 --- a/automation_tools/flatpak_build_only.sh +++ b/automation_tools/flatpak_build_only.sh @@ -23,7 +23,7 @@ command="flatpak-builder --user --force-clean $FLATPAK_BUILD_EXTRA_ARGS \ --install-deps-from=flathub \ --install-deps-from=flathub-beta \ --repo=${GITHUB_WORKSPACE}/retrodeck-repo \ - --disable-download \ + --disable-download $FLATPAK_BUILDER_CCACHE\ \"${GITHUB_WORKSPACE}/$FOLDER\" \ net.retrodeck.retrodeck.yml" diff --git a/developer_toolbox/build_retrodeck_locally.sh b/developer_toolbox/build_retrodeck_locally.sh index fb60f06d..5a74f6dd 100755 --- a/developer_toolbox/build_retrodeck_locally.sh +++ b/developer_toolbox/build_retrodeck_locally.sh @@ -2,13 +2,21 @@ # WARNING: run this script from the project root folder, not from here!! -# Check if script is running with elevated privileges -# if [ "$EUID" -ne 0 ]; then -# read -rp "The build might fail without some superuser permissions, please run me with sudo. Continue WITHOUT sudo (not suggested)? [y/N] " continue_without_sudo -# if [[ "$continue_without_sudo" != "y" ]]; then -# exit 1 -# fi -# fi +# Check if ccache is installed +if ! command -v ccache &> /dev/null; then + echo "Compiler cache (ccache) is not installed. Install it to be able to use the cache and speed up your builds" +else + read -rp "Do you want to use ccache? If you're unsure just say no [Y/n] " use_ccache_input + use_ccache_input=${use_ccache_input:-Y} + if [[ "$use_ccache_input" =~ ^[Yy]$ ]]; then + # Use ccache + export CC="ccache gcc" + export CXX="ccache g++" + export FLATPAK_BUILDER_CCACHE="--ccache" + else + echo "Proceeding without ccache" + fi +fi read -rp "Do you want to use the hashes cache? If you're unsure just say no [Y/n] " use_cache_input use_cache_input=${use_cache_input:-Y} @@ -51,4 +59,4 @@ automation_tools/flatpak_build_only.sh "${@}" automation_tools/flatpak_build_bundle.sh mv -f net.retrodeck.retrodeck.appdata.xml.bak net.retrodeck.retrodeck.appdata.xml -mv -f net.retrodeck.retrodeck.yml.bak net.retrodeck.retrodeck.yml +mv -f net.retrodeck.retrodeck.yml.bak net.retrodeck.retrodeck.yml \ No newline at end of file