Skip to content

Commit 38398b6

Browse files
authored
Merge pull request #542 from zeromq/macos-arm
2 parents e450c46 + 1cfccdb commit 38398b6

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

.github/workflows/CI.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ jobs:
106106
architecture: ${{ matrix.node_arch }}
107107
cache: "pnpm"
108108

109-
- name: Install Mac-OS Dependencies
110-
if: contains(matrix.os, 'macos')
109+
- name: Install Mac-OS x86_64 Dependencies
110+
if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'x86_64' }}
111111
run: |
112112
brew install libsodium gnutls
113113
114+
- name: Install Mac-OS arm64 Dependencies
115+
if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'arm64' }}
116+
run: |
117+
brew uninstall libsodium --force --ignore-dependencies
118+
source ./script/macos-arm-deps.sh
119+
echo "PATH=$PATH" >> $GITHUB_ENV
120+
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
121+
echo "npm_config_target_arch=$npm_config_target_arch" >> $GITHUB_ENV
122+
114123
- name: Install Dependencies and Build
115124
if: ${{ !matrix.docker }}
116125
run: pnpm install

script/macos-arm-deps.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
set -e
3+
4+
#! Install arm-brew on x86 MacOS Arm
5+
#! Based on https://github.com/Homebrew/discussions/discussions/2843#discussioncomment-2243610
6+
7+
bottle_tag="arm64_big_sur" # Macos 11 is big sure
8+
dependencies="libsodium"
9+
10+
mkdir -p ~/arm-target/bin
11+
mkdir -p ~/arm-target/brew-cache
12+
export PATH="$HOME/arm-target/bin:$PATH"
13+
14+
# Download Homebrew under ~/arm-target
15+
PREV_PWD="$PWD"
16+
cd ~/arm-target
17+
mkdir -p arm-homebrew
18+
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C arm-homebrew
19+
cd "$PREV_PWD"
20+
21+
# Add arm-brew binary
22+
ln -sf ~/arm-target/arm-homebrew/bin/brew ~/arm-target/bin/arm-brew
23+
24+
# Homebrew env variables
25+
export HOMEBREW_CACHE=~/arm-target/brew-cache
26+
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
27+
28+
# Install the given dependencies for the given bottle_tag
29+
arm-brew fetch --deps --bottle-tag=$bottle_tag $dependencies |
30+
grep -E "(Downloaded to:|Already downloaded:)" |
31+
grep -E ".tar.gz" |
32+
grep -v pkg-config |
33+
awk '{ print $3 }' |
34+
xargs -n 1 arm-brew install --force-bottle || true
35+
36+
# Install host version of pkg-config so we can call it in the build system
37+
arm-brew install pkg-config || true
38+
39+
# Add the installed binaries/libraries to the path
40+
export PATH="$HOME/arm-target/bin/:$PATH"
41+
export PATH="$HOME/arm-target/lib/:$PATH"
42+
43+
# libsodium
44+
SODIUM_PATH=$(~/arm-target/bin/pkg-config libsodium --libs-only-L | sed -e 's/-L//g') # print only -L and replace "-L" itself
45+
export PATH="$SODIUM_PATH:$PATH"
46+
export PKG_CONFIG_PATH="$SODIUM_PATH:$PKG_CONFIG_PATH"
47+
export npm_config_target_arch=arm64

0 commit comments

Comments
 (0)