From d277c80fd03f263d4c3ed19b9e2ebb86ea377cd1 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 4 Sep 2024 20:26:47 +0100 Subject: [PATCH] Simplify `vcpkg` caching and use system `vcpkg` (#7473) * Fixed OpenSSL exe dir to use tools dir * Simplify vcpkg caching and use system vcpkg * Only use ref for version when ref is a tag * Add condition for event input * Add restore keys for vcpkg cache * Improve step name for vcpkg_installed * Use `windows-2022` runner * Update ChangeLog * Revert "Use `windows-2022` runner" This reverts commit f9e00cbcb3588e58914d2b9e73b3c5734a12d329. --- .github/actions/get-version/action.yml | 7 +++++-- .github/workflows/ci.yml | 12 +++--------- ChangeLog | 1 + cmake/Libraries.cmake | 5 +---- scripts/lib/vcpkg.py | 7 ++++--- test | 1 - 6 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 test diff --git a/.github/actions/get-version/action.yml b/.github/actions/get-version/action.yml index c5412238f..95f7c05bf 100644 --- a/.github/actions/get-version/action.yml +++ b/.github/actions/get-version/action.yml @@ -6,7 +6,10 @@ runs: steps: - run: | - if [[ "${{ github.ref_name }}" != "master" ]]; then - echo "SYNERGY_VERSION=${{ github.event.inputs.version || github.ref_name }}" >> $GITHUB_ENV + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + echo "SYNERGY_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + fi + if [[ "${{ github.event.inputs.version }}" != "" ]]; then + echo "SYNERGY_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV fi shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6593c3ed6..144cc8960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,13 +65,12 @@ jobs: - name: Get version uses: ./.github/actions/get-version - - name: Cache vcpkg dirs + - name: Cache vcpkg dir uses: actions/cache@v4 with: - path: | - vcpkg - vcpkg_installed + path: vcpkg_installed key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }} + restore-keys: vcpkg-${{ runner.os }} - name: Cache Python env uses: actions/cache@v4 @@ -99,11 +98,6 @@ jobs: - name: Install dependencies run: python ./scripts/install_deps.py - # The vcpkg downloads dir can be quite large (over 2GB) which bloats the cache. - # For the most part, we don't need it so it probably safe to discard it. - - name: Cleanup vcpkg downloads - run: Remove-Item -Path vcpkg/downloads -Recurse -Force - - name: Configure run: cmake -B build --preset=windows-release diff --git a/ChangeLog b/ChangeLog index 3154bd7bc..ba0faefba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ Enhancements: - #7467 Load server or client args from `synergy-config.toml` - #7469 Option to link against local `libportal` and other subprojects - #7471 Use `vcpkg` to manage `openssl` dep instead of `choco` +- #7473 Simplify `vcpkg` caching and use system `vcpkg` # 1.15.1 diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index a4e8b5757..d0b34743a 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -438,11 +438,8 @@ macro(configure_windows_libs) endmacro() macro(configure_windows_openssl) - # Strangely, vcpkg doesn't seem to put openssl.exe in the `vcpkg_installed` dir, - # so we have to fish it out of the `vcpkg/buildtrees` dir. - set(OPENSSL_EXE_DIR - ${CMAKE_SOURCE_DIR}/vcpkg/buildtrees/openssl/x64-windows-rel/apps) set(OPENSSL_ROOT_DIR ${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows) + set(OPENSSL_EXE_DIR ${OPENSSL_ROOT_DIR}/tools/openssl) if(EXISTS ${OPENSSL_EXE_DIR}) message(STATUS "OpenSSL exe dir: ${OPENSSL_EXE_DIR}") diff --git a/scripts/lib/vcpkg.py b/scripts/lib/vcpkg.py index c6efc08f0..ed30fc27b 100644 --- a/scripts/lib/vcpkg.py +++ b/scripts/lib/vcpkg.py @@ -27,10 +27,11 @@ def install(): cmd_utils.run([vcpkg_bin, "install"], print_cmd=True) -# Install a local vcpkg even if it's already installed system-wide, so that we can cache the -# vcpkg dirs in the CI env. We also depend on the local `vcpkg/buildtrees` dir when bundling -# the `openssl.exe` binary on Windows (that said, we could also use cmake to search for it). def ensure_vcpkg(): + if cmd_utils.has_command("vcpkg"): + print("Using system vcpkg") + return "vcpkg" + if not os.path.exists("vcpkg"): get_vcpkg() else: diff --git a/test b/test deleted file mode 100644 index 30d74d258..000000000 --- a/test +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file