From 3b642389f2ca3f7093ee694a0256e423780e82d7 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 11:01:34 +0000 Subject: [PATCH 1/5] First attempt at 32 bit windows building --- scripts/hak/hakEnv.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/hak/hakEnv.js b/scripts/hak/hakEnv.js index 6752d55..265a41d 100644 --- a/scripts/hak/hakEnv.js +++ b/scripts/hak/hakEnv.js @@ -42,6 +42,17 @@ function getTarget(packageJson) { } } +function detectArch() { + if (process.platform === 'win32') { + 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 +61,7 @@ module.exports = class HakEnv { runtime: getRuntime(packageJson), target: getTarget(packageJson), platform: process.platform, - arch: process.arch, + arch: detectArch(), // paths projectRoot: prefix, From 69a30fb9d071ed1b1674ef8cb544d0d201fb5ae0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 11:05:32 +0000 Subject: [PATCH 2/5] also check for patch --- hak/matrix-seshat/check.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index 6a65970..d538bac 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -37,6 +37,7 @@ module.exports = async function(hakEnv, moduleInfo) { const tools = []; 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']); From 84aa8c10c11d30006439eeec9768a7e5a0344f92 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 18 Feb 2020 11:37:27 +0000 Subject: [PATCH 3/5] Set rust toolchain appropriately --- hak/matrix-seshat/build.js | 6 ++++++ 1 file changed, 6 insertions(+) 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); From dfef609a3f97976cf32605f7d3d133375b7bbcd0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 19 Feb 2020 10:03:36 +0000 Subject: [PATCH 4/5] We need python too --- hak/matrix-seshat/check.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index d538bac..d501349 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -34,7 +34,7 @@ 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 From 7b8ae7803809fe3bfd9b4918e18a4cb4c79fa241 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 19 Feb 2020 10:07:02 +0000 Subject: [PATCH 5/5] More comment --- scripts/hak/hakEnv.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/hak/hakEnv.js b/scripts/hak/hakEnv.js index 265a41d..22b915a 100644 --- a/scripts/hak/hakEnv.js +++ b/scripts/hak/hakEnv.js @@ -44,6 +44,10 @@ 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';