Merge pull request #23 from vector-im/dbkr/hak_win_x86

Build on 32 bit Windows
This commit is contained in:
David Baker 2020-02-19 10:16:51 +00:00 committed by GitHub
commit 050501b322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -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);

View File

@ -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']);

View File

@ -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,