summaryrefslogtreecommitdiff
path: root/Toolchain
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-08-05 23:45:07 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-08 10:55:36 +0200
commit9809e685c1840c6149f3f23b7561a6cc633ace46 (patch)
treee3e498d118931d703d670d5f71ed31136219bc9a /Toolchain
parent301cab188cfd64f0f22f95050160afc3a59fdef5 (diff)
downloadserenity-9809e685c1840c6149f3f23b7561a6cc633ace46.zip
Toolchain: Add caching to BuildClang.sh for CI
Diffstat (limited to 'Toolchain')
-rwxr-xr-xToolchain/BuildClang.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/Toolchain/BuildClang.sh b/Toolchain/BuildClang.sh
index 27f6d3f392..465a52a2db 100755
--- a/Toolchain/BuildClang.sh
+++ b/Toolchain/BuildClang.sh
@@ -115,6 +115,43 @@ then
exit 1
fi
+# === CHECK CACHE AND REUSE ===
+
+pushd "$DIR"
+ if [ "$TRY_USE_LOCAL_TOOLCHAIN" = "y" ]; then
+ mkdir -p Cache
+ echo "Cache (before):"
+ ls -l Cache
+ CACHED_TOOLCHAIN_ARCHIVE="Cache/ToolchainBinariesGithubActions.tar.gz"
+ if [ -r "${CACHED_TOOLCHAIN_ARCHIVE}" ] ; then
+ echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} exists!"
+ echo "Extracting toolchain from cache:"
+ if tar xzf "${CACHED_TOOLCHAIN_ARCHIVE}" ; then
+ echo "Done 'building' the toolchain."
+ echo "Cache unchanged."
+ exit 0
+ else
+ echo
+ echo
+ echo
+ echo "Could not extract cached toolchain archive."
+ echo "This means the cache is broken and *should be removed*!"
+ echo "As Github Actions cannot update a cache, this will unnecessarily"
+ echo "slow down all future builds for this hash, until someone"
+ echo "resets the cache."
+ echo
+ echo
+ echo
+ rm -f "${CACHED_TOOLCHAIN_ARCHIVE}"
+ fi
+ else
+ echo "Cache at ${CACHED_TOOLCHAIN_ARCHIVE} does not exist."
+ echo "Will rebuild toolchain from scratch, and save the result."
+ fi
+ fi
+ echo "::group::Actually building Toolchain"
+popd
+
# === DOWNLOAD AND PATCH ===
pushd "$DIR/Tarballs"
@@ -351,3 +388,19 @@ pushd "$DIR/Build/clang/$ARCH"
buildstep "binutils/install" "$MAKE" install || exit 1
popd
popd
+
+# === SAVE TO CACHE ===
+pushd "$DIR"
+ if [ "$TRY_USE_LOCAL_TOOLCHAIN" = "y" ]; then
+ echo "::endgroup::"
+ echo "Building cache tar:"
+
+ echo "Building cache tar:"
+
+ rm -f "${CACHED_TOOLCHAIN_ARCHIVE}" # Just in case
+
+ tar czf "${CACHED_TOOLCHAIN_ARCHIVE}" Local/
+ echo "Cache (after):"
+ ls -l Cache
+ fi
+popd