Repository navigation
402 lines (358 loc) · 15.8 KB
/
Copy pathbuild-all.yml
File metadata and controls
402 lines (358 loc) · 15.8 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
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
400
401
402
name: reusable workflow (buildAll)
on:
workflow_call:
jobs:
build-macos:
name: Build macOS (${{ matrix.arch }})
runs-on: macos-26
strategy:
matrix:
include:
- arch: arm64
triple: arm64-apple-macosx
- arch: x86_64
triple: x86_64-apple-macosx
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Cache (exact)
id: spm-cache-exact
uses: actions/cache/restore@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData
~/Library/Caches/org.swift.swiftpm
.build
key: spm-release-macos-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- name: Restore Cache (fallback)
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
id: spm-cache-fallback
uses: actions/cache/restore@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData
~/Library/Caches/org.swift.swiftpm
.build
key: spm-release-macos-${{ matrix.arch }}-${{ github.ref_name }}-
restore-keys: |
spm-release-macos-${{ matrix.arch }}-
- name: Build macOS Binary
run: |
swift build -c release --triple ${{ matrix.triple }} --product sidesign
mkdir -p dist
cp .build/${{ matrix.triple }}/release/sidesign dist/
cd dist && tar -czvf ../sidesign-macos-${{ matrix.arch }}.tar.gz sidesign && cd ..
shasum -a 256 sidesign-macos-${{ matrix.arch }}.tar.gz > sidesign-macos-${{ matrix.arch }}.tar.gz.sha256
- name: Save Cache
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData
~/Library/Caches/org.swift.swiftpm
.build
key: spm-release-macos-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- uses: actions/upload-artifact@v4
with:
name: macos-assets-${{ matrix.arch }}
path: sidesign-macos-${{ matrix.arch }}.tar.gz*
build-linux:
name: Build Linux (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- arch: x86_64
os: ubuntu-latest
- arch: aarch64
os: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y binutils git gnupg2 libc6-dev libcurl4-openssl-dev libedit2 libgcc-s1 libsqlite3-0 libstdc++-13-dev libxml2-dev libz3-dev pkg-config tzdata zlib1g-dev libssl-dev
- name: Setup Swift
run: |
if [ "${{ matrix.arch }}" = "aarch64" ]; then
SWIFT_PKG="swift-6.0.3-RELEASE-ubuntu24.04-aarch64"
SWIFT_URL="https://download.swift.org/swift-6.0.3-release/ubuntu2404-aarch64/swift-6.0.3-RELEASE/$SWIFT_PKG.tar.gz"
else
SWIFT_PKG="swift-6.0.3-RELEASE-ubuntu24.04"
SWIFT_URL="https://download.swift.org/swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE/$SWIFT_PKG.tar.gz"
fi
curl -fsSL "$SWIFT_URL" -o /tmp/swift.tar.gz
sudo mkdir -p /usr/local/swift
sudo tar -xzf /tmp/swift.tar.gz -C /usr/local/swift --strip-components=1
echo "/usr/local/swift/usr/bin" >> $GITHUB_PATH
/usr/local/swift/usr/bin/swift --version
- name: Restore Cache (exact)
id: spm-cache-exact
uses: actions/cache/restore@v4
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: spm-release-linux-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- name: Restore Cache (fallback)
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
id: spm-cache-fallback
uses: actions/cache/restore@v4
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: spm-release-linux-${{ matrix.arch }}-${{ github.ref_name }}-
restore-keys: |
spm-release-linux-${{ matrix.arch }}-
- name: Install Unicorn (Headers & Static Library)
run: |
curl -fsSL "https://github.com/mahee96/unicorn/releases/latest/download/unicorn-linux-${{ matrix.arch }}.tar.gz" -o /tmp/unicorn.tar.gz
mkdir -p /tmp/unicorn-pkg
tar -xzf /tmp/unicorn.tar.gz -C /tmp/unicorn-pkg
sudo mkdir -p /usr/include/unicorn /usr/local/include/unicorn /usr/lib /usr/local/lib
sudo cp -r /tmp/unicorn-pkg/include/unicorn/* /usr/include/unicorn/
sudo cp -r /tmp/unicorn-pkg/include/unicorn/* /usr/local/include/unicorn/
sudo cp /tmp/unicorn-pkg/lib/libunicorn.a /usr/lib/
sudo cp /tmp/unicorn-pkg/lib/libunicorn.a /usr/local/lib/
- name: Build Linux Binary
run: |
swift build -c release --product sidesign
mkdir -p dist
cp .build/release/sidesign dist/
cd dist && tar -czvf ../sidesign-linux-${{ matrix.arch }}.tar.gz sidesign && cd ..
shasum -a 256 sidesign-linux-${{ matrix.arch }}.tar.gz > sidesign-linux-${{ matrix.arch }}.tar.gz.sha256
- name: Save Cache
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: spm-release-linux-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- uses: actions/upload-artifact@v4
with:
name: linux-assets-${{ matrix.arch }}
path: sidesign-linux-${{ matrix.arch }}.tar.gz*
build-windows:
name: Build Windows (${{ matrix.arch }})
runs-on: windows-2022
strategy:
matrix:
include:
- arch: x64
msvc_arch: x64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Cache (exact)
id: spm-cache-exact
uses: actions/cache/restore@v4
with:
path: |
~\AppData\Local\org.swift.swiftpm
~/.cache/org.swift.swiftpm
.build
C:\unicorn
key: spm-windows-${{ matrix.arch }}-swift6.0.3-sdk10.0.22621.0-${{ hashFiles('**/Package.resolved', '**/Package.swift') }}-${{ github.sha }}
- name: Restore Cache (fallback)
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
id: spm-cache-fallback
uses: actions/cache/restore@v4
with:
path: |
~\AppData\Local\org.swift.swiftpm
~/.cache/org.swift.swiftpm
.build
C:\unicorn
key: spm-windows-${{ matrix.arch }}-swift6.0.3-sdk10.0.22621.0-${{ hashFiles('**/Package.resolved', '**/Package.swift') }}-
restore-keys: |
spm-windows-${{ matrix.arch }}-swift6.0.3-sdk10.0.22621.0-
spm-windows-${{ matrix.arch }}-
- name: Setup MSVC Developer Environment (Windows SDK 10.0.22621.0)
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}
sdk: "10.0.22621.0"
- name: Setup Swift on Windows
uses: SwiftyLab/setup-swift@latest
with:
swift-version: "6.0.3"
- name: Configure Windows SDK Modulemaps
shell: pwsh
run: |
Write-Host "=== Clearing Clang Module Cache ==="
if (Test-Path "$env:LOCALAPPDATA\clang\ModuleCache") {
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\clang\ModuleCache"
}
$share = "$env:SDKROOT\usr\share"
$ucrtDir = "C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt"
$umDir = "C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um"
Write-Host "=== Copying module.modulemap to Windows Kits UCRT and UM ==="
Copy-Item "$share\ucrt.modulemap" "$ucrtDir\module.modulemap" -Force
Copy-Item "$share\winsdk.modulemap" "$umDir\module.modulemap" -Force
Copy-Item "$share\ucrt.apinotes" "$ucrtDir\ucrt.apinotes" -Force -ErrorAction SilentlyContinue
Copy-Item "$share\winsdk.apinotes" "$umDir\winsdk.apinotes" -Force -ErrorAction SilentlyContinue
Write-Host "UCRT modulemap placed at: $ucrtDir\module.modulemap"
Write-Host "WinSDK modulemap placed at: $umDir\module.modulemap"
- name: Install Unicorn & Dependencies (Headers & Library)
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path C:\unicorn\include | Out-Null
New-Item -ItemType Directory -Force -Path C:\unicorn\lib | Out-Null
if (-not (Test-Path "C:\unicorn\include\unicorn\unicorn.h")) {
Write-Host "Unicorn not found in cache, downloading..."
Invoke-WebRequest -Uri "https://github.com/mahee96/unicorn/releases/latest/download/unicorn-windows-${{ matrix.arch }}.zip" -OutFile C:\unicorn.zip
Expand-Archive -Path C:\unicorn.zip -DestinationPath C:\unicorn -Force
} else {
Write-Host "Unicorn restored from cache!"
}
# Ensure zlib headers and library (zlib.lib / z.lib) are present in C:\unicorn
if (-not (Test-Path "C:\unicorn\lib\zlib.lib") -or -not (Test-Path "C:\unicorn\include\zlib.h")) {
Write-Host "Installing zlib static library via vcpkg..."
vcpkg install zlib:x64-windows-static --x-install-root=C:\vcpkg_installed
Copy-Item "C:\vcpkg_installed\x64-windows-static\lib\*.lib" "C:\unicorn\lib\zlib.lib" -Force
Copy-Item "C:\vcpkg_installed\x64-windows-static\lib\*.lib" "C:\unicorn\lib\z.lib" -Force
Copy-Item "C:\vcpkg_installed\x64-windows-static\include\zlib.h" "C:\unicorn\include\zlib.h" -Force
Copy-Item "C:\vcpkg_installed\x64-windows-static\include\zconf.h" "C:\unicorn\include\zconf.h" -Force
}
if (Test-Path "C:\unicorn\include\zconf.h") {
(Get-Content C:\unicorn\include\zconf.h) -replace '.*unistd\.h.*', '// #include <unistd.h>' | Set-Content C:\unicorn\include\zconf.h
}
echo "INCLUDE=$env:INCLUDE;C:\unicorn\include" >> $env:GITHUB_ENV
echo "LIB=$env:LIB;C:\unicorn\lib" >> $env:GITHUB_ENV
- name: Build Windows Executable
shell: pwsh
env:
_CL_: "/D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
run: |
swift build -c release -v `
-Xcc -IC:\unicorn\include `
-Xcc -DWIN32=1 `
-Xcc -DZ_HAVE_UNISTD_H=0 `
-Xcc -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH `
-Xcxx -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH `
-Xcc -D_CRT_SECURE_NO_WARNINGS `
-Xcc -D_CRT_NONSTDC_NO_WARNINGS `
-Xswiftc -D_CRT_SECURE_NO_WARNINGS `
-Xswiftc -D_CRT_NONSTDC_NO_WARNINGS `
-Xcxx -IC:\unicorn\include `
-Xlinker /LIBPATH:C:\unicorn\lib `
-Xlinker C:\unicorn\lib\zlib.lib `
--product sidesign
if ($LASTEXITCODE -ne 0) {
Write-Error "Swift build failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
New-Item -ItemType Directory -Force -Path dist | Out-Null
$exe = Get-ChildItem -Path .build -Filter sidesign.exe -Recurse | Where-Object { $_.FullName -like "*release*" } | Select-Object -First 1 -ExpandProperty FullName
if (-not $exe) {
Write-Error "Could not locate sidesign.exe in .build folder"
Get-ChildItem -Path .build -Recurse | Select-Object FullName
exit 1
}
Write-Host "Found binary at: $exe"
Copy-Item $exe dist\sidesign.exe
Compress-Archive -Path dist\sidesign.exe -DestinationPath sidesign-windows-${{ matrix.arch }}.zip
$hash = (Get-FileHash sidesign-windows-${{ matrix.arch }}.zip -Algorithm SHA256).Hash
"$hash sidesign-windows-${{ matrix.arch }}.zip" | Out-File -Encoding ASCII sidesign-windows-${{ matrix.arch }}.zip.sha256
- name: Save Cache
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~\AppData\Local\org.swift.swiftpm
~/.cache/org.swift.swiftpm
.build
C:\unicorn
key: spm-windows-${{ matrix.arch }}-swift6.0.3-sdk10.0.22621.0-${{ hashFiles('**/Package.resolved', '**/Package.swift') }}-${{ github.sha }}
- uses: actions/upload-artifact@v4
with:
name: windows-assets-${{ matrix.arch }}
path: sidesign-windows-${{ matrix.arch }}.zip*
build-android:
name: Build Android (${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: aarch64
triple: aarch64-unknown-linux-android24
unicorn_arch: arm64-v8a
- arch: x86_64
triple: x86_64-unknown-linux-android24
unicorn_arch: x86_64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Swift
uses: swift-actions/setup-swift@v2
with:
swift-version: "6.0.3"
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r26d
- name: Restore Cache (exact)
id: spm-cache-exact
uses: actions/cache/restore@v4
with:
path: |
~/.cache/org.swift.swiftpm
~/.local/share/swift/sdks
.build
key: spm-release-android-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- name: Restore Cache (fallback)
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
id: spm-cache-fallback
uses: actions/cache/restore@v4
with:
path: |
~/.cache/org.swift.swiftpm
~/.local/share/swift/sdks
.build
key: spm-release-android-${{ matrix.arch }}-${{ github.ref_name }}-
restore-keys: |
spm-release-android-${{ matrix.arch }}-
- name: Install Swift Android SDK
run: |
if ! swift sdk list 2>/dev/null | grep -q "${{ matrix.triple }}"; then
curl -fsSL "https://github.com/finagolfin/swift-android-sdk/releases/download/6.0.3/swift-6.0.3-RELEASE-android-24-0.1.artifactbundle.tar.gz" -o android-sdk.tar.gz
swift sdk install android-sdk.tar.gz
else
echo "Swift Android SDK already installed from cache!"
fi
- name: Install Unicorn (Headers & Library)
run: |
curl -fsSL "https://github.com/mahee96/unicorn/releases/latest/download/unicorn-android-${{ matrix.unicorn_arch }}.tar.gz" -o /tmp/unicorn.tar.gz
mkdir -p /tmp/unicorn-pkg
tar -xzf /tmp/unicorn.tar.gz -C /tmp/unicorn-pkg
- name: Build Android Binary
run: |
swift build -c release --swift-sdk ${{ matrix.triple }} \
-Xcc -I/tmp/unicorn-pkg/include \
-Xcxx -I/tmp/unicorn-pkg/include \
-Xlinker -L/tmp/unicorn-pkg/lib \
--product sidesign
mkdir -p dist
cp .build/${{ matrix.triple }}/release/sidesign dist/
cd dist && tar -czvf ../sidesign-android-${{ matrix.arch }}.tar.gz sidesign && cd ..
shasum -a 256 sidesign-android-${{ matrix.arch }}.tar.gz > sidesign-android-${{ matrix.arch }}.tar.gz.sha256
- name: Save Cache
if: steps.spm-cache-exact.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.cache/org.swift.swiftpm
~/.local/share/swift/sdks
.build
key: spm-release-android-${{ matrix.arch }}-${{ github.ref_name }}-${{ github.sha }}
- uses: actions/upload-artifact@v4
with:
name: android-assets-${{ matrix.arch }}
path: sidesign-android-${{ matrix.arch }}.tar.gz*