From 5bbce91e5163f1c697857f2faa66c70abb020b29 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Jul 2021 19:01:34 +0100 Subject: [PATCH 1/3] Check target with rustc directly To avoid depending on rustup (at least when not cross-compiling) --- hak/matrix-seshat/check.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index 4554f5f..5acdf89 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -15,6 +15,7 @@ limitations under the License. */ const childProcess = require('child_process'); +const fsProm = require('fs').promises; module.exports = async function(hakEnv, moduleInfo) { // of course tcl doesn't have a --version @@ -61,17 +62,15 @@ module.exports = async function(hakEnv, moduleInfo) { }); } - // Ensure Rust target exists + // Ensure Rust target exists (nb. we avoid depending on rustup) await new Promise((resolve, reject) => { - childProcess.execFile('rustup', ['target', 'list', '--installed'], (err, out) => { + const rustc = childProcess.execFile('rustc', ['--target', hakEnv.getTargetId(), '-o', 'tmp', '-'], (err, out) => { if (err) { - reject("Can't find rustup"); + reject("rustc can't build for target " + hakEnv.getTargetId() + ": ensure the correct toolchain is installed"); } - const target = hakEnv.getTargetId(); - if (!out.includes(target)) { - reject(`Rust target ${target} not installed`); - } - resolve(); + fsProm.unlink('tmp').then(resolve); }); + rustc.stdin.write('fn main() {}'); + rustc.stdin.end(); }); }; From b5725da9eae3fe7d7d2df62d15b4b4cb0ed3c8bb Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Jul 2021 19:06:58 +0100 Subject: [PATCH 2/3] lint --- hak/matrix-seshat/check.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index 5acdf89..7ccbd8f 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -64,9 +64,14 @@ module.exports = async function(hakEnv, moduleInfo) { // Ensure Rust target exists (nb. we avoid depending on rustup) await new Promise((resolve, reject) => { - const rustc = childProcess.execFile('rustc', ['--target', hakEnv.getTargetId(), '-o', 'tmp', '-'], (err, out) => { + const rustc = childProcess.execFile('rustc', [ + '--target', hakEnv.getTargetId(), '-o', 'tmp', '-', + ], (err, out) => { if (err) { - reject("rustc can't build for target " + hakEnv.getTargetId() + ": ensure the correct toolchain is installed"); + reject( + "rustc can't build for target " + hakEnv.getTargetId() + + ": ensure the correct toolchain is installed", + ); } fsProm.unlink('tmp').then(resolve); }); From 9913b0ff78ffa25feee2ae862f6a81408ff388dc Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 7 Jul 2021 10:58:54 +0100 Subject: [PATCH 3/3] Fix confused toolchain / target naming Co-authored-by: J. Ryan Stinnett --- hak/matrix-seshat/check.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hak/matrix-seshat/check.js b/hak/matrix-seshat/check.js index 7ccbd8f..b2a6afc 100644 --- a/hak/matrix-seshat/check.js +++ b/hak/matrix-seshat/check.js @@ -70,7 +70,8 @@ module.exports = async function(hakEnv, moduleInfo) { if (err) { reject( "rustc can't build for target " + hakEnv.getTargetId() + - ": ensure the correct toolchain is installed", + ": ensure target is installed via `rustup target add " + hakEnv.getTargetId() + "` " + + "or your package manager if not using `rustup`", ); } fsProm.unlink('tmp').then(resolve);