Support SDKROOT env var on iOS
Following what clang does (296a80102a/clang/lib/Driver/ToolChains/Darwin.cpp (L1661-L1678)), allow allow SDKROOT to tell us where the Apple SDK lives so we don't have to invoke xcrun.
This commit is contained in:
parent
4b65a86eba
commit
ccb5d0a7c1
1 changed files with 7 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::env;
|
||||
use std::io;
|
||||
use std::process::Command;
|
||||
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
|
||||
|
|
@ -27,6 +28,12 @@ impl Arch {
|
|||
}
|
||||
|
||||
pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
|
||||
if let Some(sdkroot) = env::var("SDKROOT").ok() {
|
||||
let sdkroot_path = Path::new(sdkroot);
|
||||
if sdkroot_path.is_absolute() && sdkroot_path != Path::new("/") && sdkroot_path.exists() {
|
||||
return Ok(sdkroot);
|
||||
}
|
||||
}
|
||||
let res = Command::new("xcrun")
|
||||
.arg("--show-sdk-path")
|
||||
.arg("-sdk")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue