From e6311e5b0e8105ea8cd013cc13d4b03965816a06 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 17 Nov 2024 14:25:56 +0300 Subject: [PATCH] ci: add wafcache to all targets that use Waf, except Android which uses generated CMakeLists instead --- .github/workflows/c-cpp.yml | 27 +++++++++++++++++++++++++++ scripts/gha/build_apple.sh | 2 +- scripts/gha/build_linux.sh | 4 ++-- scripts/gha/build_motomagx.sh | 2 +- scripts/gha/build_nswitch.sh | 2 +- scripts/gha/build_nswitch_docker.sh | 2 +- scripts/gha/build_psvita.sh | 4 ++-- scripts/gha/build_win32.sh | 4 ++-- 8 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 4167fd7990..709e5f6101 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -6,8 +6,21 @@ jobs: # steps: # - name: Cleanup # run: rm -rf .* || true + get_prev_runid: + runs-on: ubuntu-latest + outputs: + value: ${{ steps.do.outputs.value }} + steps: + - id: do + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + value=$(gh run -R ${{ github.repository }} list -b${{ github.ref_name }} -ssuccess -L1 --json databaseId -q'.[0].databaseId') + echo "Last run ID is $value" + echo "value=$value" >> "$GITHUB_OUTPUT" build: runs-on: ${{ matrix.os }} + needs: get_prev_runid continue-on-error: true strategy: fail-fast: false @@ -69,11 +82,19 @@ jobs: SDL_VERSION: 2.30.11 GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CROSSCOMPILING: ${{ matrix.cross }} + WAFCACHE: $HOME/wafcache + WAFCACHE_EVICT_MAX_BYTES: 1000000 # github only gives 10gb for the whole repository + WAFCACHE_STATS: 1 # enable statistics in build log steps: - name: Checkout uses: actions/checkout@v4 with: submodules: recursive + - name: Restore cache + uses: actions/cache/restore@v4 + with: + key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ needs.get_prev_runid.outputs.value }} + path: ~/wafcache - name: Install dependencies run: bash scripts/gha/deps_${{ matrix.targetos }}.sh - name: Build engine @@ -85,6 +106,12 @@ jobs: with: name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }} path: artifacts/* + - name: Save cache + uses: actions/cache/save@v4 + with: + path: ~/wafcache + key: ${{ runner.os }}-${{ matrix.targetos }}-${{ matrix.targetarch }}-${{ github.run_id }} + flatpak: runs-on: ubuntu-latest strategy: diff --git a/scripts/gha/build_apple.sh b/scripts/gha/build_apple.sh index 3be0506b94..677aae4a09 100755 --- a/scripts/gha/build_apple.sh +++ b/scripts/gha/build_apple.sh @@ -8,7 +8,7 @@ pushd hlsdk || die ./waf configure build install --destdir=../bin || die popd -./waf configure --enable-utils --enable-tests --enable-lto build install --destdir=bin || die_configure +./waf configure --enable-utils --enable-tests --enable-lto --enable-wafcache build --zones=wafcache install --destdir=bin || die_configure cp -vr /Library/Frameworks/SDL2.framework bin diff --git a/scripts/gha/build_linux.sh b/scripts/gha/build_linux.sh index 3c14f06563..5cd968b448 100755 --- a/scripts/gha/build_linux.sh +++ b/scripts/gha/build_linux.sh @@ -61,9 +61,9 @@ build_engine() fi if [ "$1" = "dedicated" ]; then - ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d || die_configure + ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -d --enable-wafcache || die_configure elif [ "$1" = "full" ]; then - ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils || die_configure + ./waf configure $AMD64 $ENABLE_TESTS --enable-lto --enable-bundled-deps -s SDL2_linux --enable-stb --enable-utils --enable-wafcache || die_configure else die fi diff --git a/scripts/gha/build_motomagx.sh b/scripts/gha/build_motomagx.sh index e38aadbeb7..77593e1185 100755 --- a/scripts/gha/build_motomagx.sh +++ b/scripts/gha/build_motomagx.sh @@ -12,7 +12,7 @@ pushd hlsdk || die ./waf configure -T fast --enable-magx --enable-simple-mod-hacks build install --destdir=../Xash || die popd -./waf configure -T fast --enable-magx build install --destdir=Xash/ || die +./waf configure -T fast --enable-magx --enable-wafcache build install --destdir=Xash/ || die cat > Xash/run.sh << 'EOF' mypath=${0%/*} diff --git a/scripts/gha/build_nswitch.sh b/scripts/gha/build_nswitch.sh index 1f841354c3..505ae2eb54 100644 --- a/scripts/gha/build_nswitch.sh +++ b/scripts/gha/build_nswitch.sh @@ -11,7 +11,7 @@ mkdir -p artifacts/ || die echo "Running build script in Docker container..." -docker run --name xash-build --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die +docker run --name xash-build --rm -v `pwd`:`pwd` -v $HOME/.cache:$HOME/.cache -w `pwd` devkitpro/devkita64:latest bash ./scripts/gha/build_nswitch_docker.sh || die echo "Packaging artifacts..." diff --git a/scripts/gha/build_nswitch_docker.sh b/scripts/gha/build_nswitch_docker.sh index 00e76a6bf4..40c84615cf 100644 --- a/scripts/gha/build_nswitch_docker.sh +++ b/scripts/gha/build_nswitch_docker.sh @@ -42,7 +42,7 @@ make -C libsolder install || die echo "Building engine..." -./waf configure -T release --nswitch || die_configure +./waf configure -T release --nswitch --enable-wafcache || die_configure ./waf build install --destdir=pkgtemp/xash3d -v || die echo "Building HLSDK..." diff --git a/scripts/gha/build_psvita.sh b/scripts/gha/build_psvita.sh index 11acecba85..cd89568b96 100644 --- a/scripts/gha/build_psvita.sh +++ b/scripts/gha/build_psvita.sh @@ -44,8 +44,8 @@ popd echo "Building engine..." -./waf configure -T release --psvita || die_configure -./waf build install --destdir=pkgtemp/data/xash3d -v || die +./waf configure -T release --psvita --enable-wafcache || die_configure +./waf build install --destdir=pkgtemp/data/xash3d || die cp build/engine/xash.vpk pkgtemp/ echo "Building HLSDK..." diff --git a/scripts/gha/build_win32.sh b/scripts/gha/build_win32.sh index 6f0f3d23fd..bef94e6c18 100755 --- a/scripts/gha/build_win32.sh +++ b/scripts/gha/build_win32.sh @@ -12,8 +12,8 @@ fi # NOTE: to build with other version use --msvc_version during configuration # NOTE: sometimes you may need to add WinSDK to %PATH% # NOTE: --enable-msvcdeps only used for CI builds, enabling it non-English versions of MSVC causes useless console spam -./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps $AMD64 || die_configure -./waf.bat build || die +./waf.bat configure -s "SDL2_VC" -T release --enable-utils --enable-tests --enable-lto --enable-msvcdeps --enable-wafcache $AMD64 || die_configure +./waf.bat build --zones=wafcache || die ./waf.bat install --destdir=. || die if [ "$ARCH" = "i386" ]; then