-
Notifications
You must be signed in to change notification settings - Fork 54
258 lines (237 loc) · 10.9 KB
/
Copy pathnative-quickjs.yml
File metadata and controls
258 lines (237 loc) · 10.9 KB
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
# Builds the twelve native `quickjs` artifacts com.reactunity.quickjs P/Invokes into.
#
# Why this exists: the binaries in unity/quickjs/Plugins/QuickJS were unity-jsb
# prebuilts and this repo had no way to reproduce any of them. See
# unity/quickjs/MIGRATION.md, "Gate 0".
#
# It deliberately does NOT commit what it builds. Every artifact is uploaded and
# installing them is a separate, manual step -- the same shape as release-upm.yml,
# and for the same reason: these are tracked binaries in a Unity package, and a
# half-updated set is worse than a stale one. Nothing here needs Unity.
#
# One CMakeLists drives all of it (native/quickjs/CMakeLists.txt); the per-target
# differences are the toolchain arguments below, which is why there is no build
# script per platform. The Android and iOS invocations follow quickjs-ng's own CI.
name: native-quickjs
on:
workflow_dispatch:
inputs:
build-type:
description: CMake build type
type: choice
default: Release
options: [Release, Debug]
pull_request:
paths: ['native/quickjs/**', 'native/exports.py', '.github/workflows/native-quickjs.yml']
push:
branches: [main]
paths: ['native/quickjs/**', 'native/exports.py']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_TYPE: ${{ inputs.build-type || 'Release' }}
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# Empty for every leg but linux-x64, which runs the job inside the image named there.
container: ${{ matrix.container || '' }}
strategy:
fail-fast: false
matrix:
include:
# ---- desktop. `native` means the runner can execute what it built,
# which is what lets shim-test run rather than only link.
- name: windows-x64
os: windows-latest
artifact: x64/quickjs.dll
built: build/${{ github.event.inputs.build-type || 'Release' }}/quickjs.dll
configure: -A x64
native: true
- name: windows-x86
os: windows-latest
artifact: x86/quickjs.dll
built: build/${{ github.event.inputs.build-type || 'Release' }}/quickjs.dll
configure: -A Win32
- name: linux-x64
os: ubuntu-latest
# Built in an old container on purpose: glibc is backward compatible, never
# forward, so the floor a binary records is the oldest system it will load on.
# ubuntu-latest is 24.04 (2.39) and the Unity test container is older, so a
# runner-native build produced a .so Unity could not load at all --
# DllNotFoundException, which reads like a missing file rather than a too-new
# one. 22.04 gives 2.35. The binary this replaces asked for 2.17, so this is a
# narrower reach than users had; an older base is the fix if that matters.
container: ubuntu:22.04
artifact: x64/libquickjs.so
built: build/libquickjs.so
configure: -DCMAKE_BUILD_TYPE=${{ github.event.inputs.build-type || 'Release' }}
native: true
- name: macos-universal
os: macos-latest
artifact: quickjs.bundle/Contents/MacOS/quickjs
built: build/quickjs.bundle/Contents/MacOS/quickjs
# One bundle for both Macs; Unity ships OSXUniversal, not per-arch.
configure: >-
-DCMAKE_BUILD_TYPE=${{ github.event.inputs.build-type || 'Release' }}
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"
native: true
# ---- WSA. UWP compiles with /sdl, which promotes two warnings quickjs.c
# trips deliberately; the CMakeLists suppresses them. The static-library
# probe is needed because CMake's default try-compile builds and signs an
# appx, which fails on ARM64.
# WSA ARM (32-bit) is absent on purpose: the Windows SDK dropped 32-bit ARM
# (MSB8087 from 10.0.26100 on) and Unity no longer targets it.
- name: wsa-x64
os: windows-latest
artifact: WSA/x64/quickjs.dll
built: build/${{ github.event.inputs.build-type || 'Release' }}/quickjs.dll
configure: >-
-A x64
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
- name: wsa-x86
os: windows-latest
artifact: WSA/x86/quickjs.dll
built: build/${{ github.event.inputs.build-type || 'Release' }}/quickjs.dll
configure: >-
-A Win32
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
- name: wsa-arm64
os: windows-latest
artifact: WSA/ARM64/quickjs.dll
built: build/${{ github.event.inputs.build-type || 'Release' }}/quickjs.dll
configure: >-
-A ARM64
-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
# ---- Android. android-24 matches Unity 6's minimum API level.
# armeabi-v7a and x86_64 are Unity 6's other two ABIs; 32-bit x86 is not
# one of them, which is why the shipped set's `x86` is not rebuilt here.
- name: android-arm64-v8a
os: ubuntu-latest
artifact: Android/libs/arm64-v8a/libquickjs.so
built: build/libquickjs.so
android-abi: arm64-v8a
- name: android-armeabi-v7a
os: ubuntu-latest
artifact: Android/libs/armeabi-v7a/libquickjs.so
built: build/libquickjs.so
android-abi: armeabi-v7a
- name: android-x86_64
os: ubuntu-latest
artifact: Android/libs/x86_64/libquickjs.so
built: build/libquickjs.so
android-abi: x86_64
# ---- iOS. A static archive, per the IOS branch in the CMakeLists:
# Unity links it into the generated Xcode project.
- name: ios-arm64
os: macos-latest
artifact: iOS/libquickjs.a
built: build/${{ github.event.inputs.build-type || 'Release' }}-iphoneos/libquickjs.a
configure: >-
-G Xcode -DCMAKE_SYSTEM_NAME=iOS
-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
-DCMAKE_OSX_ARCHITECTURES=arm64
steps:
# A bare distro image has none of this. GitHub mounts its own node in, so the
# actions themselves run, but git and a toolchain are ours -- and this has to
# precede checkout, which shells out to git.
- name: Container prerequisites
if: matrix.container
run: |
apt-get update
# python-is-python3 because the shared check step calls `python`, which a
# bare 22.04 does not provide even with python3 installed.
apt-get install -y --no-install-recommends git cmake build-essential ca-certificates python3 python-is-python3
- uses: actions/checkout@v7
- name: Configure
working-directory: native/quickjs
shell: bash
run: |
if [ -n "${{ matrix.android-abi }}" ]; then
cmake -B build \
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI=${{ matrix.android-abi }} \
-DANDROID_PLATFORM=android-24 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
else
cmake -B build ${{ matrix.configure }}
fi
# Always name the target: quickjs-ng registers run-test262, api-test and
# friends unconditionally, and a default build compiles all of them.
- name: Build
working-directory: native/quickjs
run: cmake --build build --config ${{ env.BUILD_TYPE }} --target quickjs
- name: Build and run shim-test
if: matrix.native
working-directory: native/quickjs
shell: bash
run: |
cmake --build build --config "$BUILD_TYPE" --target shim-test
# Multi-config generators put it in a per-config directory, single-config not.
for candidate in "build/$BUILD_TYPE/shim-test.exe" "build/$BUILD_TYPE/shim-test" "build/shim-test"; do
if [ -x "$candidate" ]; then "$candidate"; exit $?; fi
done
echo "shim-test binary not found" && exit 1
# Reads PE, ELF, Mach-O and archives, and takes the wanted set from the
# committed pinvoke-native.txt -- the .csproj it is otherwise derived from are
# generated by Unity and gitignored, so no job here could produce them.
- name: Check exports
working-directory: native/quickjs
shell: bash
run: |
# ubuntu images ship python3 without a `python` alias
PY=python3; command -v python3 >/dev/null || PY=python
"$PY" check-exports.py "${{ matrix.built }}"
- name: Stage artifact
working-directory: native/quickjs
shell: bash
run: |
mkdir -p "staged/$(dirname '${{ matrix.artifact }}')"
cp "${{ matrix.built }}" "staged/${{ matrix.artifact }}"
- uses: actions/upload-artifact@v7
with:
name: quickjs-${{ matrix.name }}
path: native/quickjs/staged/
if-no-files-found: error
# The WebGL backend has no native library, so its check is about the jslib
# rather than a binary. It belongs here because it asks the same question.
jslib:
name: webgl-jslib
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check the jslib against the P/Invoke surface
run: python3 native/quickjs/check-jslib.py
- uses: actions/setup-node@v6
with:
node-version-file: .node-version
# The jslib is generated from .source, and nothing else checks that the committed
# one is what .source produces -- a hand-edit or a forgotten rebuild would ship.
- name: Rebuild the jslib and check it matches
working-directory: unity/quickjs/Plugins/QuickJS/WebGL/.source
run: |
npx -y -p typescript@5 tsc
node postbuild.mjs
git diff --exit-code -- ../jsbplugin.jslib
# The module machinery is the one part of the jslib that runs outside a browser, and
# the part with a scanner in it. It is tested against the generated file, not .source.
- name: Run the jslib module tests
working-directory: unity/quickjs/Plugins/QuickJS/WebGL/.source
run: node --test jsbplugin.test.mjs
# One place to see whether the set is complete, and the only job worth making
# a required check.
collect:
name: all artifacts
needs: [build, jslib]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: List what was built
run: find artifacts -type f | sort