-
Notifications
You must be signed in to change notification settings - Fork 16
221 lines (191 loc) · 8.03 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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, docker_platform: linux/arm64/v8 }
- { name: linux-arm, os: ubuntu-20.04, flags: -GNinja, target_apt_arch: ":armhf", container: arm32v7/ubuntu, docker_platform: linux/arm/v7 }
- { 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 }}
--platform ${{ matrix.platform.docker_platform }}
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'