mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xtask: add simple check for toolchain
This adds a simple check for the proper Rust toolchain. A more advance test will advise on toolchain installation. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
66a68f1757
commit
05801f3f06
1 changed files with 38 additions and 1 deletions
|
|
@ -224,7 +224,12 @@ Please refer to tools/README_UPDATE.md for instructions on how to set up `usb_up
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_usb(do_kernel: bool, do_loader: bool, nuke_soc: bool, stage_soc: bool) -> Result<(), DynError> {
|
fn update_usb(
|
||||||
|
do_kernel: bool,
|
||||||
|
do_loader: bool,
|
||||||
|
nuke_soc: bool,
|
||||||
|
stage_soc: bool,
|
||||||
|
) -> Result<(), DynError> {
|
||||||
use std::io::{BufRead, BufReader, Error, ErrorKind};
|
use std::io::{BufRead, BufReader, Error, ErrorKind};
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
|
|
@ -534,6 +539,37 @@ fn build_kernel(debug: bool) -> Result<PathBuf, DynError> {
|
||||||
Ok(path)
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DONE_COMPILER_CHECK: std::sync::atomic::AtomicBool =
|
||||||
|
std::sync::atomic::AtomicBool::new(false);
|
||||||
|
fn ensure_compiler(target: &Option<&str>) -> Result<(), String> {
|
||||||
|
use std::process::Stdio;
|
||||||
|
if DONE_COMPILER_CHECK.load(std::sync::atomic::Ordering::SeqCst) {
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
|
let target = target.unwrap_or(PROGRAM_TARGET).to_owned();
|
||||||
|
let have_toolchain = Command::new("rustc")
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.args(&[
|
||||||
|
"--target",
|
||||||
|
&target,
|
||||||
|
"--print",
|
||||||
|
"sysroot",
|
||||||
|
])
|
||||||
|
.spawn()
|
||||||
|
.unwrap()
|
||||||
|
.wait()
|
||||||
|
.unwrap()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
DONE_COMPILER_CHECK.store(have_toolchain, std::sync::atomic::Ordering::SeqCst);
|
||||||
|
if have_toolchain {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(format!("Toolchain for {} not found", target))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn build(
|
fn build(
|
||||||
packages: &[&str],
|
packages: &[&str],
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
|
@ -541,6 +577,7 @@ fn build(
|
||||||
directory: Option<PathBuf>,
|
directory: Option<PathBuf>,
|
||||||
extra_args: Option<&[&str]>,
|
extra_args: Option<&[&str]>,
|
||||||
) -> Result<PathBuf, DynError> {
|
) -> Result<PathBuf, DynError> {
|
||||||
|
ensure_compiler(&target)?;
|
||||||
let stream = if debug { "debug" } else { "release" };
|
let stream = if debug { "debug" } else { "release" };
|
||||||
let mut args = vec!["build"];
|
let mut args = vec!["build"];
|
||||||
print!("Building");
|
print!("Building");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue