From 2edc843c8694ad906bf4c6f40c41c7c91b871520 Mon Sep 17 00:00:00 2001 From: ascjones Date: Fri, 12 Aug 2022 16:35:51 +0100 Subject: [PATCH] Install required toolchain --- build.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 109150998..783b3e921 100644 --- a/build.rs +++ b/build.rs @@ -165,6 +165,34 @@ fn build_and_zip_dylint_driver( out_dir: PathBuf, dylint_driver_dst_file: PathBuf, ) -> Result<()> { + const NIGHTLY_TOOLCHAIN: &str = "nightly-2022-06-30"; + + let mut install_toolchain = Command::new("rustup"); + install_toolchain + .args(vec![ + "toolchain", + "install", + NIGHTLY_TOOLCHAIN, + "--component", + "llvm-tools-preview", + "rustc-dev", + ]); + + let child = install_toolchain + // Capture the stdout to return from this function as bytes + .stdout(std::process::Stdio::piped()) + .spawn()?; + + let output = child.wait_with_output()?; + + if !output.status.success() { + anyhow::bail!( + "`{:?}` failed with exit code: {:?}", + install_toolchain, + output.status.code() + ); + } + let mut cmd = Command::new("rustup"); let manifest_arg = format!( @@ -174,7 +202,7 @@ fn build_and_zip_dylint_driver( let target_dir = format!("--target-dir={}", out_dir.display()); cmd.args(vec![ "run", - "nightly-2022-06-30", + NIGHTLY_TOOLCHAIN, "cargo", "build", "--release",