diff --git a/hak/matrix-seshat/build.js b/hak/matrix-seshat/build.js index 2efe4aa..ababbd5 100644 --- a/hak/matrix-seshat/build.js +++ b/hak/matrix-seshat/build.js @@ -240,6 +240,12 @@ async function buildMatrixSeshat(hakEnv, moduleInfo) { if (hakEnv.isWin()) { env.RUSTFLAGS = '-Ctarget-feature=+crt-static -Clink-args=libcrypto.lib'; + // Note that in general, you can specify targets in Rust without having to have + // the matching toolchain, however for this, cargo gets confused when building + // the build scripts since they run on the host, but vcvarsall.bat sets the c + // compiler in the path to be the one for the target, so we just use the matching + // toolchain for the target architecture which makes everything happy. + env.RUSTUP_TOOLCHAIN = hakEnv.arch == 'x64' ? 'stable-x86_64-pc-windows-msvc' : 'stable-i686-pc-windows-msvc'; } console.log("Running neon with env", env); diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index 6a65970..d501349 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -34,9 +34,10 @@ module.exports = async function(hakEnv, moduleInfo) { }); } - const tools = []; + const tools = ['python', '--version']; // node-gyp uses python for reasons beyond comprehension if (hakEnv.isWin()) { tools.push(['perl', '--version']); // for openssl configure + tools.push(['patch', '--version']); // to patch sqlcipher Makefile.msc tools.push(['nmake', '/?']); } else { tools.push(['make', '--version']); diff --git a/scripts/hak/hakEnv.js b/scripts/hak/hakEnv.js index 6752d55..22b915a 100644 --- a/scripts/hak/hakEnv.js +++ b/scripts/hak/hakEnv.js @@ -42,6 +42,21 @@ function getTarget(packageJson) { } } +function detectArch() { + if (process.platform === 'win32') { + // vcvarsall.bat (the script that sets up the environment for + // visual studio build tools) sets an env var to tell us what + // architecture the active build tools target, so we auto-detect + // this. + const targetArch = process.env.VSCMD_ARG_TGT_ARCH; + if (targetArch === 'x86') { + return 'ia32'; + } else if (targetArch === 'x64') { + return 'x64'; + } + } + return process.arch; +} module.exports = class HakEnv { constructor(prefix, packageJson) { @@ -50,7 +65,7 @@ module.exports = class HakEnv { runtime: getRuntime(packageJson), target: getTarget(packageJson), platform: process.platform, - arch: process.arch, + arch: detectArch(), // paths projectRoot: prefix,