-
-
Notifications
You must be signed in to change notification settings - Fork 2
446 lines (387 loc) · 16.8 KB
/
userland-build.yml
File metadata and controls
446 lines (387 loc) · 16.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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# Darwin Userland Build CI
# Tests building Darwin userland components for ARM64 (Raspberry Pi 3)
name: Userland Build
on:
push:
branches: [ master, main ]
paths:
- 'Userland/**'
- '.github/workflows/userland-build.yml'
- 'scripts/**'
pull_request:
branches: [ master, main ]
paths:
- 'Userland/**'
- '.github/workflows/userland-build.yml'
- 'scripts/**'
workflow_dispatch: # Allow manual trigger
env:
# Build settings
TARGET_ARCH: "arm64"
MACOS_DEPLOYMENT_TARGET: "11.0"
jobs:
# ==========================================================================
# Build libdispatch (using Swift open-source version for better portability)
# ==========================================================================
build-libdispatch:
name: Build libdispatch
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Clone swift-corelibs-libdispatch
run: |
git clone --depth 1 --branch swift-5.9.2-RELEASE https://github.com/apple/swift-corelibs-libdispatch.git ~/libdispatch
- name: Configure libdispatch
run: |
cd ~/libdispatch
mkdir build && cd build
# Use older CMake generator expression syntax compatibility
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_OSX_ARCHITECTURES=${{ env.TARGET_ARCH }} \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.MACOS_DEPLOYMENT_TARGET }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$HOME/darwin-sysroot/usr \
-DENABLE_SWIFT=OFF \
2>&1 | tail -50
- name: Build libdispatch
run: |
cd ~/libdispatch/build
make -j$(sysctl -n hw.ncpu) 2>&1 | tail -100
- name: Install libdispatch
run: |
cd ~/libdispatch/build
make install DESTDIR=$HOME/darwin-sysroot || true
echo "==> Installed files:"
find $HOME/darwin-sysroot -type f | head -30 || true
- name: Upload libdispatch artifacts
uses: actions/upload-artifact@v4
with:
name: libdispatch-${{ env.TARGET_ARCH }}
path: ~/darwin-sysroot
retention-days: 7
if-no-files-found: warn
# ==========================================================================
# Build CoreFoundation (using Swift open-source version)
# ==========================================================================
build-corefoundation:
name: Build CoreFoundation
runs-on: macos-14
needs: build-libdispatch
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Download libdispatch artifacts
uses: actions/download-artifact@v4
with:
name: libdispatch-${{ env.TARGET_ARCH }}
path: ~/darwin-sysroot
- name: Clone swift-corelibs-foundation
run: |
git clone --depth 1 --branch swift-5.9.2-RELEASE https://github.com/apple/swift-corelibs-foundation.git ~/foundation
- name: Build CoreFoundation
run: |
cd ~/foundation
# Check structure
echo "==> Foundation structure:"
ls -la
# Try to find CoreFoundation sources
CF_DIR=""
if [ -d "Sources/CoreFoundation" ]; then
CF_DIR="Sources/CoreFoundation"
elif [ -d "CoreFoundation" ]; then
CF_DIR="CoreFoundation"
fi
if [ -n "$CF_DIR" ] && [ -f "$CF_DIR/CMakeLists.txt" ]; then
echo "==> Found CoreFoundation at $CF_DIR with CMake"
cd "$CF_DIR"
mkdir -p build && cd build
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_OSX_ARCHITECTURES=${{ env.TARGET_ARCH }} \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.MACOS_DEPLOYMENT_TARGET }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=$HOME/darwin-sysroot/usr \
-DCF_DEPLOYMENT_SWIFT=OFF \
2>&1 | tail -50 || echo "CMake configuration had issues"
make -j$(sysctl -n hw.ncpu) 2>&1 | tail -100 || echo "Build completed with warnings/errors"
else
echo "==> CoreFoundation CMakeLists.txt not found, copying headers only"
mkdir -p $HOME/darwin-sysroot/usr/include/CoreFoundation
find ~/foundation -name "*.h" -path "*/CoreFoundation/*" -exec cp {} $HOME/darwin-sysroot/usr/include/CoreFoundation/ \; 2>/dev/null || true
echo "Headers copied"
fi
- name: Upload CoreFoundation artifacts
uses: actions/upload-artifact@v4
with:
name: corefoundation-${{ env.TARGET_ARCH }}
path: ~/darwin-sysroot
retention-days: 7
if-no-files-found: warn
# ==========================================================================
# Attempt to build launchd from Apple Open Source
# ==========================================================================
build-launchd:
name: Build launchd
runs-on: macos-14
needs: build-libdispatch
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Download libdispatch artifacts
uses: actions/download-artifact@v4
with:
name: libdispatch-${{ env.TARGET_ARCH }}
path: ~/darwin-sysroot
- name: Try to download launchd source
id: download-launchd
run: |
mkdir -p ~/sources
cd ~/sources
# Try multiple versions - Apple may have different versions available
VERSIONS=("2038.120.1" "1336.261.2" "1205.70.9" "842.92.1")
for VERSION in "${VERSIONS[@]}"; do
echo "==> Trying launchd-${VERSION}..."
if curl -fSL -o "launchd-${VERSION}.tar.gz" \
"https://opensource.apple.com/tarballs/launchd/launchd-${VERSION}.tar.gz" 2>/dev/null; then
echo "==> Downloaded launchd-${VERSION}"
tar xzf "launchd-${VERSION}.tar.gz"
echo "LAUNCHD_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "LAUNCHD_FOUND=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "==> launchd source not available from Apple Open Source"
echo "LAUNCHD_FOUND=false" >> $GITHUB_OUTPUT
- name: Inspect launchd source
if: steps.download-launchd.outputs.LAUNCHD_FOUND == 'true'
run: |
cd ~/sources
VERSION="${{ steps.download-launchd.outputs.LAUNCHD_VERSION }}"
echo "==> launchd-${VERSION} structure:"
ls -la "launchd-${VERSION}/" || true
find "launchd-${VERSION}" -name "*.xcodeproj" -o -name "Makefile" -o -name "*.c" | head -20 || true
- name: Attempt launchd build
if: steps.download-launchd.outputs.LAUNCHD_FOUND == 'true'
run: |
cd ~/sources
VERSION="${{ steps.download-launchd.outputs.LAUNCHD_VERSION }}"
cd "launchd-${VERSION}"
# Try xcodebuild if xcodeproj exists
if ls *.xcodeproj 1> /dev/null 2>&1; then
echo "==> Found Xcode project, listing targets..."
xcodebuild -list 2>&1 | head -50 || true
echo "==> Attempting build..."
xcodebuild -project *.xcodeproj \
-alltargets \
-configuration Release \
ARCHS=${{ env.TARGET_ARCH }} \
VALID_ARCHS=${{ env.TARGET_ARCH }} \
SDKROOT=macosx \
ONLY_ACTIVE_ARCH=NO \
2>&1 | tail -100 || echo "Build completed (may have errors)"
elif [ -f Makefile ]; then
echo "==> Found Makefile, attempting build..."
make ARCH=${{ env.TARGET_ARCH }} 2>&1 | tail -100 || echo "Make completed (may have errors)"
else
echo "==> No standard build system found"
ls -la
fi
- name: Build status
run: |
if [ "${{ steps.download-launchd.outputs.LAUNCHD_FOUND }}" == "true" ]; then
echo "✅ launchd source downloaded (v${{ steps.download-launchd.outputs.LAUNCHD_VERSION }})"
else
echo "⚠️ launchd source not available from Apple Open Source"
echo "Note: Some Apple sources are not publicly available"
fi
# ==========================================================================
# Build dyld from Apple Open Source
# ==========================================================================
build-dyld:
name: Build dyld
runs-on: macos-14
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Try to download dyld source
id: download-dyld
run: |
mkdir -p ~/sources
cd ~/sources
# Try multiple versions
VERSIONS=("1125.2" "1042.1" "955.6" "852.2" "832.7.3" "750.6" "655.1.1")
for VERSION in "${VERSIONS[@]}"; do
echo "==> Trying dyld-${VERSION}..."
if curl -fSL -o "dyld-${VERSION}.tar.gz" \
"https://opensource.apple.com/tarballs/dyld/dyld-${VERSION}.tar.gz" 2>/dev/null; then
echo "==> Downloaded dyld-${VERSION}"
tar xzf "dyld-${VERSION}.tar.gz"
echo "DYLD_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "DYLD_FOUND=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "==> dyld source not available"
echo "DYLD_FOUND=false" >> $GITHUB_OUTPUT
- name: Inspect and build dyld
if: steps.download-dyld.outputs.DYLD_FOUND == 'true'
run: |
cd ~/sources
VERSION="${{ steps.download-dyld.outputs.DYLD_VERSION }}"
echo "==> dyld-${VERSION} structure:"
ls -la "dyld-${VERSION}/" || true
cd "dyld-${VERSION}"
if ls *.xcodeproj 1> /dev/null 2>&1; then
echo "==> Found Xcode project, listing targets..."
xcodebuild -list 2>&1 | head -50 || true
# Try to find a suitable scheme/target
echo "==> Attempting build..."
xcodebuild -project dyld.xcodeproj \
-alltargets \
-configuration Release \
ARCHS=${{ env.TARGET_ARCH }} \
SDKROOT=macosx \
2>&1 | tail -150 || echo "dyld build completed (may have errors)"
else
echo "==> No Xcode project found"
ls -la
fi
- name: Build status
run: |
if [ "${{ steps.download-dyld.outputs.DYLD_FOUND }}" == "true" ]; then
echo "✅ dyld source downloaded (v${{ steps.download-dyld.outputs.DYLD_VERSION }})"
else
echo "⚠️ dyld source not available from Apple Open Source"
fi
# ==========================================================================
# Try to download and inspect XNU headers
# ==========================================================================
check-xnu-headers:
name: Check XNU Headers
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Try to download XNU source
id: download-xnu
run: |
mkdir -p ~/sources
cd ~/sources
# Try multiple versions
VERSIONS=("10063.141.1" "8792.81.2" "8020.140.41" "7195.141.2" "7195.81.3" "6153.141.1")
for VERSION in "${VERSIONS[@]}"; do
echo "==> Trying xnu-${VERSION}..."
if curl -fSL -o "xnu-${VERSION}.tar.gz" \
"https://opensource.apple.com/tarballs/xnu/xnu-${VERSION}.tar.gz" 2>/dev/null; then
echo "==> Downloaded xnu-${VERSION}"
tar xzf "xnu-${VERSION}.tar.gz"
echo "XNU_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "XNU_FOUND=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "==> XNU source not available"
echo "XNU_FOUND=false" >> $GITHUB_OUTPUT
- name: Inspect XNU headers
if: steps.download-xnu.outputs.XNU_FOUND == 'true'
run: |
cd ~/sources
VERSION="${{ steps.download-xnu.outputs.XNU_VERSION }}"
echo "==> XNU-${VERSION} key directories:"
ls -la "xnu-${VERSION}/" || true
echo ""
echo "==> Header directories:"
find "xnu-${VERSION}" -type d -name "include" | head -10 || true
echo ""
echo "==> Mach headers:"
find "xnu-${VERSION}" -path "*/mach/*.h" | head -10 || true
- name: Build status
run: |
if [ "${{ steps.download-xnu.outputs.XNU_FOUND }}" == "true" ]; then
echo "✅ XNU source downloaded (v${{ steps.download-xnu.outputs.XNU_VERSION }})"
else
echo "⚠️ XNU source not available from Apple Open Source"
fi
# ==========================================================================
# Summary job - reports overall build status
# ==========================================================================
build-summary:
name: Build Summary
runs-on: ubuntu-latest
needs: [build-libdispatch, build-corefoundation, build-launchd, build-dyld, check-xnu-headers]
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate build report
run: |
echo "# Darwin Userland Build Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Build Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status | Notes |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|-------|" >> $GITHUB_STEP_SUMMARY
# libdispatch
if [ "${{ needs.build-libdispatch.result }}" == "success" ]; then
echo "| libdispatch | ✅ Success | Swift open-source version |" >> $GITHUB_STEP_SUMMARY
else
echo "| libdispatch | ❌ ${{ needs.build-libdispatch.result }} | |" >> $GITHUB_STEP_SUMMARY
fi
# CoreFoundation
if [ "${{ needs.build-corefoundation.result }}" == "success" ]; then
echo "| CoreFoundation | ✅ Success | Swift open-source version |" >> $GITHUB_STEP_SUMMARY
else
echo "| CoreFoundation | ⚠️ ${{ needs.build-corefoundation.result }} | May need Swift toolchain |" >> $GITHUB_STEP_SUMMARY
fi
# launchd
if [ "${{ needs.build-launchd.result }}" == "success" ]; then
echo "| launchd | ✅ Success | Apple Open Source |" >> $GITHUB_STEP_SUMMARY
else
echo "| launchd | ⚠️ ${{ needs.build-launchd.result }} | May not be publicly available |" >> $GITHUB_STEP_SUMMARY
fi
# dyld
if [ "${{ needs.build-dyld.result }}" == "success" ]; then
echo "| dyld | ✅ Success | Apple Open Source |" >> $GITHUB_STEP_SUMMARY
else
echo "| dyld | ⚠️ ${{ needs.build-dyld.result }} | Complex dependencies |" >> $GITHUB_STEP_SUMMARY
fi
# XNU
if [ "${{ needs.check-xnu-headers.result }}" == "success" ]; then
echo "| XNU Headers | ✅ Available | |" >> $GITHUB_STEP_SUMMARY
else
echo "| XNU Headers | ⚠️ ${{ needs.check-xnu-headers.result }} | |" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Notes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Target architecture: **arm64** (Raspberry Pi 3)" >> $GITHUB_STEP_SUMMARY
echo "- Swift open-source versions are used for libdispatch and CoreFoundation" >> $GITHUB_STEP_SUMMARY
echo "- Some Apple components may not be publicly available or may require additional dependencies" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "See [Userland documentation](Userland/README.md) for manual build instructions." >> $GITHUB_STEP_SUMMARY
- name: Check critical components
run: |
if [ "${{ needs.build-libdispatch.result }}" == "failure" ]; then
echo "::warning::libdispatch build failed - this is a critical dependency"
fi