Skip to content

Commit 0f020b6

Browse files
committed
chore: fix build_type
1 parent cca70dc commit 0f020b6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

.github/scripts/libmongocrypt.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function parseArguments() {
2626
'no-macos-universal': { type: 'boolean', default: false },
2727
clean: { short: 'c', type: 'boolean', default: false },
2828
build: { short: 'b', type: 'boolean', default: false },
29+
dynamic: { type: 'boolean', default: false },
2930
fastDownload: { type: 'boolean', default: false }, // Potentially incorrect download, only for the brave and impatient
3031
help: { short: 'h', type: 'boolean', default: false }
3132
};
@@ -48,6 +49,7 @@ async function parseArguments() {
4849
fastDownload: args.values.fastDownload,
4950
clean: args.values.clean,
5051
build: args.values.build,
52+
dynamic: args.values.dynamic,
5153
noMacosUniversal: args.values['no-macos-universal'],
5254
pkg
5355
};
@@ -237,7 +239,7 @@ async function main() {
237239

238240
const nodeDepsDir = resolveRoot('deps');
239241

240-
if (args.build) {
242+
if (args.build && !args.dynamic) {
241243
const libmongocryptCloneDir = resolveRoot('_libmongocrypt');
242244

243245
const currentLibMongoCryptBranch = await fs
@@ -257,7 +259,7 @@ async function main() {
257259
if (args.clean || !isBuilt) {
258260
await buildLibMongoCrypt(libmongocryptCloneDir, nodeDepsDir);
259261
}
260-
} else {
262+
} else if (!args.dynamic) {
261263
// Download
262264
await downloadLibMongoCrypt(nodeDepsDir, args);
263265
}
@@ -269,10 +271,17 @@ async function main() {
269271
await run('npm', ['install', '--ignore-scripts']);
270272
// The prebuild command will make both a .node file in `./build` (local and CI testing will run on current code)
271273
// it will also produce `./prebuilds/mongodb-client-encryption-vVERSION-napi-vNAPI_VERSION-OS-ARCH.tar.gz`.
272-
const prebuildOptions =
273-
process.platform === 'darwin' && args.noMacosUniversal
274-
? { env: { ...process.env, GYP_DEFINES: 'no_macos_universal=true' } }
275-
: undefined;
274+
let prebuildOptions;
275+
if (process.platform === 'darwin' && args.noMacosUniversal) {
276+
prebuildOptions ??= { env: { ...process.env } };
277+
prebuildOptions.env.GYP_DEFINES = (prebuildOptions.env.GYP_DEFINES ?? '') + 'no_macos_universal=true '
278+
}
279+
280+
if (args.dynamic) {
281+
prebuildOptions ??= { env: { ...process.env } }
282+
prebuildOptions.env.GYP_DEFINES = (prebuildOptions.env.GYP_DEFINES ?? '') + 'build_type=dynamic '
283+
}
284+
276285
await run('npm', ['run', 'prebuild'], prebuildOptions);
277286
// Compile Typescript
278287
await run('npm', ['run', 'prepare']);

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Can be configured to clone and build without crypto.
4848
--clean Combined with --build, the script will not skip cloning and rebuilding libmongocrypt.
4949
--build Instead of downloading, clone and build libmongocrypt along with the bindings.
5050
--no-macos-universal Disable creating a universal binary for MacOS builds.
51+
--dynamic Skips cloning or downloading libmongocrypt, runs prebuild with build_type set to "dynamic" to compile
52+
a prebuild that links to a system copy of libmongocrypt.
5153
5254
Only suitable for local development:
5355

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'variables': {
88
'ARCH': '<(host_arch)',
99
'no_macos_universal%': 'false',
10-
'build_type%': 'dynamic',
10+
'build_type%': 'static',
1111
},
1212
'sources': [
1313
'addon/mongocrypt.cc'

0 commit comments

Comments
 (0)