From 872720740aaccebf01a8452d23cc606566341204 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 30 Jul 2023 20:47:59 -0700 Subject: [PATCH] attempt to get windows build reusable --- .github/workflows/build-linux.yml | 3 +- .github/workflows/build-windows.yml | 65 +++++++++++++++++++++++++++++ .github/workflows/build.yml | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-windows.yml diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 034cfc989..4e070e9f0 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -71,6 +71,7 @@ jobs: env: CC: gcc-${{ inputs.gcc-ver }} CXX: g++-${{ inputs.gcc-ver }} + CCACHE_DIR: ${{ env.HOME }}/.ccache run: | cmake \ -S . \ @@ -82,7 +83,7 @@ jobs: ${{ inputs.platform-files && '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache' || '' }} \ -DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} \ -DBUILD_PLUGINS:BOOL=${{ inputs.platform-files }} \ - -DBUILD_STONESENSE:BOOL=${{ inputs.platform-files }} \ + -DBUILD_STONESENSE:BOOL=${{ inputs.stonesense }} \ -DBUILD_DEV_PLUGINS:BOOL=${{ inputs.extras }} \ -DBUILD_SIZECHECK:BOOL=${{ inputs.extras }} \ -DBUILD_SKELETON:BOOL=${{ inputs.extras }} \ diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 000000000..d6a5371b0 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,65 @@ +name: build-windows + +on: + workflow_call: + inputs: + artifact-name: + type: string + append-date-and-hash: + type: boolean + default: false + cache-id: + type: string + default: '' + platform-files: + type: boolean + default: true + common-files: + type: boolean + default: true + +jobs: + build-win64: + name: Build win64 + runs-on: windows-latest + steps: + - run: pip install clcache + if: inputs.platform-files + - run: pip install 'sphinx<4.4.0' + if: inputs.common-files + - name: Clone DFHack + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: ${{ !inputs.platform-files && 1 || 0 }} + - name: Fetch clcache + if: inputs.platform-files + uses: actions/cache@v3 + with: + path: ${{ env.HOME }}/clcache + key: win-msvc-${{ inputs.cache-id }}-${{ github.sha }} + restore-keys: | + win-msvc-${{ inputs.cache-id }} + win-msvc + - name: Configure DFHack + env: + CLCACHE_DIR: ${{ env.HOME }}/clcache + run: cmake -S . -B build -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=build/image ${{ inputs.platform-files && '-DCMAKE_C_COMPILER_LAUNCHER=clcache' || '' }} ${{ inputs.platform-files && '-DCMAKE_CXX_COMPILER_LAUNCHER=clcache' || '' }} -DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} -DBUILD_PLUGINS:BOOL=${{ inputs.platform-files }} -DBUILD_STONESENSE:BOOL=${{ inputs.platform-files }} -DBUILD_DOCS:BOOL=${{ inputs.common-files }} -DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} -DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }} + - name: Build DFHack + run: cmake --build build -j 2 --config Release --target install + - name: Trim cache + if: inputs.platform-files + run: | + clcache -M 52428800 + clcache -c + clcache -s + - name: Format artifact name + if: inputs.append-date-and-hash + id: artifactname + run: echo "name=${{ inputs.artifact-name }}-$(date +%Y%m%d)-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + - name: Upload artifact + if: inputs.artifact-name + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.append-date-and-hash && steps.artifactname.outputs.name || inputs.artifact-name }} + path: build/image/* diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2567132a..1c9f4b13f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build-linux: - name: Build (Linux ${{ matrix.type }}, GCC ${{ matrix.gcc }}) + name: Linux ${{ matrix.type }}, GCC ${{ matrix.gcc }} uses: ./.github/workflows/build-linux.yml with: artifact-name: ${{ matrix.artifact-name || format('{0}-gcc-{1}', matrix.type, matrix.gcc) }}