1+ name : Fix dylib dependencies
2+
3+ on : [push, pull_request]
4+
5+ jobs :
6+ check-dylib :
7+ strategy :
8+ fail-fast : false
9+ matrix :
10+ # See https://github.com/actions/runner-images?tab=readme-ov-file#available-images
11+ os : [macos-15-intel]
12+ runs-on : ${{ matrix.os }}
13+ steps :
14+ - uses : actions/checkout@v4
15+ - name : Install dependencies with brew
16+ run : |
17+ brew install libusb hidapi
18+ - name : List dependencies (macOS)
19+ run : otool -L ./bin/openocd
20+ - name : Try to run unfixed openocd
21+ run : ./bin/openocd --version || true
22+ - name : Fix dylib dependencies
23+ run : |
24+ cd bin
25+ # Copy dylib files from homebrew
26+ cp /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib .
27+ cp /opt/homebrew/opt/hidapi/lib/libhidapi.0.dylib .
28+
29+ # Check architecture of dylib files
30+ echo "Architecture info:"
31+ file libusb-1.0.0.dylib
32+ file libhidapi.0.dylib
33+ file openocd
34+
35+ # Fix openocd binary to use local dylibs
36+ echo "Fixing openocd dependencies..."
37+ install_name_tool -change /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib "@executable_path/./libusb-1.0.0.dylib" ./openocd
38+ install_name_tool -change /opt/homebrew/opt/hidapi/lib/libhidapi.0.dylib "@executable_path/./libhidapi.0.dylib" ./openocd
39+
40+ # Verify the changes
41+ otool -L ./openocd
42+ - name : Uninstall brew packages to verify self-contained binary
43+ run : |
44+ brew uninstall --ignore-dependencies libusb hidapi
45+ - name : Try to run fixed openocd
46+ run : ./bin/openocd --version || true
47+ - name : Upload fixed openocd
48+ uses : actions/upload-artifact@v4
49+ with :
50+ name : openocd-fixed
51+ path : |
52+ bin/openocd
53+ bin/libusb-1.0.0.dylib
54+ bin/libhidapi.0.dylib
0 commit comments