-
Notifications
You must be signed in to change notification settings - Fork 21
399 lines (395 loc) · 13.3 KB
/
build-natives.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# Modified from https://github.com/libgdx/libgdx/blob/master/.github/workflows/build-publish.yml
name: Build and Publish
on:
workflow_dispatch:
pull_request:
branches: [main]
push:
tags:
- '*'
paths-ignore:
- '.github/**'
- 'docs/**'
- 'README.md'
branches:
- main
env:
MACOSX_DEPLOYMENT_TARGET: "10.10"
jobs:
apple-natives:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- run: echo "JAVA_17=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build natives
run: |
./gradlew jniGen jnigenBuildMacOsX64 jnigenBuildMacOsXARM64 jnigenBuildIOS
- name: Test
run: |
./gradlew :example:test :jsr223:test :jpms-example:run
- name: Upload macOS natives
uses: actions/upload-artifact@v4
with:
name: apple-natives
path: ./*/libs
retention-days: 5
most-natives:
environment: Codecov
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- name: Download llvm-mingw
uses: robinraju/[email protected]
with:
repository: 'mstorsjo/llvm-mingw'
tag: 20240619
fileName: llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64.tar.xz
tarBall: false
zipBall: false
- name: Set up llvm-mingw
run: |
sudo mkdir -p /usr/local
sudo tar -Jxf llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64.tar.xz -C /usr/local
echo "PATH=/usr/local/llvm-mingw-20240619-ucrt-ubuntu-20.04-x86_64/bin:$PATH" >> $GITHUB_ENV
- name: Install cross-compilation toolchains
run: |
sudo apt update
# x86_64
sudo apt install -y --force-yes gcc g++
sudo apt install -y --force-yes libc6-dev linux-libc-dev linux-libc-dev-amd64-cross
# x86
sudo apt install -y --force-yes gcc-i686-linux-gnu g++-i686-linux-gnu
sudo apt install -y --force-yes lib32stdc++-9-dev libstdc++-9-dev-i386-cross
sudo apt install -y --force-yes libc6-dev-i386 libc6-dev-i386-cross linux-libc-dev-i386-cross
# arm64
sudo apt install -y --force-yes gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt install -y --force-yes libstdc++-9-dev-arm64-cross linux-libc-dev-arm64-cross
# armhf
sudo apt install -y --force-yes gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-dev-armhf-cross
sudo apt install -y --force-yes libstdc++-9-dev-armhf-cross linux-libc-dev-armhf-cross
# TODO: riscv64
# Windows
sudo apt install -y --force-yes mingw-w64 lib32z1
- name: Install PatchELF (verneed-fix)
run: |
git clone https://github.com/gudzpoz/patchelf.git
cd patchelf
git checkout 1684a4606be1fef189d04a465adc0c9d31421dac
./bootstrap.sh
./configure
make
make check
`pwd`/src/patchelf --version
echo "`pwd`/src" >> $GITHUB_PATH
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build natives
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
./gradlew jniGen jnigenBuildLinux jnigenBuildLinux64
./gradlew jniGen jnigenBuildLinuxARM jnigenBuildLinuxARM64
# TODO: ./gradlew jniGen jnigenBuildLinuxRISCV64
./gradlew jniGen jnigenBuildAndroid jnigenBuildWindows jnigenBuildWindows64 jnigenBuildWindowsARM64
- name: Test (Desktop)
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
./gradlew --info --stacktrace :example:test :jsr223:test :jpms-example:run
- name: Jacoco Test Report
run: |
export NDK_HOME=$ANDROID_NDK_LATEST_HOME
./gradlew jacocoTestReport
- name: Upload test result
uses: codecov/codecov-action@v4
with:
files: >-
./lua51/build/reports/jacoco/report.xml,
./lua52/build/reports/jacoco/report.xml,
./lua53/build/reports/jacoco/report.xml,
./lua54/build/reports/jacoco/report.xml,
./luajit/build/reports/jacoco/report.xml,
./luaj/build/reports/jacoco/report.xml,
./luajava/build/reports/jacoco/report.xml,
./jsr223/build/reports/jacoco/report.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload all output libs
uses: actions/upload-artifact@v4
with:
name: most-natives
path: ./*/libs
retention-days: 5
linux-testing:
runs-on: ubuntu-latest
needs:
- most-natives
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Download most-natives artifact
uses: actions/download-artifact@v4
with:
name: most-natives
- name: JniGen
run: |
./gradlew jniGen
- name: Build example
run: |
./gradlew :example:shadowJar
- name: Test on Ubuntu 14.04
run: |
sudo docker build -t ljtest-glibc -f example/docker/glibc/Dockerfile example/build/libs
sudo docker run --rm ljtest-glibc
- name: Test on Alpine
run: |
sudo docker build -t ljtest-musl -f example/docker/musl/Dockerfile example/build/libs
sudo docker run --rm ljtest-musl
windows-testing:
runs-on: windows-latest
needs:
- most-natives
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Download most-natives artifact
uses: actions/download-artifact@v4
with:
name: most-natives
- name: JniGen
run: |
./gradlew jniGen
- name: Test
run: |
./gradlew --info --stacktrace :example:test :jsr223:test :jpms-example:run
android-testing:
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [ 21 ]
android-arch: [ 'x86_64', 'x86' ]
include:
- api-level: 24
android-arch: 'x86'
- api-level: 33
android-arch: 'x86_64'
needs:
- most-natives
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Download most-natives artifact
uses: actions/download-artifact@v4
with:
name: most-natives
- name: JniGen
run: |
./gradlew jniGen
- name: Pack Android natives
run: |
./gradlew :android:assemble
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.android-arch }}
- name: Enable KVM for linux runners
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.android-arch }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Test on Android AVD
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.android-arch }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew --info --stacktrace :android:android-test:connectedAndroidTest
pack-natives:
environment: OSSRH
needs:
- apple-natives
- most-natives
- windows-testing
- android-testing
- linux-testing
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- run: echo "JAVA_8=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- run: echo "JAVA_11=$JAVA_HOME" >> $GITHUB_ENV
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Download apple-natives artifact
uses: actions/download-artifact@v4
with:
name: apple-natives
- name: Download most-natives artifact
uses: actions/download-artifact@v4
with:
name: most-natives
- name: JniGen
run: |
./gradlew jniGen
- name: Pack desktop natives
run: |
ant -f lua51/jni/build.xml pack-natives
ant -f lua52/jni/build.xml pack-natives
ant -f lua53/jni/build.xml pack-natives
ant -f lua54/jni/build.xml pack-natives
ant -f luajit/jni/build.xml pack-natives
- name: Pack Android AAR
run: |
./gradlew :android:assemble
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: natives
path: ./*/libs
- name: Release?
if: |
startsWith(github.ref, 'refs/tags/')
run: echo "IS_RELEASE=true" >> $GITHUB_ENV
- name: Publish
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GPG_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
GPG_SECKEY: ${{ secrets.SIGNING_SECRET_KEY }}
GITHUB_REF: ${{ github.ref }}
run: |
./gradlew build -x test
./gradlew publish -Dorg.gradle.parallel=false
- name: Build example
run: |
./gradlew :example:shadowJar
- name: Upload example
uses: actions/upload-artifact@v4
with:
name: example
path: example/build/libs/example-all.jar
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: example/build/libs/example-all.jar
mac-arm-test:
needs:
- pack-natives
runs-on: macos-14
steps:
- name: Download example tests
uses: actions/download-artifact@v4
with:
name: example
- name: Run example tests
run: |
java -jar example-all.jar --test
linux-arm-test:
environment: Bitrise
needs:
- pack-natives
runs-on: ubuntu-20.04
steps:
- name: Trigger CircleCI tests for Linux on arm64
env:
CIRCLECI_TOKEN: ${{ secrets.CIRCLECI_TOKEN }}
run: |
curl -X POST -H "Circle-Token: $CIRCLECI_TOKEN" https://circleci.com/api/v2/project/github/gudzpoz/luajava/pipeline