From bedfb2c75a947e8486f353c016e16118f0cc2a8f Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 24 Sep 2021 21:39:28 +0200 Subject: [PATCH] [minor] Build a universal binary to support Apple M1 Fixes #135 --- .github/workflows/ci.yml | 16 +++++++++++----- binding.gyp | 7 ++++++- package.json | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 605100c..95690f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,12 +17,12 @@ jobs: - 14 - 16 os: - - macOS-latest + - macos-11 - ubuntu-18.04 - windows-latest exclude: - arch: x86 - os: macOS-latest + os: macos-11 - arch: x86 os: ubuntu-18.04 steps: @@ -34,7 +34,13 @@ jobs: - run: npm install - run: npm test - run: npm run prebuild - if: matrix.node == 14 && startsWith(github.ref, 'refs/tags/') + if: + matrix.node == 14 && matrix.os != 'macos-11' && startsWith(github.ref, + 'refs/tags/') + - run: npm run prebuild-darwin-x64+arm64 + if: + matrix.node == 14 && matrix.os == 'macos-11' && startsWith(github.ref, + 'refs/tags/') - run: npm run prebuild-linux-arm if: matrix.node == 14 && matrix.os == 'ubuntu-18.04' && @@ -57,8 +63,8 @@ jobs: - run: echo ::set-output name=version::$(git describe --tags) id: get_version - run: - tar -cvf "${{ steps.get_version.outputs.version }}-darwin-x64.tar" -C - "prebuilds/macOS-latest" . + tar -cvf "${{ steps.get_version.outputs.version + }}-darwin-x64+arm64.tar" -C "prebuilds/macos-11" . - run: tar -cvf "${{ steps.get_version.outputs.version }}-linux-arm.tar" -C "prebuilds/ubuntu-18.04" linux-arm diff --git a/binding.gyp b/binding.gyp index da5fc81..2b25e54 100644 --- a/binding.gyp +++ b/binding.gyp @@ -3,7 +3,12 @@ { 'target_name': 'bufferutil', 'sources': ['src/bufferutil.c'], - 'cflags': ['-std=c99'] + 'cflags': ['-std=c99'], + 'xcode_settings': { + 'MACOSX_DEPLOYMENT_TARGET': '10.7', + 'OTHER_CFLAGS': ['-arch x86_64', '-arch arm64'], + 'OTHER_LDFLAGS': ['-arch x86_64', '-arch arm64'] + } } ] } diff --git a/package.json b/package.json index ab977f5..bccbc9f 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "install": "node-gyp-build", "prebuild": "prebuildify --napi --strip", + "prebuild-darwin-x64+arm64": "prebuildify --arch x64+arm64 --napi --strip", "prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 -i linux-arm64 --napi --strip", "test": "mocha" },