Skip to content

Commit

Permalink
Obtain deployment target consistently
Browse files Browse the repository at this point in the history
Fix the now-unified default watchOS deployment target
  • Loading branch information
BlackHoleFox committed Aug 4, 2023
1 parent cbedc33 commit 430a770
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,8 +1718,8 @@ impl Build {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
{
let deployment_target = env::var("IPHONEOS_DEPLOYMENT_TARGET")
.unwrap_or_else(|_| "7.0".into());
let deployment_target =
self.apple_deployment_version(AppleOs::Ios, target, None);
cmd.args.push(
format!(
"--target={}-apple-ios{}-simulator",
Expand All @@ -1732,8 +1732,8 @@ impl Build {
if let Some(arch) =
map_darwin_target_from_rust_to_compiler_architecture(target)
{
let deployment_target = env::var("WATCHOS_DEPLOYMENT_TARGET")
.unwrap_or_else(|_| "5.0".into());
let deployment_target =
self.apple_deployment_version(AppleOs::WatchOs, target, None);
cmd.args.push(
format!(
"--target={}-apple-watchos{}-simulator",
Expand Down Expand Up @@ -2336,7 +2336,7 @@ impl Build {
}
};

let min_version = self.apple_deployment_version(os, &target, arch_str);
let min_version = self.apple_deployment_version(os, &target, Some(arch_str));
let (sdk_prefix, sim_prefix) = match os {
AppleOs::MacOs => ("macosx", ""),
AppleOs::Ios => ("iphone", "ios-"),
Expand Down Expand Up @@ -3290,7 +3290,12 @@ impl Build {
Ok(ret)
}

fn apple_deployment_version(&self, os: AppleOs, target: &str, arch_str: &str) -> String {
fn apple_deployment_version(
&self,
os: AppleOs,
target: &str,
arch_str: Option<&str>,
) -> String {
fn rustc_provided_target(rustc: Option<&str>, target: &str) -> Option<String> {
let rustc = rustc?;
let output = Command::new(rustc)
Expand Down Expand Up @@ -3327,7 +3332,7 @@ impl Build {
.ok()
.or_else(|| rustc_provided_target(rustc, target))
.unwrap_or_else(|| {
if arch_str == "aarch64" {
if arch_str == Some("aarch64") {
"11.0"
} else {
"10.7"
Expand All @@ -3341,7 +3346,7 @@ impl Build {
AppleOs::WatchOs => env::var("WATCHOS_DEPLOYMENT_TARGET")
.ok()
.or_else(|| rustc_provided_target(rustc, target))
.unwrap_or_else(|| "2.0".into()),
.unwrap_or_else(|| "5.0".into()),
}
}

Expand Down

0 comments on commit 430a770

Please sign in to comment.