From fda89225e59bad4e732631e6dd7ce5fe843c968a Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 17 Jun 2024 12:50:33 -0400 Subject: [PATCH 1/3] feat(NODE-6226): build macos universal binary --- .github/scripts/libmongocrypt.mjs | 13 +++++++++++-- .github/workflows/build.yml | 2 +- binding.gyp | 10 +++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/scripts/libmongocrypt.mjs b/.github/scripts/libmongocrypt.mjs index f07dea3..89e9ff3 100644 --- a/.github/scripts/libmongocrypt.mjs +++ b/.github/scripts/libmongocrypt.mjs @@ -41,7 +41,8 @@ async function parseArguments() { return { libmongocrypt: { url: args.values.gitURL, ref: args.values.libVersion }, clean: args.values.clean, - build: args.values.build + build: args.values.build, + pkg }; } @@ -189,7 +190,7 @@ export async function downloadLibMongoCrypt(nodeDepsRoot, { ref }) { } async function main() { - const { libmongocrypt, build, clean } = await parseArguments(); + const { libmongocrypt, build, clean, pkg } = await parseArguments(); const nodeDepsDir = resolveRoot('deps'); @@ -228,6 +229,14 @@ async function main() { // The prebuild command will make both a .node file in `./build` (local and CI testing will run on current code) // it will also produce `./prebuilds/mongodb-client-encryption-vVERSION-napi-vNAPI_VERSION-OS-ARCH.tar.gz`. await run('npm', ['run', 'prebuild']); + + if (process.platform === 'darwin') { + // The "arm64" build is actually a universal binary + await fs.copyFile( + `prebuilds/mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`, + `prebuilds/mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz` + ); + } } await main(); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93b8df9..a4c3421 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: host_builds: strategy: matrix: - os: [macos-11, macos-latest, windows-2019] + os: [macos-latest, windows-2019] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/binding.gyp b/binding.gyp index d789780..aeb631f 100644 --- a/binding.gyp +++ b/binding.gyp @@ -23,7 +23,15 @@ 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 'CLANG_CXX_LIBRARY': 'libc++', - 'MACOSX_DEPLOYMENT_TARGET': '10.12' + 'MACOSX_DEPLOYMENT_TARGET': '10.12', + "OTHER_CFLAGS": [ + "-arch x86_64", + "-arch arm64" + ], + "OTHER_LDFLAGS": [ + "-arch x86_64", + "-arch arm64" + ] }, 'cflags!': [ '-fno-exceptions' ], 'cflags_cc!': [ '-fno-exceptions' ], From 978bee8616aa3597dbfd9613cd434e40f9bf0716 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 17 Jun 2024 13:03:24 -0400 Subject: [PATCH 2/3] chore: add platform list to readme --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 61844ac..50f51ca 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,21 @@ Run the following command to build libmongocrypt and setup the node bindings for bash ./etc/build-static.sh ``` +#### Prebuild Platforms + +Below are the platforms that are available as prebuilds on each github release. +`prebuild-install` downloads these automatically depending on the platform you are running npm install on. + +- Linux GLIBC 2.23 or later + - s390x + - arm64 + - x64 +- MacOS universal binary + - x64 + - arm64 +- Windows + - x64 + #### Linting We lint both the c++ bindings and the Typescript. From 01f410e6ca08180a176a4bdfa660859ec1a5e15f Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Mon, 17 Jun 2024 14:12:48 -0400 Subject: [PATCH 3/3] chore: make script runnable from anywhere --- .github/scripts/libmongocrypt.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/libmongocrypt.mjs b/.github/scripts/libmongocrypt.mjs index 89e9ff3..7299ac1 100644 --- a/.github/scripts/libmongocrypt.mjs +++ b/.github/scripts/libmongocrypt.mjs @@ -233,8 +233,8 @@ async function main() { if (process.platform === 'darwin') { // The "arm64" build is actually a universal binary await fs.copyFile( - `prebuilds/mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`, - `prebuilds/mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz` + resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`), + resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`) ); } }