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:
Scott Wolchok 2019-07-16 13:29:40 -07:00
parent 4b65a86eba
commit ccb5d0a7c1

View file

@ -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")