Skip to content

build - windows msvc #2

build - windows msvc

build - windows msvc #2

name: build - windows msvc
on:
workflow_dispatch:
workflow_call:
jobs:
windows-msvc:
# inspired by https://github.com/lukka/CppCMakeVcpkgTemplate/blob/main/.github/workflows/hosted-pure-workflow.yml
strategy:
matrix:
config: [Debug, Release]
arch: [x64, x86]
name: Windows ${{ matrix.config }} ${{ matrix.arch }} Build (MSVC)
runs-on: windows-2022
env:
VCPKG_ROOT: C:\vcpkg
VCPKG_TARGET_TRIPLET: ${{ matrix.arch }}-windows-static
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Checkout vcpkg
id: prepare
run: |
REF=${{ vars.VCPKG_REF }}
cd ${{ env.VCPKG_ROOT }}
# REF can be empty, a commit hash or a pull request
echo "Checking out '$REF'"
[ -n "$REF" ] && git fetch
git checkout $REF || git pull origin $REF
echo "vcpkg_key=${{ hashFiles( './install-dependencies.sh' ) }}-${REF}" >> $GITHUB_OUTPUT
shell: bash
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v4
with:
# Explicit path here because env is overridden by msvc-dev-cmd
path: C:\vcpkg\installed
key: |
${{ steps.prepare.outputs.vcpkg_key }}-${{ matrix.arch }}
- name: Installing dependencies
run: |
choco install innosetup
# Cache should have been populated by vcpkg-packages job
./install-dependencies.sh vcpkg --triplet=${{ env.VCPKG_TARGET_TRIPLET }}
shell: bash
- name: Configure MSVC development console
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Compiler
env:
VCPKG_ROOT: C:\vcpkg
run: |
mkdir $env:GITHUB_WORKSPACE\build
cd $env:GITHUB_WORKSPACE\build
cmake.exe -G "NMake Makefiles" .. -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_BUILD_TESTS=ON -DOPTION_ASAN=OFF -DOPTION_BUILD_CODECHECK=OFF -DOPTION_BUILD_WINSTATIC=ON -DOPTION_USE_GLBINDING=ON -DOPTION_FORCE_EMBEDDED_MINIZIP=ON
if ((Select-String -Quiet REVDETECT-BROKEN VERSION)) { exit 1 }
nmake
if ("${{ matrix.config }}" -Match "Release") {
strip -sv ./src/widelands.exe
}
- name: InnoSetup
run: |
cd $env:GITHUB_WORKSPACE
# Environment variables needed by our InnoSetup script
$env:PLATFORM = "${{ matrix.arch }}"
$env:CONFIGURATION = "${{ matrix.config }}"
$env:APPVEYOR_BUILD_FOLDER = $env:GITHUB_WORKSPACE
$env:APPVEYOR_BUILD_VERSION = "Widelands-${{ github.sha }}-${{ matrix.config }}-${{ matrix.arch }}"
ISCC.exe /o$env:GITHUB_WORKSPACE /fWidelands-${{ github.sha }}-msvc-${{ matrix.config }}-${{ matrix.arch }} $env:GITHUB_WORKSPACE\utils\windows\innosetup\Widelands.iss
- name: Uploading installer
uses: actions/upload-artifact@v4
with:
name: Widelands ${{ matrix.config }} ${{ matrix.arch }} Installer (MSVC)
path: ${{ github.workspace }}\Widelands-${{ github.sha }}-msvc-${{ matrix.config }}-${{ matrix.arch }}.exe