Skip to content

Commit c89d72a

Browse files
committed
Fixed macos cross compilation
1 parent 79c27a9 commit c89d72a

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

.github/workflows/build.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
push:
1212
branches:
1313
- main
14-
- ci-build-wheel
1514
release:
1615
types:
1716
- published

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools"]
2+
requires = ["setuptools", "cffi>=1.15.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

scripts/build_libbinaryen.sh

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!/bin/bash
2+
root_path="./binaryen/libbinaryen"
3+
4+
if grep -Fxq $BINARYEN_VERSION $root_path/version; then
5+
# Existing version found
6+
echo "Found existing binaryen installation, skipping."
7+
echo "You may need to clear the binaryen/libbinaryen folder if errors occur"
8+
exit 0
9+
fi
210

311
arch=$(uname -m)
412

13+
# Set the platform = 'macos' | 'linux' | 'windows'
514
case "$(uname -sr)" in
615

716
Darwin*)
@@ -30,42 +39,44 @@ if [ -z ${BINARYEN_VERSION+x} ]; then
3039
exit 1
3140
fi
3241

33-
lib_path="./binaryen/libbinaryen/$arch-$platform"
42+
lib_path="$root_path/$arch-$platform"
3443
mkdir -p $lib_path
3544

36-
if grep -Fxq $BINARYEN_VERSION $lib_path/version; then
37-
# Existing version found
38-
echo "Found existing binaryen installation, skipping."
39-
echo "You may need to clear the binaryen/libbinaryen folder if errors occur"
40-
exit 0
41-
fi
42-
4345
wildcards="--wildcards"
4446

4547
if [[ "$platform" == "macos" ]]; then
48+
# Wildcards are supported by default on macOS
4649
wildcards=""
4750
fi
4851

4952
echo "Setting up binaryen for $arch $platform"
5053

5154
if [[ "$platform" == "macos" ]]; then
52-
echo "Building static binaryen for MacOS"
53-
mkdir -p "./binaryen/libbinaryen/src/"
55+
echo "Building static binaryen for macOS"
56+
mkdir -p "$root_path/src/"
5457

5558
file="version_$BINARYEN_VERSION.tar.gz"
5659
url="https://github.com/WebAssembly/binaryen/archive/refs/tags/$file"
5760

58-
wget -q -nc --no-check-certificate --content-disposition $url -P "./binaryen/libbinaryen"
61+
wget -q -nc --no-check-certificate --content-disposition $url -P "$root_path"
5962
echo "Downloaded source code"
6063

61-
tar -xzf "./binaryen/libbinaryen/binaryen-$file" -C "./binaryen/libbinaryen/src" --strip-components=1
64+
tar -xzf "$root_path/binaryen-$file" -C "$root_path/src" --strip-components=1
6265
echo "Extracted source code"
6366

64-
cmake -S "./binaryen/libbinaryen/src" -B "./binaryen/libbinaryen/build/" -G Ninja \
65-
-DCMAKE_INSTALL_PREFIX="$lib_path" -DCMAKE_OSX_ARCHITECTURES=$arch \
67+
echo "Building for Apple Silicon"
68+
cmake -S "$root_path/src" -B "$root_path/build/" -G Ninja \
69+
-DCMAKE_INSTALL_PREFIX=""$root_path/arm64-macos"" -DCMAKE_OSX_ARCHITECTURES="arm64" \
70+
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_TOOLS=OFF \
71+
-DBUILD_STATIC_LIB=ON
72+
cmake --build "$root_path/build/" -v --config Release --target install
73+
74+
echo "Build for Intel"
75+
cmake -S "$root_path/src" -B "$root_path/build/" -G Ninja \
76+
-DCMAKE_INSTALL_PREFIX=""$root_path/x86_64-macos"" -DCMAKE_OSX_ARCHITECTURES="x86_64" \
6677
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_TOOLS=OFF \
6778
-DBUILD_STATIC_LIB=ON
68-
cmake --build "./binaryen/libbinaryen/build/" -v --config Release --target install
79+
cmake --build "$root_path/build/" -v --config Release --target install
6980
else
7081
file="binaryen-version_$BINARYEN_VERSION-$arch-$platform.tar.gz"
7182
url="https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYEN_VERSION/$file"
@@ -84,4 +95,4 @@ echo "Generating C def file"
8495
python3 ./scripts/create_cdef.py
8596
echo "Successfully generated C def file"
8697

87-
echo "$BINARYEN_VERSION" >| $lib_path/version
98+
echo "$BINARYEN_VERSION" >| $root_path/version

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from setuptools import setup
22

33
setup(
4-
setup_requires=["cffi>=1.15.0"],
54
cffi_modules=["binaryen/binaryen_build.py:ffibuilder"],
6-
install_requires=["cffi>=1.15.0"],
75
)

0 commit comments

Comments
 (0)