Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,140 @@ jobs:
with:
name: butterscotch-windows-${{ matrix.arch }}
path: build/butterscotch.exe


build-x64-gdk:
name: Build (x64 GDK)
runs-on: windows-2025

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Cache GDK
id: cache-gdk
uses: actions/cache@v4
with:
path: ${{ runner.temp }}\gdk-cache
key: gdk-${{ runner.os }}-x64

- name: Install or restore GDK
shell: pwsh
run: |
$cacheRoot = Join-Path '${{ runner.temp }}' 'gdk-cache'
$installRoots = @(
"${env:ProgramFiles}\Microsoft GDK",
"${env:ProgramFiles(x86)}\Microsoft GDK"
)

$gdkRoot = $installRoots |
Where-Object { $_ -and (Test-Path $_) } |
Select-Object -First 1

if ("${{ steps.cache-gdk.outputs.cache-hit }}" -eq "true") {
$cached = @(
(Join-Path $cacheRoot 'Microsoft GDK'),
(Join-Path $cacheRoot 'MicrosoftGDK'),
$cacheRoot
) |
Where-Object { $_ -and (Test-Path $_) } |
Select-Object -First 1

if (-not $cached) {
throw "Cached GDK directory was not found in $cacheRoot."
}

if (-not $gdkRoot) {
$gdkRoot = "${env:ProgramFiles}\Microsoft GDK"
}

if (Test-Path $gdkRoot) {
Remove-Item $gdkRoot -Recurse -Force
}

Copy-Item $cached $gdkRoot -Recurse -Force
}
else {
winget install Microsoft.Gaming.GDK `
--accept-package-agreements `
--accept-source-agreements `
--silent

$gdkRoot = $installRoots |
Where-Object { $_ -and (Test-Path $_) } |
Select-Object -First 1

if (-not $gdkRoot) {
throw "Microsoft GDK was not found under Program Files after installation."
}

New-Item -ItemType Directory -Force -Path $cacheRoot | Out-Null
Copy-Item $gdkRoot (Join-Path $cacheRoot 'Microsoft GDK') -Recurse -Force
}

if (-not $gdkRoot) {
throw "Microsoft GDK was not found under Program Files after restore."
}

"GDK=$gdkRoot" | Out-File -FilePath $env:GITHUB_ENV -Append
"GDKX=$gdkRoot" | Out-File -FilePath $env:GITHUB_ENV -Append

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v5

- name: Cache SDL2 build
id: cache-sdl2
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/vendor/SDL2/install
key: sdl2-gdk-${{ runner.os }}-2.32.10-rev2

- name: Checkout SDL2
if: steps.cache-sdl2.outputs.cache-hit != 'true'
uses: actions/checkout@v7
with:
repository: libsdl-org/SDL
ref: release-2.32.10
path: vendor/SDL2

- name: Build SDL2 from source
if: steps.cache-sdl2.outputs.cache-hit != 'true'
shell: pwsh
run: |
$workspace = $env:GITHUB_WORKSPACE
$gdkScript = Join-Path $workspace 'scripts\invoke-gdk.ps1'
$sdlSrc = Join-Path $workspace 'vendor\SDL2'
$sdlBuild = Join-Path $sdlSrc 'build'
$sdlInstall = Join-Path $workspace 'vendor\SDL2\install'
$cmakeCommand = "cmake -S `"$sdlSrc`" -B `"$sdlBuild`" -G `"Visual Studio 18 2026`" -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`"$sdlInstall`" -DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TESTS=OFF -DSDL_GDK=ON"
& $gdkScript $cmakeCommand
& $gdkScript "cmake --build `"$sdlBuild`" --config Release"
& $gdkScript "cmake --install `"$sdlBuild`""

- name: Configure Butterscotch
shell: pwsh
run: |
if (Test-Path "$env:GITHUB_WORKSPACE/build") {
Remove-Item "$env:GITHUB_WORKSPACE/build" -Recurse -Force
}

$workspace = $env:GITHUB_WORKSPACE
$gdkScript = Join-Path $workspace 'scripts\invoke-gdk.ps1'
$buildDir = Join-Path $workspace 'build'
$sdlDir = Join-Path $workspace 'vendor\SDL2\install'
$cmakeCommand = "cmake -S `"$workspace`" -B `"$buildDir`" -G `"Visual Studio 18 2026`" -A x64 -DBACKEND=sdl2 -DIS_GDK=ON -DSDL2_DIR=`"$sdlDir`" -DCMAKE_PREFIX_PATH=`"$sdlDir`" -DCMAKE_BUILD_TYPE=Release -DWERROR=ON"
& $gdkScript $cmakeCommand

- name: Build Butterscotch
shell: pwsh
run: |
$workspace = $env:GITHUB_WORKSPACE
$gdkScript = Join-Path $workspace 'scripts\invoke-gdk.ps1'
$buildDir = Join-Path $workspace 'build'
& $gdkScript "cmake --build `"$buildDir`" --config Release"

- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: butterscotch-gdk
path: build/**/*
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:

Other:
uses: ./.github/workflows/build-other.yml

Compilers:
uses: ./.github/workflows/build-old-compilers.yml
Loading
Loading