Skip to content

Commit 54baa27

Browse files
committed
CI: workflow to build bundled macOS dylibs (GLFW + GLEW)
1 parent 8b696c8 commit 54baa27

1 file changed

Lines changed: 35 additions & 55 deletions

File tree

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,51 @@
1-
name: Build macOS bundled libs (GLFW + GLEW)
1+
name: Build macOS bundled dylibs
22

33
on:
4-
workflow_dispatch:
5-
6-
permissions:
7-
contents: write
4+
workflow_dispatch: # manual trigger only
85

96
jobs:
107
build:
11-
runs-on: macos-latest # arm64 runner only -- we lipo universal binaries
8+
runs-on: macos-latest
129
steps:
1310
- uses: actions/checkout@v4
1411

15-
- name: Install GLFW and GLEW (arm64)
16-
run: |
17-
export HOMEBREW_NO_REQUIRE_TAP_TRUST=1
18-
export NONINTERACTIVE=1
19-
brew install glfw glew
20-
21-
- name: Install x86_64 GLFW and GLEW via Rosetta homebrew
22-
run: |
23-
export HOMEBREW_NO_REQUIRE_TAP_TRUST=1
24-
export NONINTERACTIVE=1
25-
# Install x86_64 homebrew if not present
26-
if [ ! -f /usr/local/bin/brew ]; then
27-
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
28-
fi
29-
arch -x86_64 /usr/local/bin/brew install glfw glew
12+
- name: Install GLFW and GLEW via Homebrew
13+
run: brew install glfw glew
3014

31-
- name: Build universal dylibs
15+
- name: Collect dylibs (arm64)
3216
run: |
33-
mkdir -p libs/macos-arm64 libs/macos-x64
34-
35-
ARM_PREFIX=$(brew --prefix)
36-
X64_PREFIX=/usr/local
37-
17+
mkdir -p libs/macos-arm64
3818
# GLFW
39-
cp "$ARM_PREFIX/lib/libglfw.3.dylib" libs/macos-arm64/libglfw.3.dylib
40-
install_name_tool -id @rpath/libglfw.3.dylib libs/macos-arm64/libglfw.3.dylib
41-
42-
cp "$X64_PREFIX/lib/libglfw.3.dylib" libs/macos-x64/libglfw.3.dylib
43-
install_name_tool -id @rpath/libglfw.3.dylib libs/macos-x64/libglfw.3.dylib
44-
19+
cp $(brew --prefix glfw)/lib/libglfw.3.dylib libs/macos-arm64/
4520
# GLEW
46-
GLEW_ARM=$(ls "$ARM_PREFIX/lib/libGLEW".*.dylib | head -1)
47-
GLEW_X64=$(ls "$X64_PREFIX/lib/libGLEW".*.dylib | head -1)
48-
GLEW_BASE=$(basename "$GLEW_ARM")
49-
50-
cp "$GLEW_ARM" libs/macos-arm64/$GLEW_BASE
51-
install_name_tool -id @rpath/$GLEW_BASE libs/macos-arm64/$GLEW_BASE
52-
cp "$GLEW_ARM" libs/macos-arm64/libGLEW.dylib
21+
cp $(brew --prefix glew)/lib/libGLEW.dylib libs/macos-arm64/
22+
# Fix install names so the binary finds them via @rpath
23+
install_name_tool -id @rpath/libglfw.3.dylib libs/macos-arm64/libglfw.3.dylib
5324
install_name_tool -id @rpath/libGLEW.dylib libs/macos-arm64/libGLEW.dylib
54-
55-
cp "$GLEW_X64" libs/macos-x64/$GLEW_BASE
56-
install_name_tool -id @rpath/$GLEW_BASE libs/macos-x64/$GLEW_BASE
57-
cp "$GLEW_X64" libs/macos-x64/libGLEW.dylib
58-
install_name_tool -id @rpath/libGLEW.dylib libs/macos-x64/libGLEW.dylib
59-
60-
echo "=== arm64 ==="
25+
ls -la libs/macos-arm64/
6126
file libs/macos-arm64/*.dylib
62-
echo "=== x64 ==="
63-
file libs/macos-x64/*.dylib
6427
65-
- name: Commit to repo
28+
- name: Also build x64 slice (lipo from universal if available)
6629
run: |
67-
git config user.name "github-actions[bot]"
68-
git config user.email "github-actions[bot]@users.noreply.github.com"
69-
git add libs/macos-arm64/ libs/macos-x64/
70-
git diff --staged --quiet || git commit -m "ci: update bundled macOS arm64+x64 GLFW+GLEW dylibs"
71-
git push
30+
mkdir -p libs/macos-x64
31+
# GitHub's macos-latest runners are arm64; extract x86_64 slice if universal
32+
for f in libs/macos-arm64/*.dylib; do
33+
name=$(basename $f)
34+
if lipo -info $f 2>/dev/null | grep -q x86_64; then
35+
lipo $f -thin x86_64 -output libs/macos-x64/$name
36+
else
37+
# arm64 only -- copy as-is for now, x64 users need Homebrew
38+
cp $f libs/macos-x64/$name
39+
fi
40+
done
41+
ls -la libs/macos-x64/
42+
file libs/macos-x64/*.dylib
43+
44+
- name: Upload as artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: macos-dylibs
48+
path: |
49+
libs/macos-arm64/
50+
libs/macos-x64/
51+
retention-days: 30

0 commit comments

Comments
 (0)