Skip to content

Commit 38fd07f

Browse files
committed
fix: add mac build
1 parent 77938d7 commit 38fd07f

File tree

3 files changed

+71
-7
lines changed

3 files changed

+71
-7
lines changed

.github/workflows/cmake-multiple-platform.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ jobs:
6464
arch: x86_64
6565
container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
6666
setup_env: gcc14
67+
- os: macos-latest
68+
platform: osx-arm64
69+
arch: arm64
70+
container: null
71+
setup_env: clang
6772
runs-on: ${{ matrix.os }}
6873
container: ${{ matrix.container }}
6974
steps:
@@ -88,8 +93,16 @@ jobs:
8893
ln -sf /usr/bin/gcc-14 /usr/bin/gcc && ln -sf /usr/bin/g++-14 /usr/bin/g++
8994
# for ACT add nodejs
9095

96+
# macOS-specific setup
97+
- name: Setup macOS build environment
98+
if: matrix.setup_env == 'clang'
99+
shell: bash -el {0}
100+
run: |
101+
# Install ninja via homebrew if not present
102+
brew list ninja &>/dev/null || brew install ninja
103+
91104
- name: Setup CMake
92-
if: matrix.setup_env == 'msvc'
105+
if: matrix.setup_env == 'msvc' || matrix.setup_env == 'clang'
93106
uses: lukka/get-cmake@latest
94107

95108
- name: Cache build dependencies
@@ -145,6 +158,8 @@ jobs:
145158
platform: win-64
146159
- os: ubuntu-latest
147160
platform: linux-64
161+
- os: macos-latest
162+
platform: osx-arm64
148163
runs-on: ${{ matrix.os }}
149164
outputs:
150165
url: ${{ steps.release.outputs.url }}
@@ -185,8 +200,8 @@ jobs:
185200
version="${version#v}" # Remove leading 'v'
186201
sed "s/REPLACE_VERSION/$version/g" "conda/meta.yaml.example" > "conda/meta.yaml"
187202
188-
# Ensure build.sh is executable on Linux
189-
if [[ "$RUNNER_OS" == "Linux" ]]; then
203+
# Ensure build.sh is executable on Unix systems
204+
if [[ "$RUNNER_OS" == "Linux" ]] || [[ "$RUNNER_OS" == "macOS" ]]; then
190205
chmod +x "conda/build.sh"
191206
fi
192207
@@ -266,18 +281,20 @@ jobs:
266281
env:
267282
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
268283
run: |
269-
mkdir -p build/repo/{linux-64,win-64,noarch}
284+
mkdir -p build/repo/{linux-64,win-64,osx-arm64,noarch}
270285
gh api /repos/${{ github.repository }}/releases?per_page=10 \
271286
| jq -r '.[] | .assets[] | .browser_download_url' \
272287
| grep -E "(\.tar\.bz2|\.conda)$" > urls.txt
273288
274289
# separate by platform
275290
grep linux-64 urls.txt > linux.txt || true
276291
grep win-64 urls.txt > win.txt || true
292+
grep osx-arm64 urls.txt > osx.txt || true
277293
grep -v -E "(linux-64|win-64)" urls.txt > noarch.txt || true
278294

279295
[ -s linux.txt ] && aria2c -x4 -s4 -j4 -i linux.txt -d build/repo/linux-64/ --continue
280296
[ -s win.txt ] && aria2c -x4 -s4 -j4 -i win.txt -d build/repo/win-64/ --continue
297+
[ -s osx.txt ] && aria2c -x4 -s4 -j4 -i osx.txt -d build/repo/osx-arm64/ --continue
281298
[ -s noarch.txt ]&& aria2c -x4 -s4 -j4 -i noarch.txt -d build/repo/noarch/ --continue
282299

283300
- name: Download conda packages
@@ -354,6 +371,7 @@ jobs:
354371
<div class="platforms">
355372
<a href="linux-64/" class="platform-link">🐧 Linux (64-bit)</a>
356373
<a href="win-64/" class="platform-link">🪟 Windows (64-bit)</a>
374+
<a href="osx-arm64/" class="platform-link">🍎 macOS (ARM64)</a>
357375
<a href="noarch/" class="platform-link">📦 NoArch</a>
358376
</div>
359377
</div>

conda/build.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
#!/bin/bash
2-
# build.sh - For Linux builds
2+
# build.sh - For Unix builds
33

44
set -ex
55

6+
# Detect the platform and set the appropriate library extension
7+
if [[ "$OSTYPE" == "darwin"* ]]; then
8+
LIB_EXT="dylib"
9+
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
10+
LIB_EXT="so"
11+
else
12+
echo "Unsupported platform: $OSTYPE"
13+
exit 1
14+
fi
15+
616
# Create the target directories
717
mkdir -p $PREFIX/bin
818
mkdir -p $PREFIX/lib
919
mkdir -p $PREFIX/python3.12
1020
mkdir -p $PREFIX
1121

1222
# Copy the shared library and module file
13-
cp bin/libplugify-module-python3.so $PREFIX/bin/
23+
cp bin/libplugify-module-python3.$LIB_EXT $PREFIX/bin/
1424
cp -r lib/* $PREFIX/lib/
1525
cp -r python3.12/* $PREFIX/python3.12/
1626
cp plugify-module-python3.pmodule $PREFIX/
1727

1828
# Set proper permissions
19-
chmod 755 $PREFIX/bin/libplugify-module-python3.so
29+
chmod 755 $PREFIX/bin/libplugify-module-python3.$LIB_EXT
2030
chmod -R 755 $PREFIX/lib
2131
chmod -R 755 $PREFIX/python3.12
2232
chmod 644 $PREFIX/plugify-module-python3.pmodule

conda/meta.yaml.example

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,53 @@ build:
2222
- "*/libpython3.12.so*" # [linux]
2323
- "*/plugify.dll" # [win]
2424
- "*/python312.dll" # [win]
25+
26+
# Linux system libraries
27+
- "*/ld-linux*.so.*" # [linux]
28+
- "*/libc.so.*" # [linux]
29+
- "*/libm.so.*" # [linux]
30+
- "*/libdl.so.*" # [linux]
31+
- "*/libpthread.so.*" # [linux]
32+
- "*/librt.so.*" # [linux]
33+
- "*/libplugify.so*" # [linux]
34+
- "*/libpython3.12.so*" # [linux]
35+
# macOS system libraries and frameworks
36+
- "/usr/lib/libc++.1.dylib" # [osx]
37+
- "/usr/lib/libSystem.B.dylib" # [osx]
38+
- "/usr/lib/libc++abi.dylib" # [osx]
39+
- "/usr/lib/libutil.dylib" # [osx]
40+
- "/System/Library/Frameworks/*" # [osx]
41+
- "*/libplugify.dylib" # [osx]
42+
- "*/libplugify.*.dylib" # [osx]
43+
- "@rpath/libplugify.dylib" # [osx]
44+
- "@loader_path/libplugify.dylib" # [osx]
45+
- "*/libpython3.12.dylib" # [osx]
46+
- "*/libpython3.12.*.dylib" # [osx]
47+
- "@rpath/libpython3.12.dylib" # [osx]
48+
- "@loader_path/libpython3.12.dylib" # [osx]
49+
# Windows libraries
50+
- "*/plugify.dll" # [win]
51+
- "*/python312.dll" # [win]
2552

2653
requirements:
2754
run:
2855
- __glibc >=2.17 # [linux64]
56+
- __osx >=11.0 # [osx and arm64]
2957

3058
test:
3159
commands:
60+
# Linux tests
3261
- test -f $PREFIX/bin/libplugify-module-python3.so # [linux]
3362
- test -d $PREFIX/lib # [linux]
3463
- test -d $PREFIX/python3.12 # [linux]
3564
- test -f $PREFIX/plugify-module-python3.pmodule # [linux]
65+
# macOS tests
66+
- test -f $PREFIX/bin/libplugify-module-python3.dylib # [osx]
67+
- test -d $PREFIX/lib # [osx]
68+
- test -d $PREFIX/python3.12 # [osx]
69+
- test -f $PREFIX/plugify-module-python3.pmodule # [osx]
70+
- otool -L $PREFIX/bin/libplugify-module-python3.dylib # [osx]
71+
# Windows tests
3672
- if not exist %PREFIX%\\bin\\plugify-module-python3.dll exit 1 # [win]
3773
- if not exist %PREFIX%\\lib exit 1 # [win]
3874
- if not exist %PREFIX%\\python3.12 exit 1 # [win]

0 commit comments

Comments
 (0)