Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'xtask/src/util.rs')
| -rw-r--r-- | xtask/src/util.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/xtask/src/util.rs b/xtask/src/util.rs index 39f52938c8..e5404d5717 100644 --- a/xtask/src/util.rs +++ b/xtask/src/util.rs @@ -1,5 +1,7 @@ use std::path::{Path, PathBuf}; +use xshell::{Shell, cmd}; + pub(crate) fn list_rust_files(dir: &Path) -> Vec<PathBuf> { let mut res = list_files(dir); res.retain(|it| { @@ -29,3 +31,13 @@ pub(crate) fn list_files(dir: &Path) -> Vec<PathBuf> { } res } + +pub(crate) fn detect_target(sh: &Shell) -> String { + match std::env::var("RA_TARGET") { + Ok(target) => target, + _ => match cmd!(sh, "rustc --print=host-tuple").read() { + Ok(target) => target, + Err(e) => panic!("Failed to detect target: {e}\nPlease set RA_TARGET explicitly"), + }, + } +} |