Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
81 changes: 63 additions & 18 deletions .github/workflows/build-natives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Build native dependencies (SDL2)
# Change Chromium revision numbers based on https://chromium.woolyss.com/download/.
env:
SDL2_VERSION: 2.32.10 # Make sure this matches the version mentioned in the description in the .nuspec file.
CHROMIUM_BUILD_x86: 1136315
CHROMIUM_BUILD_x64: 1136314
CHROMIUM_BUILD_arm64: 1313033

on:
pull_request:
Expand All @@ -17,35 +17,80 @@ permissions:

jobs:
windows:
name: Windows (x86 + x64)
runs-on: ubuntu-22.04
name: Windows (x64)
runs-on: windows-2022
steps:
- name: Setup Dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts/x64 | Out-Null

- name: Build SDL2 (x64)
shell: pwsh
run: |
mkdir -p artifacts/x86
mkdir artifacts/x64
$sdlZip = "SDL2-${env:SDL2_VERSION}.zip"
$sdlUrl = "https://github.com/libsdl-org/SDL/releases/download/release-${env:SDL2_VERSION}/$sdlZip"

# Download an official precompiled release version of SDL because compiling for Windows on Linux is hard.
# Download also a precompiled version of Chromium in order to extract libEGL.dll and libGLESv2.dll, which the Windows SDL DLL depends on.
- name: Download Natives
Invoke-WebRequest -Uri $sdlUrl -OutFile $sdlZip
Expand-Archive -Path $sdlZip -DestinationPath .
$sdlRoot = "SDL2-${env:SDL2_VERSION}"

cmake -S $sdlRoot -B build-x64 -A x64 -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED=ON -DSDL_STATIC=OFF
cmake --build build-x64 --config Release
Copy-Item "build-x64/Release/SDL2.dll" "artifacts/x64/SDL2.dll" -Force

- name: Download ANGLE
shell: pwsh
run: |
curl -s -L -O https://www.libsdl.org/release/SDL2-${SDL2_VERSION}-win32-x86.zip
unzip SDL2-${SDL2_VERSION}-win32-x86.zip SDL2.dll -d artifacts/x86
curl -s -L -O https://storage.googleapis.com/chromium-browser-snapshots/Win/${CHROMIUM_BUILD_x86}/chrome-win.zip
unzip -j chrome-win.zip chrome-win/libEGL.dll -d artifacts/x86
unzip -j chrome-win.zip chrome-win/libGLESv2.dll -d artifacts/x86
curl -s -L -O https://www.libsdl.org/release/SDL2-${SDL2_VERSION}-win32-x64.zip
unzip SDL2-${SDL2_VERSION}-win32-x64.zip SDL2.dll -d artifacts/x64
curl -s -L -O https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/${CHROMIUM_BUILD_x64}/chrome-win.zip
unzip -j chrome-win.zip chrome-win/libEGL.dll -d artifacts/x64
unzip -j chrome-win.zip chrome-win/libGLESv2.dll -d artifacts/x64
Invoke-WebRequest -Uri "https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/${env:CHROMIUM_BUILD_x64}/chrome-win.zip" -OutFile "chrome-win-x64.zip"
Expand-Archive -Path "chrome-win-x64.zip" -DestinationPath "chrome-win-x64"
Copy-Item "chrome-win-x64/chrome-win/libEGL.dll" "artifacts/x64/libEGL.dll" -Force
Copy-Item "chrome-win-x64/chrome-win/libGLESv2.dll" "artifacts/x64/libGLESv2.dll" -Force

- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Windows
path: ./artifacts

windows-arm64:
name: Windows (arm64)
runs-on: windows-11-arm
steps:
- name: Setup Dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts/arm64 | Out-Null

- name: Build SDL2 (arm64)
shell: pwsh
run: |
$sdlZip = "SDL2-${env:SDL2_VERSION}.zip"
$sdlUrl = "https://github.com/libsdl-org/SDL/releases/download/release-${env:SDL2_VERSION}/$sdlZip"

Invoke-WebRequest -Uri $sdlUrl -OutFile $sdlZip
Expand-Archive -Path $sdlZip -DestinationPath .
$sdlRoot = "SDL2-${env:SDL2_VERSION}"

cmake -S $sdlRoot -B build-arm64 -A ARM64 -DCMAKE_BUILD_TYPE=Release -DSDL_SHARED=ON -DSDL_STATIC=OFF
cmake --build build-arm64 --config Release

Copy-Item "build-arm64/Release/SDL2.dll" "artifacts/arm64/SDL2.dll" -Force

- name: Download ANGLE
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://storage.googleapis.com/chromium-browser-snapshots/Win_Arm64/${env:CHROMIUM_BUILD_arm64}/chrome-win.zip" -OutFile "chrome-win-arm64.zip"
Expand-Archive -Path "chrome-win-arm64.zip" -DestinationPath "chrome-win-arm64"
Copy-Item "chrome-win-arm64/chrome-win/libEGL.dll" "artifacts/arm64/libEGL.dll" -Force
Copy-Item "chrome-win-arm64/chrome-win/libGLESv2.dll" "artifacts/arm64/libGLESv2.dll" -Force

- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Windows(arm64)
path: ./artifacts

macos:
name: macOS (x64 + arm64)
runs-on: macos-14
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
name: Natives-Windows
path: ./native/win

- name: Download artifacts - native - Windows
uses: actions/download-artifact@v8
with:
name: Natives-Windows(arm64)
path: ./native/win

- name: Download artifacts - native - MacOS
uses: actions/download-artifact@v8
with:
Expand Down
2 changes: 1 addition & 1 deletion OpenRA-SDL2-CS.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<files>
<file src="OpenRA-SDL2-CS.targets" target="build" />
<file src="bin/netstandard2.0/SDL2-CS.*" target="lib/netstandard2.0" />
<file src="native/win/x86/*.dll" target="native/win-x86" />
<file src="native/win/x64/*.dll" target="native/win-x64" />
<file src="native/win/arm64/*.dll" target="native/win-arm64" />
<file src="native/linux/x64/SDL2.so" target="native/linux-x64" />
<file src="native/linux/arm64/SDL2.so" target="native/linux-arm64" />
<file src="native/osx/x86_64/SDL2.dylib" target="native/osx-x64" />
Expand Down
20 changes: 10 additions & 10 deletions OpenRA-SDL2-CS.targets
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x86\libEGL.dll" Condition="'$(TargetPlatform)' == 'win-x86'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\SDL2.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libEGL.dll</Link>
<Link>SDL2.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x86\libGLESv2.dll" Condition="'$(TargetPlatform)' == 'win-x86'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\libEGL.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libGLESv2.dll</Link>
<Link>libEGL.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x86\SDL2.dll" Condition="'$(TargetPlatform)' == 'win-x86'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\libGLESv2.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SDL2.dll</Link>
<Link>libGLESv2.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\SDL2.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-arm64\SDL2.dll" Condition="'$(TargetPlatform)' == 'win-arm64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SDL2.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\libEGL.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-arm64\libEGL.dll" Condition="'$(TargetPlatform)' == 'win-arm64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libEGL.dll</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-x64\libGLESv2.dll" Condition="'$(TargetPlatform)' == 'win-x64'">
<Content Include="$(MSBuildThisFileDirectory)\..\native\win-arm64\libGLESv2.dll" Condition="'$(TargetPlatform)' == 'win-arm64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libGLESv2.dll</Link>
<Visible>false</Visible>
Expand All @@ -51,7 +51,7 @@
<Link>SDL2.dylib</Link>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\lib\netstandard2.0\SDL2-CS.dll.config" Condition="'$(TargetPlatform)' != 'win-x64' And '$(TargetPlatform)' != 'win-x86'">
<Content Include="$(MSBuildThisFileDirectory)\..\lib\netstandard2.0\SDL2-CS.dll.config" Condition="'$(TargetPlatform)' != 'win-x64' And '$(TargetPlatform)' != 'win-arm64'">
Comment thread
Mailaender marked this conversation as resolved.
Outdated
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SDL2-CS.dll.config</Link>
<Visible>false</Visible>
Expand Down