Skip to content

Commit bedfb2c

Browse files
committed
[minor] Build a universal binary to support Apple M1
Fixes #135
1 parent b40a0f2 commit bedfb2c

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- 14
1818
- 16
1919
os:
20-
- macOS-latest
20+
- macos-11
2121
- ubuntu-18.04
2222
- windows-latest
2323
exclude:
2424
- arch: x86
25-
os: macOS-latest
25+
os: macos-11
2626
- arch: x86
2727
os: ubuntu-18.04
2828
steps:
@@ -34,7 +34,13 @@ jobs:
3434
- run: npm install
3535
- run: npm test
3636
- run: npm run prebuild
37-
if: matrix.node == 14 && startsWith(github.ref, 'refs/tags/')
37+
if:
38+
matrix.node == 14 && matrix.os != 'macos-11' && startsWith(github.ref,
39+
'refs/tags/')
40+
- run: npm run prebuild-darwin-x64+arm64
41+
if:
42+
matrix.node == 14 && matrix.os == 'macos-11' && startsWith(github.ref,
43+
'refs/tags/')
3844
- run: npm run prebuild-linux-arm
3945
if:
4046
matrix.node == 14 && matrix.os == 'ubuntu-18.04' &&
@@ -57,8 +63,8 @@ jobs:
5763
- run: echo ::set-output name=version::$(git describe --tags)
5864
id: get_version
5965
- run:
60-
tar -cvf "${{ steps.get_version.outputs.version }}-darwin-x64.tar" -C
61-
"prebuilds/macOS-latest" .
66+
tar -cvf "${{ steps.get_version.outputs.version
67+
}}-darwin-x64+arm64.tar" -C "prebuilds/macos-11" .
6268
- run:
6369
tar -cvf "${{ steps.get_version.outputs.version }}-linux-arm.tar" -C
6470
"prebuilds/ubuntu-18.04" linux-arm

binding.gyp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
{
44
'target_name': 'bufferutil',
55
'sources': ['src/bufferutil.c'],
6-
'cflags': ['-std=c99']
6+
'cflags': ['-std=c99'],
7+
'xcode_settings': {
8+
'MACOSX_DEPLOYMENT_TARGET': '10.7',
9+
'OTHER_CFLAGS': ['-arch x86_64', '-arch arm64'],
10+
'OTHER_LDFLAGS': ['-arch x86_64', '-arch arm64']
11+
}
712
}
813
]
914
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"scripts": {
1010
"install": "node-gyp-build",
1111
"prebuild": "prebuildify --napi --strip",
12+
"prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip",
1213
"prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 -i linux-arm64 --napi --strip",
1314
"test": "mocha"
1415
},

0 commit comments

Comments
 (0)