Build Native #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Native | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: '0 0 * * *' | |
env: | |
BUILD_TYPE: Release | |
jobs: | |
build: | |
name: ${{ matrix.platform.name }} | |
runs-on: ${{ matrix.platform.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- { name: win-x64, os: windows-latest, flags: -A x64 } | |
- { name: win-x86, os: windows-latest, flags: -A Win32 } | |
- { name: win-arm64, os: windows-latest, flags: -A ARM64 } | |
- { name: linux-x64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":amd64" } | |
- { name: linux-x86, os: ubuntu-20.04, flags: -GNinja -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32", target_apt_arch: ":i386" } | |
- { name: linux-arm64, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":arm64", container: arm64v8/ubuntu } | |
- { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu } | |
- { name: osx-x64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 } | |
# NOTE: macOS 11.0 is the first released supported by Apple Silicon. | |
- { name: osx-arm64, os: macos-latest, flags: -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up QEMU | |
if: contains(matrix.platform.container, 'arm') | |
uses: docker/setup-qemu-action@v3 | |
- name: Build (Linux ARM) | |
if: contains(matrix.platform.container, 'arm') | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: ${{ matrix.platform.container }} | |
options: > | |
-v ${{ github.workspace }}:/workspace | |
-e NAME=${{ matrix.platform.name }} | |
-e TARGET_APT_ARCH=${{ matrix.platform.target_apt_arch }} | |
-e RUNNER_OS=${{ runner.os }} | |
-e FLAGS=${{ matrix.platform.flags }} | |
-e BUILD_TYPE=${{ env.BUILD_TYPE }} | |
run: | | |
cd /workspace | |
./External/build.sh | |
- name: Build | |
if: ${{ !contains(matrix.platform.container, 'arm') }} | |
shell: bash | |
env: | |
NAME: ${{ matrix.platform.name }} | |
TARGET_APT_ARCH: ${{ matrix.platform.target_apt_arch }} | |
RUNNER_OS: ${{ runner.os }} | |
FLAGS: ${{ matrix.platform.flags }} | |
run: ./External/build.sh | |
- name: Get Actions user id | |
if: runner.os == 'Linux' | |
id: get_uid | |
run: echo "uid=$(id -u $USER)" >> $GITHUB_OUTPUT | |
- name: Correct Ownership in GITHUB_WORKSPACE directory | |
if: runner.os == 'Linux' | |
uses: peter-murray/reset-workspace-ownership-action@v1 | |
with: | |
user_id: ${{ steps.get_uid.outputs.uid }} | |
- name: Compress native directory | |
run: tar -cf native-${{ matrix.platform.name }}.tar native/${{ matrix.platform.name }} | |
- name: Upload native artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: native-${{ matrix.platform.name }} | |
path: native-${{ matrix.platform.name }}.tar | |
if-no-files-found: error | |
build-ios: | |
name: ios | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build (iOS) | |
run: xcodebuild -project External/SDL/Xcode/SDL/SDL.xcodeproj -target SDL3.xcframework -configuration Release | |
- name: Prepare release directory (iOS) | |
run: mkdir -p native/ios | |
- name: Prepare release (iOS) | |
run: | | |
mkdir -p native/ios/SDL3.xcframework/ios-arm64/SDL3.framework; | |
mkdir -p native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework; | |
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/Info.plist native/ios/SDL3.xcframework/Info.plist; | |
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3 native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/SDL3; | |
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist native/ios/SDL3.xcframework/ios-arm64/SDL3.framework/Info.plist; | |
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3 native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/SDL3; | |
cp External/SDL/Xcode/SDL/build/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist native/ios/SDL3.xcframework/ios-arm64_x86_64-simulator/SDL3.framework/Info.plist; | |
- name: Compress native directory | |
run: tar -cf native-ios.tar native/ios | |
- name: Upload native artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: native-ios | |
path: native-ios.tar | |
if-no-files-found: error | |
build-android: | |
name: android | |
runs-on: ubuntu-20.04 | |
env: | |
NDK_VER: 23.1.7779620 | |
PLATFORM_VER: android-34 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: microsoft | |
java-version: | | |
11 | |
17 | |
- name: Install Android SDK Manager | |
uses: android-actions/setup-android@v3 | |
with: | |
packages: '' | |
- name: Install Android SDK | |
run: | | |
sdkmanager --install "platform-tools" "platforms;$PLATFORM_VER" | |
sdkmanager --install "ndk;$NDK_VER" --channel=3 | |
- name: Build (Android) | |
run: | | |
export PATH=$ANDROID_HOME/ndk/$NDK_VER:$PATH | |
export OUTPUT=$PWD/native/android | |
rm -rf $OUTPUT && mkdir -p $OUTPUT | |
# Build SDL3 | |
sed -i 's/abi=.*/abi="armeabi-v7a arm64-v8a x86 x86_64"/g' ./External/SDL/build-scripts/androidbuildlibs.sh | |
./External/SDL/build-scripts/androidbuildlibs.sh NDK_LIBS_OUT="$OUTPUT" | |
- name: Build SDL3 Android Java | |
run: | | |
export JAVA_HOME=$JAVA_HOME_11_X64 | |
export PATH=$JAVA_HOME_11_X64/bin:$PATH | |
export OUTPUT=$PWD/SDL3-CS.Android/Jars/ | |
rm -rf $OUTPUT && mkdir -p $OUTPUT | |
# Build SDL3 Android Java part | |
cd ./External/SDL/android-project/app/src/main/java | |
javac -cp $ANDROID_HOME/platforms/$PLATFORM_VER/android.jar -encoding utf8 org/libsdl/app/*.java | |
jar cvf $OUTPUT/SDL3AndroidBridge.jar org/libsdl/app/*.class | |
- name: Compress native directory | |
run: tar -cf native-android.tar native/android | |
- name: Upload native artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: native-android | |
path: native-android.tar | |
if-no-files-found: error | |
- name: Upload JAR artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: android-jar | |
path: SDL3-CS.Android/Jars/SDL3AndroidBridge.jar | |
if-no-files-found: error | |
make-pr: | |
name: Submit pull request | |
runs-on: ubuntu-latest | |
needs: [ build, build-ios, build-android ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download native artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: native-* | |
merge-multiple: true | |
- name: Decompress native artifacts | |
run: | | |
for file in native-*.tar | |
do | |
tar -xf "$file" | |
done | |
rm native-*.tar | |
- name: Download JAR artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: android-jar | |
path: SDL3-CS.Android/Jars/ | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: Update native binaries | |
title: Update native binaries | |
body: This PR has been auto-generated to update the native SDL binaries | |
branch: update-native-binaries | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' |