Skip to content

Commit acfded4

Browse files
committed
Merge remote-tracking branch 'origin/update-electron-rebuild' into electron-32
2 parents b698978 + 83dfdba commit acfded4

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
},
141141
"scripts": {
142142
"install": "node scripts/download-fonts.js && node scripts/download-csfle.js",
143-
"electron-rebuild": "electron-rebuild --only kerberos,keytar,interruptor,os-dns-native,win-export-certificate-and-key,macos-export-certificate-and-key --prebuild-tag-prefix not-real-prefix-to-force-rebuild",
143+
"electron-rebuild": "node scripts/electron-rebuild.js",
144144
"prestart": "npm run electron-rebuild && npm run compile --workspace=@mongodb-js/webpack-config-compass",
145145
"start": "HADRON_DISTRIBUTION=${HADRON_DISTRIBUTION:-compass} npm run webpack serve -- --mode development",
146146
"test-electron": "npm run test-main && npm run test-renderer",
@@ -240,6 +240,7 @@
240240
"chalk": "^4.1.2",
241241
"clean-stack": "^2.0.0",
242242
"compass-preferences-model": "^2.29.1",
243+
"cross-spawn": "^7.0.3",
243244
"debug": "^4.3.4",
244245
"depcheck": "^1.4.1",
245246
"electron": "^32.2.1",
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
const spawn = require('cross-spawn');
3+
const path = require('path');
4+
5+
const modulesToRebuild =
6+
require('../package.json').config.hadron.rebuild.onlyModules;
7+
8+
// We only want to force rebuild on linux to make sure that the version of glibc
9+
// is matching the platform we're running this on instead of the platform the
10+
// prebuilt was generated on, for other platforms it's okay to just download the
11+
// prebuilt modules when available
12+
const forceRebuildFromSource = process.platform === 'linux';
13+
14+
/** @type {[string, string[]]} */
15+
const rebuildArgs = [
16+
'electron-rebuild',
17+
[
18+
'--only',
19+
modulesToRebuild.join(','),
20+
...(forceRebuildFromSource
21+
? [
22+
// electron-rebuild doesn't allow to force rebuild from source, but we
23+
// can force it by passing a fake tag that would not allow prebuilt to
24+
// download the asset
25+
'--prebuild-tag-prefix',
26+
'not-real-prefix-to-force-rebuild',
27+
]
28+
: []),
29+
...process.argv.slice(2),
30+
],
31+
];
32+
33+
// eslint-disable-next-line no-console
34+
console.log('> %s', rebuildArgs.flat().join(' '));
35+
36+
spawn(...rebuildArgs, {
37+
cwd: path.resolve(__dirname, '..'),
38+
stdio: 'inherit',
39+
env: process.env,
40+
});

packages/hadron-build/commands/release.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,24 @@ const installDependencies = util.callbackify(async (CONFIG) => {
384384
force: true,
385385
};
386386

387+
const forceRebuildFromSourceOptions =
388+
// We only want to force rebuild on linux to make sure that the version of
389+
// glibc is matching the platform we're running this on instead of the
390+
// platform the prebuilt was generated on, for other platforms it's okay to
391+
// just download the prebuilt modules when available
392+
process.platform === 'linux'
393+
? {
394+
// electron-rebuild doesn't allow to force rebuild from source, but we
395+
// can force it by passing a fake tag that would not allow prebuilt to
396+
// download the asset
397+
prebuildTagPrefix: 'not-real-prefix-to-force-rebuild',
398+
}
399+
: {};
400+
387401
const allModulesRebuildConfig = {
388402
...sharedRebuildConfig,
389403
...CONFIG.rebuild,
390-
// We want to ensure that we are actually rebuilding native modules on the
391-
// platform we are packaging. There is currently no direct way of passing a
392-
// --build-from-source flag to rebuild-install package, but we can force
393-
// rebuild by providing a tag prefix that will make prebuild think that
394-
// prebuilt files don't exist
395-
prebuildTagPrefix: 'totally-not-a-real-prefix-to-force-rebuild',
404+
...forceRebuildFromSourceOptions,
396405
};
397406

398407
// We can not force rebuild mongodb-client-encryption locally, but we need to

0 commit comments

Comments
 (0)