Skip to content

Commit ba90200

Browse files
committed
Obtain deployment target consistently
Fix the now-unified default watchOS deployment target
1 parent e251e13 commit ba90200

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,8 +1832,8 @@ impl Build {
18321832
if let Some(arch) =
18331833
map_darwin_target_from_rust_to_compiler_architecture(target)
18341834
{
1835-
let deployment_target = env::var("IPHONEOS_DEPLOYMENT_TARGET")
1836-
.unwrap_or_else(|_| "7.0".into());
1835+
let deployment_target =
1836+
self.apple_deployment_version(AppleOs::Ios, target, None);
18371837
cmd.args.push(
18381838
format!(
18391839
"--target={}-apple-ios{}-simulator",
@@ -1846,8 +1846,8 @@ impl Build {
18461846
if let Some(arch) =
18471847
map_darwin_target_from_rust_to_compiler_architecture(target)
18481848
{
1849-
let deployment_target = env::var("WATCHOS_DEPLOYMENT_TARGET")
1850-
.unwrap_or_else(|_| "5.0".into());
1849+
let deployment_target =
1850+
self.apple_deployment_version(AppleOs::WatchOs, target, None);
18511851
cmd.args.push(
18521852
format!(
18531853
"--target={}-apple-watchos{}-simulator",
@@ -2450,7 +2450,7 @@ impl Build {
24502450
}
24512451
};
24522452

2453-
let min_version = self.apple_deployment_version(os, &target, arch_str);
2453+
let min_version = self.apple_deployment_version(os, &target, Some(arch_str));
24542454
let (sdk_prefix, sim_prefix) = match os {
24552455
AppleOs::MacOs => ("macosx", ""),
24562456
AppleOs::Ios => ("iphone", "ios-"),
@@ -3404,7 +3404,12 @@ impl Build {
34043404
Ok(ret)
34053405
}
34063406

3407-
fn apple_deployment_version(&self, os: AppleOs, target: &str, arch_str: &str) -> String {
3407+
fn apple_deployment_version(
3408+
&self,
3409+
os: AppleOs,
3410+
target: &str,
3411+
arch_str: Option<&str>,
3412+
) -> String {
34083413
fn rustc_provided_target(rustc: Option<&str>, target: &str) -> Option<String> {
34093414
let rustc = rustc?;
34103415
let output = Command::new(rustc)
@@ -3438,7 +3443,7 @@ impl Build {
34383443
.ok()
34393444
.or_else(|| rustc_provided_target(rustc, target))
34403445
.unwrap_or_else(|| {
3441-
if arch_str == "aarch64" {
3446+
if arch_str == Some("aarch64") {
34423447
"11.0"
34433448
} else {
34443449
"10.7"
@@ -3452,7 +3457,7 @@ impl Build {
34523457
AppleOs::WatchOs => env::var("WATCHOS_DEPLOYMENT_TARGET")
34533458
.ok()
34543459
.or_else(|| rustc_provided_target(rustc, target))
3455-
.unwrap_or_else(|| "2.0".into()),
3460+
.unwrap_or_else(|| "5.0".into()),
34563461
}
34573462
}
34583463

0 commit comments

Comments
 (0)