From ee27935aabdda0cbb65627acac04261d796a2633 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 13 Aug 2025 12:07:36 +0200 Subject: [PATCH] add `vcpkg.json`, and modify `ci.yaml` to improve usage `vcpkg` Now we utilise storing dependencies in `vcpkg.json`, we can use this to more easily install the dependencies. Furthermore, we moved cloning vcpkg to `checkout`, which creates clones with `--depth=1` by default. --- .github/workflows/ci.yaml | 58 ++++++++++++++++++++------------------- .gitignore | 1 + vcpkg.json | 7 +++++ 3 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 vcpkg.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eadc88f..759fcbf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,6 @@ on: env: VCPKG_DISABLE_METRICS: 1 VCPKG_ROOT: ${{github.workspace}}/.vcpkg - DEPS_VCPKG: glfw3:x64-linux-dynamic glfw3:x64-mingw-static libarchive:x64-linux-dynamic libarchive:x64-mingw-static WINEPREFIX: /tmp/wineprefix jobs: # @@ -19,37 +18,40 @@ jobs: # exec-ci-tasks: runs-on: ubuntu-latest - container: ghcr.io/thepigeongenerator/mcaselector-lite:latest steps: - # # general setup - # - - uses: actions/checkout@v4 - # - # VCPKG setup - # - - id: gen-keys - run: echo "HASH_VCPKG=vcpkg-$(echo "$DEPS_VCPKG" | sha256sum | cut -d ' ' -f1)" >>"$GITHUB_OUTPUT" - # load the vcpkg cache + - name: checkout main branch + uses: actions/checkout@v4 + - name: checkout vcpkg + uses: actions/checkout@v4 + with: + repository: microsoft/vcpkg + path: ${{env.VCPKG_ROOT}} + - run: . "$VCPKG_ROOT/bootstrap-vcpkg.sh" + + - name: get library data + id: libdat + run: echo "LIBS_HASH=vcpkg_installed-$(cat vcpkg.json | sha256sum | cut -d ' ' -f1)" >>"$GITHUB_OUTPUT" + + # restore the cache - uses: actions/cache@v4 id: vcpkg-cache with: - path: ${{env.VCPKG_ROOT}} - key: ${{steps.gen-keys.outputs.HASH_VCPKG}} - restore-keys: vcpkg- + path: vcpkg_installed + key: ${{steps.libdat.outputs.LIBS_HASH}} + restore-keys: vcpkg_installed- + # setup vcpkg if the cache didn't hit - - if: steps.vcpkg-cache.outputs.cache-hit != 'true' + - name: install vcpkg dependencies + if: steps.vcpkg-cache.outputs.cache-hit != 'true' run: | - if [ -d "$VCPKG_ROOT" ]; then - cd "$VCPKG_ROOT" - git pull -f - cd - - else - git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT" - fi - "$VCPKG_ROOT/bootstrap-vcpkg.sh" - "$VCPKG_ROOT/vcpkg" install $DEPS_VCPKG - - name: compilation (using bulk compilation) - run: make all CALL=compile -j - - name: unit tests (using bulk flags) - run: make all CALL=run DEBUG=test -j + "$VCPKG_ROOT/vcpkg" install --triplet=x64-linux-dynamic + "$VCPKG_ROOT/vcpkg" install --triplet=x64-mingw-static + + # perform continuous integration actions + - run: make x86_64-linux-gnu-gcc CALL=compile -j + - run: make x86_64-w64-mingw32-gcc CALL=compile -j + - run: make x86_64-linux-gnu-gcc CALL=run DEBUG=test -j + - run: make x86_64-w64-mingw32-gcc CALL=run DEBUG=test -j + + diff --git a/.gitignore b/.gitignore index 6cd8d74..33b0377 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ /test/bin/ /test/obj/ *.lock +/vcpkg_installed/ compile_commands.json diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..813539d --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "dependencies": [ + "glfw3", + "libarchive" + ] +}