Skip to content

Commit

Permalink
Fix rebuild of sqlite on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Mar 11, 2022
1 parent 236b081 commit 5cf60d4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const npmEnvs = {
system: process.env,
electron: Object.assign({}, process.env, {
npm_config_target: npmElectronTarget,
npm_config_arch: process.arch,
npm_config_target_arch: process.arch,
npm_config_arch: process.platform === 'win32' ? 'ia32' : process.arch,
npm_config_target_arch: process.platform === 'win32' ? 'ia32' : process.arch,
npm_config_disturl: 'https://atom.io/download/electron',
npm_config_runtime: 'electron',
npm_config_build_from_source: true,
Expand All @@ -35,8 +35,8 @@ function npm(cmd, options) {
cwd: path.resolve(__dirname, '..', cwd),
env: npmEnvs[env],
},
err => {
return err ? reject(err) : resolve(null);
(err, stdout) => {
return err ? reject(err) : resolve(stdout);
}
);
});
Expand Down Expand Up @@ -145,14 +145,23 @@ async function run() {
rimraf.sync(path.join(appModulesPath, 'better-sqlite3'));
// install the module pointing to our local sqlite source with custom #DEFINEs set
const amalgamationPath = path.join(appPath, 'build', 'sqlite-amalgamation');
await npm(
const resp = await npm(
`install better-sqlite3@${appDependencies['better-sqlite3']} ` +
`--no-save --no-audit --build-from-source --sqlite3="${amalgamationPath}"`,
{ cwd: './app', env: 'electron' }
);
console.log(`better-sqlite stdout: ${resp}`);

// remove the build symlinks so that we can build an installer for the app without
// symlinks out to the sqlite-amalgamation directory.
rimraf.sync(path.join(appModulesPath, 'better-sqlite3', 'build', 'Release', 'obj'));

if (!fs.existsSync(path.join(appModulesPath, 'better-sqlite3', 'build', 'Release'))) {
console.error(`better-sqlite did not recompile successfully!`);
process.exit(1001);
} else {
console.error(`better-sqlite recompiled successfully!`);
}
}

// if SQlite was STILL not built with HAVE_USLEEP, do not ship this build! We need usleep
Expand Down

0 comments on commit 5cf60d4

Please sign in to comment.