diff --git a/Makefile b/Makefile index 3d65b230abb..cdfccce88e7 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ clean: mac-arm64: @echo "Make macOS arm64 whl" - bash packages/build_mac_arm64.sh + packages/build_mac_arm64.sh @echo "Done." build: clean buildlib wheel diff --git a/packages/build_mac_arm64.sh b/packages/build_mac_arm64.sh index afea79f44ee..1c05d65fdf5 100755 --- a/packages/build_mac_arm64.sh +++ b/packages/build_mac_arm64.sh @@ -2,6 +2,12 @@ set -e +# check current arch +if [ "$(uname -m)" != "arm64" ]; then + echo "OS not supported, run with arch -arm64 /bin/bash" + exit 1 +fi + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" PROJ_DIR=$(dirname ${DIR}) @@ -24,6 +30,27 @@ elif [ -f /usr/local/opt/llvm/bin/clang ]; then export CC=/usr/local/opt/llvm/bin/clang fi +# Download MacOSX11.0.sdk.tar.xz +if [ ! -f ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz ]; then + wget "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz" -O ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz +fi + +# Extract MacOSX11.0.sdk.tar.xz +if [ ! -f ${PROJ_DIR}/cmake/toolchain/darwin-x86_64/Entitlements.plist ]; then + tar xJf ${PROJ_DIR}/python_pkg/MacOSX11.0.sdk.tar.xz -C cmake/toolchain/darwin-x86_64 --strip-components=1 +fi + +# Fix soft link if darwin-aarch64 not linked to darwin-x86_64 +if [ -L ${PROJ_DIR}/cmake/toolchain/darwin-aarch64 ]; then + dest=$(readlink ${PROJ_DIR}/cmake/toolchain/darwin-aarch64) +fi + +if [ "${dest}" != "darwin-x86_64" ]; then + rm -f ${PROJ_DIR}/cmake/toolchain/darwin-aarch64 + ln -sf darwin-x86_64 ${PROJ_DIR}/cmake/toolchain/darwin-aarch64 +fi + + for PY_VER in 3.9.13 3.10.11 3.11.3; do if [ ! -f ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg ]; then wget https://www.python.org/ftp/python/${PY_VER}/python-${PY_VER}-macos11.pkg -O ${PROJ_DIR}/python_pkg/python-${PY_VER}-macos11.pkg