diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-01-21 21:01:49 +0800 |
|---|---|---|
| committer | Jieyou Xu <jieyouxu@outlook.com> | 2025-01-29 08:10:05 +0000 |
| commit | dd616d6a16288a0e8d79405650db2e68762a4367 (patch) | |
| tree | e82ef747cc8619c50c3f84e5f5d4e18a8ecf0a59 | |
| parent | ccc9ba5c30c675824e9ca62b960830ff4a1858ea (diff) | |
| download | rust-dd616d6a16288a0e8d79405650db2e68762a4367.tar.gz rust-dd616d6a16288a0e8d79405650db2e68762a4367.zip | |
run-make-support: add `sysroot` helper
Convenience helper for `rustc --print=sysroot`.
| -rw-r--r-- | src/tools/run-make-support/src/external_deps/rustc.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index 8894ea7fb20..b70db7130f6 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -1,5 +1,6 @@ use std::ffi::{OsStr, OsString}; -use std::path::Path; +use std::path::{Path, PathBuf}; +use std::str::FromStr as _; use crate::command::Command; use crate::env::env_var; @@ -390,3 +391,10 @@ impl Rustc { self } } + +/// Query the sysroot path corresponding `rustc --print=sysroot`. +#[track_caller] +pub fn sysroot() -> PathBuf { + let path = rustc().print("sysroot").run().stdout_utf8(); + PathBuf::from_str(path.trim()).unwrap() +} |
