Skip to content

Commit

Permalink
feat(NODE-6226): build macos universal binary (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken authored and baileympearson committed Jun 20, 2024
1 parent f38f4cc commit e79d0b9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .github/scripts/libmongocrypt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}

Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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(
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`)
);
}
}

await main();
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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' ],
Expand Down

0 comments on commit e79d0b9

Please sign in to comment.