|
5 | 5 | tags: |
6 | 6 | - 'v*' |
7 | 7 | branches: |
8 | | - - 'release-binaries-04' |
| 8 | + - 'mac-binary-02' |
9 | 9 | workflow_dispatch: |
10 | 10 |
|
11 | 11 | jobs: |
@@ -240,76 +240,106 @@ jobs: |
240 | 240 | # Copy the binary |
241 | 241 | cp build/vsdf release/macos/ |
242 | 242 | |
243 | | - # Find and copy all non-system dylibs |
244 | | - echo "Bundling dynamic libraries..." |
| 243 | + echo "📋 Libraries linked BEFORE bundling:" |
| 244 | + otool -L build/vsdf |
| 245 | + echo "" |
245 | 246 | |
246 | | - # Get list of dynamic libraries (excluding system ones) |
247 | | - DYLIBS=$(otool -L build/vsdf | grep -E "(glslang|spirv-tools|ffmpeg|libav)" | awk '{print $1}') |
| 247 | + # Recursively find and copy all non-system dylibs |
| 248 | + echo "🔍 Finding and bundling dynamic libraries..." |
248 | 249 | |
249 | | - for lib in $DYLIBS; do |
| 250 | + # Function to copy a library and its dependencies |
| 251 | + copy_lib_recursive() { |
| 252 | + local lib="$1" |
| 253 | + local libname=$(basename "$lib") |
| 254 | + |
| 255 | + # Skip if already copied |
| 256 | + if [ -f "release/macos/libs/$libname" ]; then |
| 257 | + return |
| 258 | + fi |
| 259 | + |
| 260 | + # Skip system libraries |
| 261 | + if [[ "$lib" == /System/* ]] || [[ "$lib" == /usr/lib/* ]] || [[ "$lib" == /Library/Apple/* ]]; then |
| 262 | + return |
| 263 | + fi |
| 264 | + |
| 265 | + # Copy the library |
250 | 266 | if [ -f "$lib" ]; then |
251 | | - libname=$(basename "$lib") |
252 | | - if [ -f "release/macos/libs/$libname" ]; then |
253 | | - echo "Already copied $libname" |
254 | | - else |
255 | | - echo "Copying $libname" |
256 | | - cp "$lib" release/macos/libs/ |
257 | | - fi |
258 | | -
|
259 | | - # Also copy any dependencies of this library |
260 | | - SUB_DYLIBS=$(otool -L "$lib" | grep -E "(glslang|spirv-tools|ffmpeg|libav)" | awk '{print $1}') |
261 | | - for sublib in $SUB_DYLIBS; do |
262 | | - if [ -f "$sublib" ]; then |
263 | | - sublibname=$(basename "$sublib") |
264 | | - if [ ! -f "release/macos/libs/$sublibname" ]; then |
265 | | - echo "Copying dependency $sublibname" |
266 | | - cp "$sublib" release/macos/libs/ |
267 | | - fi |
| 267 | + echo " → Copying $libname" |
| 268 | + cp "$lib" release/macos/libs/ |
| 269 | + |
| 270 | + # Recursively copy dependencies of this library |
| 271 | + otool -L "$lib" | tail -n +2 | awk '{print $1}' | while read -r dep; do |
| 272 | + if [ -f "$dep" ]; then |
| 273 | + copy_lib_recursive "$dep" |
268 | 274 | fi |
269 | 275 | done |
270 | 276 | fi |
| 277 | + } |
| 278 | + |
| 279 | + # Get initial list of libraries from the binary |
| 280 | + otool -L build/vsdf | tail -n +2 | awk '{print $1}' | while read -r lib; do |
| 281 | + if [ -f "$lib" ]; then |
| 282 | + copy_lib_recursive "$lib" |
| 283 | + fi |
271 | 284 | done |
272 | 285 | |
| 286 | + BUNDLED_COUNT=$(ls release/macos/libs/*.dylib 2>/dev/null | wc -l | xargs) |
| 287 | + echo "" |
| 288 | + echo "Total libraries bundled: $BUNDLED_COUNT" |
| 289 | + echo "" |
| 290 | + |
273 | 291 | # Fix all library paths to use @rpath |
274 | | - echo "Fixing library paths..." |
| 292 | + echo "🔧 Fixing library paths..." |
275 | 293 | |
276 | | - # Set rpath on the binary to look next to the executable |
277 | | - install_name_tool -add_rpath "@executable_path" release/macos/vsdf |
| 294 | + # Set rpath on the binary to look in libs/ folder next to the executable |
| 295 | + # Only add if it doesn't already exist |
| 296 | + if ! otool -l release/macos/vsdf | grep -q "@executable_path/libs"; then |
| 297 | + echo " Adding @executable_path/libs to rpath" |
| 298 | + install_name_tool -add_rpath "@executable_path/libs" release/macos/vsdf |
| 299 | + else |
| 300 | + echo " @executable_path/libs already in rpath" |
| 301 | + fi |
278 | 302 | |
279 | 303 | # Fix paths in the main binary |
280 | 304 | for lib in release/macos/libs/*.dylib; do |
281 | 305 | libname=$(basename "$lib") |
282 | 306 | # Find the original path in the binary |
283 | 307 | ORIG_PATH=$(otool -L release/macos/vsdf | grep "$libname" | awk '{print $1}') |
284 | 308 | if [ ! -z "$ORIG_PATH" ]; then |
285 | | - echo "Fixing $libname in vsdf" |
286 | | - install_name_tool -change "$ORIG_PATH" "@rpath/libs/$libname" release/macos/vsdf |
| 309 | + echo " Fixing $libname in vsdf: $ORIG_PATH -> @rpath/$libname" |
| 310 | + install_name_tool -change "$ORIG_PATH" "@rpath/$libname" release/macos/vsdf |
287 | 311 | fi |
288 | 312 | done |
289 | 313 | |
290 | 314 | # Fix inter-library dependencies |
291 | 315 | for lib in release/macos/libs/*.dylib; do |
292 | 316 | libname=$(basename "$lib") |
293 | | - echo "Fixing paths in $libname" |
294 | 317 | |
295 | 318 | # Fix the library's own id |
296 | | - install_name_tool -id "@rpath/libs/$libname" "$lib" |
| 319 | + install_name_tool -id "@rpath/$libname" "$lib" |
297 | 320 | |
298 | 321 | # Fix references to other bundled libraries |
299 | 322 | for otherlib in release/macos/libs/*.dylib; do |
300 | 323 | othername=$(basename "$otherlib") |
301 | 324 | ORIG_PATH=$(otool -L "$lib" | grep "$othername" | awk '{print $1}') |
302 | | - if [ ! -z "$ORIG_PATH" ] && [ "$ORIG_PATH" != "@rpath/libs/$othername" ]; then |
303 | | - install_name_tool -change "$ORIG_PATH" "@rpath/libs/$othername" "$lib" |
| 325 | + if [ ! -z "$ORIG_PATH" ] && [ "$ORIG_PATH" != "@rpath/$othername" ]; then |
| 326 | + echo " Fixing $othername in $libname: $ORIG_PATH -> @rpath/$othername" |
| 327 | + install_name_tool -change "$ORIG_PATH" "@rpath/$othername" "$lib" |
304 | 328 | fi |
305 | 329 | done |
306 | 330 | done |
307 | 331 | |
308 | | - echo "Bundle complete!" |
309 | | - echo "Bundled libraries:" |
| 332 | + echo "" |
| 333 | + echo "✓ Bundling complete" |
| 334 | + echo "" |
| 335 | + echo "📦 Binary info:" |
| 336 | + file release/macos/vsdf |
| 337 | + ls -lh release/macos/vsdf |
| 338 | + echo "" |
| 339 | + echo "📚 Bundled libraries:" |
310 | 340 | ls -lh release/macos/libs/ |
311 | | - |
312 | | - echo "Binary dependencies after fixing:" |
| 341 | + echo "" |
| 342 | + echo "🔗 Binary dependencies after fixing:" |
313 | 343 | otool -L release/macos/vsdf |
314 | 344 |
|
315 | 345 | - name: Code sign binaries |
|
0 commit comments