Skip to content

Commit c4be4d3

Browse files
committed
chore: allow disabling universal macos building
1 parent b769117 commit c4be4d3

File tree

3 files changed

+16
-36
lines changed

3 files changed

+16
-36
lines changed

Diff for: .github/scripts/libmongocrypt.mjs

+11-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function parseArguments() {
2323
const options = {
2424
gitURL: { short: 'u', type: 'string', default: 'https://github.com/mongodb/libmongocrypt.git' },
2525
libVersion: { short: 'l', type: 'string', default: pkg['mongodb:libmongocrypt'] },
26-
'allow-only-x64-darwin': { type: 'boolean', default: false },
26+
'no-macos-universal': { type: 'boolean', default: false },
2727
clean: { short: 'c', type: 'boolean', default: false },
2828
build: { short: 'b', type: 'boolean', default: false },
2929
fastDownload: { type: 'boolean', default: false }, // Potentially incorrect download, only for the brave and impatient
@@ -48,7 +48,7 @@ async function parseArguments() {
4848
fastDownload: args.values.fastDownload,
4949
clean: args.values.clean,
5050
build: args.values.build,
51-
allowOnlyX64Darwin: args.values['allow-only-x64-darwin'],
51+
noMacosUniversal: args.values['no-macos-universal'],
5252
pkg
5353
};
5454
}
@@ -269,31 +269,19 @@ async function main() {
269269
await run('npm', ['install', '--ignore-scripts']);
270270
// The prebuild command will make both a .node file in `./build` (local and CI testing will run on current code)
271271
// it will also produce `./prebuilds/mongodb-client-encryption-vVERSION-napi-vNAPI_VERSION-OS-ARCH.tar.gz`.
272-
await run('npm', ['run', 'prebuild']);
272+
const prebuildOptions =
273+
process.platform === 'darwin' && args.noMacosUniversal
274+
? { env: { ...process.env, GYP_DEFINES: 'no_macos_universal=true' } }
275+
: undefined;
276+
await run('npm', ['run', 'prebuild'], prebuildOptions);
273277
// Compile Typescript
274278
await run('npm', ['run', 'prepare']);
275279

276-
if (process.platform === 'darwin') {
280+
if (process.platform === 'darwin' && !args.noMacosUniversal) {
277281
// The "arm64" build is actually a universal binary
278-
try {
279-
await fs.copyFile(
280-
resolveRoot(
281-
'prebuilds',
282-
`mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`
283-
),
284-
resolveRoot(
285-
'prebuilds',
286-
`mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`
287-
)
288-
);
289-
} catch {
290-
if (process.arch === 'x64') {
291-
// The user of this script is building on an x64/intel/amd64 darwin which cannot build a universal bundle
292-
// By default we exit with failure because we do not want to release an intel only build
293-
console.error('Intel Darwin cannot build a universal bundle');
294-
process.exitCode = args.allowOnlyX64Darwin ? 0 : 1;
295-
}
296-
}
282+
const armTar = `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`;
283+
const x64Tar = `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`;
284+
await fs.copyFile(resolveRoot('prebuilds', armTar), resolveRoot('prebuilds', x64Tar));
297285
}
298286
}
299287

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Can be configured to clone and build without crypto.
4747
You may use "latest" to get current libmongocrypt `HEAD`.
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.
50+
--no-macos-universal Disable creating a universal binary for MacOS builds.
5051
5152
Only suitable for local development:
5253

Diff for: binding.gyp

+4-13
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,9 @@
55
"<!(node -p \"require('node-addon-api').include_dir\")",
66
],
77
'variables': {
8-
'ARCH': '<(host_arch)',
9-
'variables': {
10-
'build_type%': "dynamic",
11-
},
12-
'conditions': [
13-
['OS=="win"', {
14-
'build_type' : "<!(echo %BUILD_TYPE%)"
15-
}],
16-
['OS!="win"', {
17-
'build_type' : "<!(echo $BUILD_TYPE)",
18-
}]
19-
]
8+
'ARCH': '<(host_arch)',
9+
'no_macos_universal%': 'false',
10+
'build_type%': 'dynamic',
2011
},
2112
'sources': [
2213
'addon/mongocrypt.cc'
@@ -38,7 +29,7 @@
3829
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
3930
}
4031
}],
41-
['OS=="mac" and ARCH=="arm64"', {
32+
['OS=="mac" and ARCH=="arm64" and "<(no_macos_universal)"!="true"', {
4233
'xcode_settings': {
4334
"OTHER_CFLAGS": [
4435
"-arch x86_64",

0 commit comments

Comments
 (0)