Skip to content

Commit a044ccd

Browse files
authored
feat(NODE-6226): build macos universal binary (#21)
1 parent 563154c commit a044ccd

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

Diff for: .github/scripts/libmongocrypt.mjs

+11-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ async function parseArguments() {
4141
return {
4242
libmongocrypt: { url: args.values.gitURL, ref: args.values.libVersion },
4343
clean: args.values.clean,
44-
build: args.values.build
44+
build: args.values.build,
45+
pkg
4546
};
4647
}
4748

@@ -189,7 +190,7 @@ export async function downloadLibMongoCrypt(nodeDepsRoot, { ref }) {
189190
}
190191

191192
async function main() {
192-
const { libmongocrypt, build, clean } = await parseArguments();
193+
const { libmongocrypt, build, clean, pkg } = await parseArguments();
193194

194195
const nodeDepsDir = resolveRoot('deps');
195196

@@ -228,6 +229,14 @@ async function main() {
228229
// The prebuild command will make both a .node file in `./build` (local and CI testing will run on current code)
229230
// it will also produce `./prebuilds/mongodb-client-encryption-vVERSION-napi-vNAPI_VERSION-OS-ARCH.tar.gz`.
230231
await run('npm', ['run', 'prebuild']);
232+
233+
if (process.platform === 'darwin') {
234+
// The "arm64" build is actually a universal binary
235+
await fs.copyFile(
236+
resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`),
237+
resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`)
238+
);
239+
}
231240
}
232241

233242
await main();

Diff for: .github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
host_builds:
1717
strategy:
1818
matrix:
19-
os: [macos-11, macos-latest, windows-2019]
19+
os: [macos-latest, windows-2019]
2020
runs-on: ${{ matrix.os }}
2121
steps:
2222
- uses: actions/checkout@v4

Diff for: README.md

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ Run the following command to build libmongocrypt and setup the node bindings for
3333
bash ./etc/build-static.sh
3434
```
3535

36+
#### Prebuild Platforms
37+
38+
Below are the platforms that are available as prebuilds on each github release.
39+
`prebuild-install` downloads these automatically depending on the platform you are running npm install on.
40+
41+
- Linux GLIBC 2.23 or later
42+
- s390x
43+
- arm64
44+
- x64
45+
- MacOS universal binary
46+
- x64
47+
- arm64
48+
- Windows
49+
- x64
50+
3651
#### Linting
3752

3853
We lint both the c++ bindings and the Typescript.

Diff for: binding.gyp

+9-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
'xcode_settings': {
2424
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
2525
'CLANG_CXX_LIBRARY': 'libc++',
26-
'MACOSX_DEPLOYMENT_TARGET': '10.12'
26+
'MACOSX_DEPLOYMENT_TARGET': '10.12',
27+
"OTHER_CFLAGS": [
28+
"-arch x86_64",
29+
"-arch arm64"
30+
],
31+
"OTHER_LDFLAGS": [
32+
"-arch x86_64",
33+
"-arch arm64"
34+
]
2735
},
2836
'cflags!': [ '-fno-exceptions' ],
2937
'cflags_cc!': [ '-fno-exceptions' ],

0 commit comments

Comments
 (0)