Skip to content

Commit b02e9c2

Browse files
committed
run-make-support: add sysroot helper
Convenience helper for `rustc --print=sysroot`.
1 parent 2f348cb commit b02e9c2

File tree

1 file changed

+9
-1
lines changed
  • src/tools/run-make-support/src/external_deps

1 file changed

+9
-1
lines changed

src/tools/run-make-support/src/external_deps/rustc.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::ffi::{OsStr, OsString};
2-
use std::path::Path;
2+
use std::path::{Path, PathBuf};
3+
use std::str::FromStr as _;
34

45
use crate::command::Command;
56
use crate::env::env_var;
@@ -390,3 +391,10 @@ impl Rustc {
390391
self
391392
}
392393
}
394+
395+
/// Query the sysroot path corresponding `rustc --print=sysroot`.
396+
#[track_caller]
397+
pub fn sysroot() -> PathBuf {
398+
let path = rustc().print("sysroot").run().stdout_utf8();
399+
PathBuf::from_str(path.trim()).unwrap()
400+
}

0 commit comments

Comments
 (0)