From 367d05b302b2261cff89e98c2f6b39a2144dfc69 Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Sat, 16 Aug 2025 06:32:01 +0200 Subject: [PATCH] ci: vcpkg improvements * Upgrade to 2025.07.25 * Configure vcpkg settings in vcpkg.json, this avoids needing to duplicate the vcpkg hash used in several places, and also avoids needing to set overlay ports/triplets directories from CMake * Add caching workaround so that builds won't take forever every time * Build on windows-2025 --- .github/workflows/build-macos.yml | 18 ++++++++++++++++-- .github/workflows/build-windows.yml | 18 +++++++++++++++--- cmake/ConfigureVcpkg.cmake | 5 +---- vcpkg.json | 10 ++++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index cf9c7f45c..7d5e94a4c 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -10,7 +10,6 @@ on: - master env: - VCPKG_COMMIT: 2ad004460f5db4d3b66f62f5799ff66c265c4b5d MELONDS_GIT_BRANCH: ${{ github.ref }} MELONDS_GIT_HASH: ${{ github.sha }} MELONDS_BUILD_PROVIDER: GitHub Actions @@ -24,6 +23,10 @@ jobs: name: ${{ matrix.arch }} runs-on: macos-14 + + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite + steps: - name: Check out sources uses: actions/checkout@v3 @@ -32,10 +35,16 @@ jobs: brew install autoconf automake autoconf-archive libtool python-setuptools - name: Set up CMake uses: lukka/get-cmake@latest + - name: Restore vcpkg cache + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-${{ matrix.arch }}-osx-${{ hashFiles('vcpkg.json') }} + restore-keys: vcpkg-${{ matrix.arch }}-osx- - name: Set up vcpkg uses: lukka/run-vcpkg@v11 with: - vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }} + vcpkgJsonGlob: vcpkg.json - name: Build uses: lukka/run-cmake@v10 with: @@ -53,6 +62,11 @@ jobs: name: macOS-${{ matrix.arch }} path: macOS-${{ matrix.arch }}.zip retention-days: 1 + - name: Save vcpkg cache + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-${{ matrix.arch }}-osx-${{ hashFiles('vcpkg.json') }} universal-binary: name: Universal binary diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index f582c3799..c8597619e 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -10,7 +10,6 @@ on: - master env: - VCPKG_COMMIT: 2ad004460f5db4d3b66f62f5799ff66c265c4b5d MELONDS_GIT_BRANCH: ${{ github.ref }} MELONDS_GIT_HASH: ${{ github.sha }} MELONDS_BUILD_PROVIDER: GitHub Actions @@ -18,10 +17,12 @@ env: jobs: build: - runs-on: windows-latest + runs-on: windows-2025 defaults: run: shell: msys2 {0} + env: + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite steps: - name: Check out sources uses: actions/checkout@v3 @@ -31,10 +32,16 @@ jobs: msystem: ucrt64 update: true pacboy: gcc:p cmake:p ninja:p make:p + - name: Restore vcpkg cache + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-x86_64-mingw-${{ hashFiles('vcpkg.json') }} + restore-keys: vcpkg-x86_64-mingw- - name: Set up vcpkg uses: lukka/run-vcpkg@v11 with: - vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }} + vcpkgJsonGlob: vcpkg.json - name: Configure run: cmake --preset=release-mingw-x86_64 -DMELONDS_EMBED_BUILD_INFO=ON - name: Build @@ -43,3 +50,8 @@ jobs: with: name: melonDS-windows-x86_64 path: .\build\release-mingw-x86_64\melonDS.exe + - name: Save vcpkg cache + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/vcpkg_cache + key: vcpkg-x86_64-mingw-${{ hashFiles('vcpkg.json') }} diff --git a/cmake/ConfigureVcpkg.cmake b/cmake/ConfigureVcpkg.cmake index 2f8e9ad30..854f0e065 100644 --- a/cmake/ConfigureVcpkg.cmake +++ b/cmake/ConfigureVcpkg.cmake @@ -9,15 +9,12 @@ if (VCPKG_ROOT STREQUAL "${_DEFAULT_VCPKG_ROOT}") endif() FetchContent_Declare(vcpkg GIT_REPOSITORY "https://github.com/Microsoft/vcpkg.git" - GIT_TAG 2ad004460f5db4d3b66f62f5799ff66c265c4b5d + GIT_TAG HEAD EXCLUDE_FROM_ALL SOURCE_DIR "${CMAKE_SOURCE_DIR}/vcpkg") FetchContent_MakeAvailable(vcpkg) endif() -set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/cmake/overlay-triplets") -set(VCPKG_OVERLAY_PORTS "${CMAKE_SOURCE_DIR}/cmake/overlay-ports/faad2") - option(USE_RECOMMENDED_TRIPLETS "Use the recommended triplets that are used for official builds" ON) # Duplicated here because it needs to be set before project() diff --git a/vcpkg.json b/vcpkg.json index 68968b470..09447c4ce 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,4 +1,14 @@ { + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "dd3097e305afa53f7b4312371f62058d2e665320", + "reference": "dd3097e305afa53f7b4312371f62058d2e665320" + }, + "overlay-ports": [ "./cmake/overlay-ports" ], + "overlay-triplets": [ "./cmake/overlay-triplets" ] + }, "default-features": ["qt6"], "dependencies": [ "sdl2",