Check for Rust host and target support

This commit is contained in:
J. Ryan Stinnett 2021-06-22 13:37:33 +01:00
parent 48dc1ab396
commit c57a173649
2 changed files with 23 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Copyright 2020-2021 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -34,7 +34,10 @@ module.exports = async function(hakEnv, moduleInfo) {
});
}
const tools = [['python', '--version']]; // node-gyp uses python for reasons beyond comprehension
const tools = [
['rustc', '--version'],
['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
@ -57,4 +60,18 @@ module.exports = async function(hakEnv, moduleInfo) {
});
});
}
// Ensure Rust target exists
await new Promise((resolve, reject) => {
childProcess.execFile('rustup', ['target', 'list', '--installed'], (err, out) => {
if (err) {
reject("Can't find rustup");
}
const target = hakEnv.getRustTarget();
if (!out.includes(target)) {
reject(`Rust target ${target} not installed`);
}
resolve();
});
});
};

View file

@ -80,6 +80,10 @@ module.exports = class HakEnv {
return this.getRuntimeAbi() + '-' + this.target.platform + '-' + this.target.arch;
}
getRustTarget() {
return this.target.id;
}
isWin() {
return this.target.platform === 'win32';
}