-
Notifications
You must be signed in to change notification settings - Fork 119
373 lines (363 loc) · 14.7 KB
/
main.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
name: Libobjc2 CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Automatically run the workflow once a month
schedule:
- cron: '0 4 1 * *'
# Allow running the workflow manually
workflow_dispatch:
jobs:
ubuntu:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ "ubuntu-22.04", "ubuntu-20.04" ]
build-type: [ Release, Debug ]
blocks-runtime: [ "EMBEDDED", "swift-5.10-RELEASE" ]
cxxlib: [ "libc++", "libstdc++" ]
llvm-version: [10, 11, 12, 13, 14, 15]
# Don't bother testing the LLVM versions that aren't in the default image for the different platforms
exclude:
- os: "ubuntu-22.04"
llvm-version: 10
- os: "ubuntu-22.04"
llvm-version: 11
- os: "ubuntu-22.04"
llvm-version: 12
- os: "ubuntu-20.04"
llvm-version: 11
- os: "ubuntu-20.04"
llvm-version: 13
- os: "ubuntu-20.04"
llvm-version: 14
- os: "ubuntu-20.04"
llvm-version: 15
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} ${{ matrix.build-type }} LLVM-${{ matrix.llvm-version }} ${{ matrix.cxxlib }} BlocksRuntime-${{ matrix.blocks-runtime }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt install ninja-build
if [ "${{ matrix.cxxlib }}" = "libc++" ]; then
sudo apt remove -y 'libc++*'
apt search libunwind
sudo apt install libc++-${{matrix.llvm-version}}-dev libc++abi-${{matrix.llvm-version}}-dev
sudo apt install libunwind-${{matrix.llvm-version}}-dev || true
fi
if [ "${{ matrix.blocks-runtime }}" != "EMBEDDED" ]; then
git clone --depth 1 --branch "${{ matrix.blocks-runtime }}" https://github.com/apple/swift-corelibs-libdispatch.git ${{github.workspace}}/swift-corelibs-libdispatch
cmake -B ${{github.workspace}}/swift-corelibs-libdispatch/build -G Ninja -DINSTALL_PRIVATE_HEADERS=ON -DCMAKE_C_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm-version}} -S ${{github.workspace}}/swift-corelibs-libdispatch
pushd ${{github.workspace}}/swift-corelibs-libdispatch/build
ninja
sudo ninja install
popd
fi
- name: Configure CMake
run: |
export LDFLAGS=-L/usr/lib/llvm-${{ matrix.llvm-version }}/lib/
if [ "${{ matrix.blocks-runtime }}" != "EMBEDDED" ]; then
export EMBEDDED_BLOCKS_RUNTIME=OFF
else
export EMBEDDED_BLOCKS_RUNTIME=ON
fi
ls -lahR /usr/lib/llvm-${{ matrix.llvm-version }}/lib/
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -G Ninja -DTESTS=ON -DEMBEDDED_BLOCKS_RUNTIME=$EMBEDDED_BLOCKS_RUNTIME -DCMAKE_C_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_OBJC_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_ASM_COMPILER=clang-${{matrix.llvm-version}} -DCMAKE_CXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_OBJCXX_COMPILER=clang++-${{matrix.llvm-version}} -DCMAKE_CXX_FLAGS="-stdlib=${{matrix.cxxlib}}"
# Build with a nice ninja status line
- name: Build
working-directory: ${{github.workspace}}/build
run: |
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest --output-on-failure -j 4
qemu-crossbuild:
strategy:
matrix:
build-type: [ Release, Debug ]
llvm-version: [13, 14, 15]
arch:
- name: armhf
system-processor: arm
triple: arm-linux-gnueabihf
rtld: ld-linux-armhf.so.3
# The C++ exception tests are failing, disable them until they are debugged.
unsupported: -E CXX
- name: arm64
system-processor: aarch64
triple: aarch64-linux-gnu
rtld: ld-linux-aarch64.so.1
- name: riscv64
system-processor: riscv64
triple: riscv64-linux-gnu
rtld: ld-linux-riscv64-lp64d.so.1
- name: ppc64el
system-processor: powerpc64le
triple: powerpc64le-linux-gnu
rtld: ld64.so.2
# lld versions prior to 15 do not support R_RISCV_ALIGN relocations
exclude:
- llvm-version: 13
arch:
name: riscv64
- llvm-version: 14
arch:
name: riscv64
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ubuntu-latest
name: Cross-build for ${{ matrix.arch.triple }} LLVM-${{ matrix.llvm-version}} ${{ matrix.build-type }}
steps:
- uses: actions/checkout@v3
- name: Install cross-compile toolchain and QEMU
run: |
sudo apt update
sudo apt install libstdc++-9-dev-${{ matrix.arch.name }}-cross qemu-user ninja-build
- name: Configure CMake
run: |
export LDFLAGS="-L/usr/lib/llvm-${{ matrix.llvm-version }}/lib/ -fuse-ld=lld-${{ matrix.llvm-version}} -Wl,--dynamic-linker=/usr/${{ matrix.arch.triple }}/lib/${{ matrix.arch.rtld }},-rpath,/usr/${{ matrix.arch.triple }}/lib"
cmake -B ${{github.workspace}}/build \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch.system-processor }} \
-DCMAKE_C_COMPILER=clang-${{ matrix.llvm-version }} \
-DCMAKE_CXX_COMPILER=clang++-${{ matrix.llvm-version }} \
-DCMAKE_ASM_COMPILER=clang-${{ matrix.llvm-version }} \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.arch.triple }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.arch.triple }} \
-DCMAKE_OBJC_COMPILER_TARGET=${{ matrix.arch.triple }} \
-DCMAKE_OBJCXX_COMPILER_TARGET=${{ matrix.arch.triple }} \
-DCMAKE_ASM_COMPILER_TARGET=${{ matrix.arch.triple }} \
-DCMAKE_BUILD_TYPE=${{matrix.build-type}} \
-DTESTS=ON \
-G Ninja \
# Build with a nice ninja status line
- name: Build
working-directory: ${{github.workspace}}/build
run: |
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja -v
- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest --output-on-failure -j 4 ${{ matrix.arch.unsupported }}
windows:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ windows-2022, windows-2019 ]
build-type: [ Release, Debug ]
arch: [ x64_x86, x64 ]
include:
- arch: x64_x86
flags: -m32
- arch: x64
flags: -m64
- os: windows-2022
vspath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
- os: windows-2019
vspath: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} ${{ matrix.build-type }} ${{ matrix.arch }}
steps:
- name: look at VS install
shell: cmd
run: |
dir "${{ matrix.vspath }}"
- uses: actions/checkout@v3
with:
submodules: true
- name: Install dependencies
run: |
choco.exe install ninja
- name: Configure CMake
shell: cmd
run: |
call "${{ matrix.vspath }}\vcvarsall.bat" ${{ matrix.arch }}
set CFLAGS=${{ matrix.flags }}
set CXXFLAGS=${{ matrix.flags }}
set OBJCFLAGS=${{ matrix.flags }}
set OBJCXXFLAGS=${{ matrix.flags }}
set ASMFLAGS=${{ matrix.flags }}
mkdir build
cd build
cmake .. -G Ninja -DTESTS=ON -DCMAKE_C_COMPILER="c:/Program Files/LLVM/bin/clang.exe" -DCMAKE_CXX_COMPILER="c:/Program Files/LLVM/bin/clang.exe" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
shell: cmd
working-directory: build
run: |
call "${{ matrix.vspath }}\vcvarsall.bat" ${{ matrix.arch }}
ninja
- name: Test
shell: cmd
working-directory: build
run: |
ctest -j 4 --output-on-failure -T test
mingw:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ windows-2019 ]
msystem: [ ucrt64, mingw64, clang64 ]
build-type: [ Release, Debug ]
include:
- msystem: ucrt64
package-prefix: ucrt-x86_64
cmake-flags: LDFLAGS="-fuse-ld=lld -lstdc++ -lgcc_s"
- msystem: mingw64
package-prefix: x86_64
cmake-flags: LDFLAGS="-fuse-ld=lld -lstdc++ -lgcc_s"
- msystem: clang64
package-prefix: clang-x86_64
cmake-flags: LDFLAGS="-lc++"
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} ${{ matrix.msystem }} ${{ matrix.build-type}}
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: git mingw-w64-${{ matrix.package-prefix }}-clang mingw-w64-${{ matrix.package-prefix }}-lld mingw-w64-${{ matrix.package-prefix }}-cmake
- name: Configure CMake
run: |
mkdir build
cd build
${{ matrix.cmake-flags }} cmake .. -DTESTS=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
working-directory: build
run: |
cmake --build .
- name: Test
working-directory: build
run: |
ctest -j 4 --output-on-failure -T test ${{ matrix.ctest-flags }}
- name: Install
working-directory: build
run: |
cmake --install . --prefix=../dist
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.msystem }}-${{ matrix.build-type }}
path: dist/
android:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ ubuntu-20.04 ]
build-type: [ Release, Debug ]
arch:
- name: x86_64
triple: x86_64-linux-android
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
- name: arm64-v8a
triple: aarch64-linux-android
# Google broke ARM64 emulation on x86_64 hosts. A workaround is to overwrite the qemu machine type.
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -accel off -qemu -machine virt
api-level: [ 27, 33 ]
# Please note that:
# - arm64-v8a emulation on a x86_64 host currently is only possible up to API level 27 Oreo
# - armeabi-v7a is only supported up to API level 24
exclude:
- api-level: 33
arch:
name: arm64-v8a
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: Android ${{ matrix.build-type }} ${{ matrix.arch.name }} API-${{ matrix.api-level }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update -y
sudo apt-get install patchelf ninja-build -y
- name: Enable KVM
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: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.arch.name }}
- name: Create AVD and Snapshot for Caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: hmelder/android-emulator-runner@v2.33.2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch.name }}
force-avd-creation: false
emulator-options: ${{ matrix.arch.emu-options }}
disable-animations: true
script: echo "Generated AVD snapshot for caching."
# We are using the default NDK from the GitHub Actions runner.
- name: Configure CMake
run: |
export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
export CCPREFIX=$TOOLCHAIN/bin/${{ matrix.arch.triple }}${{ matrix.api-level }}
export CC="$CCPREFIX-clang"
export CXX="$CCPREFIX-clang++"
export OBJC="$CCPREFIX-clang"
export OBJCXX="$CCPREFIX-clang++"
export AS="$CCPREFIX-clang"
export LD="$TOOLCHAIN/bin/ld.lld"
export AR="$TOOLCHAIN/bin/llvm-ar"
export RANLIB="$TOOLCHAIN/bin/llvm-ranlib"
export STRIP="$TOOLCHAIN/bin/llvm-strip"
export NM="$TOOLCHAIN/bin/llvm-nm"
export OBJDUMP="$TOOLCHAIN/bin/llvm-objdump"
export LDFLAGS="-fuse-ld=lld"
export LIBS="-lc++_shared"
cmake -B ${{github.workspace}}/build \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=${{ matrix.arch.name }} \
-DANDROID_NDK=$ANDROID_NDK_HOME \
-DANDROID_STL=c++_shared \
-DCMAKE_FIND_USE_CMAKE_PATH=false \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_ASM_COMPILER=$AS \
-DCMAKE_BUILD_TYPE=${{matrix.build-type}} \
-DTESTS=ON \
-DANDROID_PLATFORM=android-${{ matrix.api-level }} \
-G Ninja
- name: Build
working-directory: ${{github.workspace}}/build
run: |
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja -v
- name: Test
uses: hmelder/android-emulator-runner@v2.33.2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch.name }}
force-avd-creation: false
emulator-options: ${{ matrix.arch.emu-options }}
disable-animations: true
target: default
script: |
${{github.workspace}}/.github/scripts/android_test_main.sh ${{github.workspace}}/build ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot ${{ matrix.arch.triple }}
# Fake check that can be used as a branch-protection rule.
all-checks:
needs: [ubuntu, windows, qemu-crossbuild]
runs-on: ubuntu-latest
steps:
- name: Dummy step
run: true