Skip to content

Commit 430a770

Browse files
committed
Obtain deployment target consistently
Fix the now-unified default watchOS deployment target
1 parent cbedc33 commit 430a770

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
@@ -1718,8 +1718,8 @@ impl Build {
17181718
if let Some(arch) =
17191719
map_darwin_target_from_rust_to_compiler_architecture(target)
17201720
{
1721-
let deployment_target = env::var("IPHONEOS_DEPLOYMENT_TARGET")
1722-
.unwrap_or_else(|_| "7.0".into());
1721+
let deployment_target =
1722+
self.apple_deployment_version(AppleOs::Ios, target, None);
17231723
cmd.args.push(
17241724
format!(
17251725
"--target={}-apple-ios{}-simulator",
@@ -1732,8 +1732,8 @@ impl Build {
17321732
if let Some(arch) =
17331733
map_darwin_target_from_rust_to_compiler_architecture(target)
17341734
{
1735-
let deployment_target = env::var("WATCHOS_DEPLOYMENT_TARGET")
1736-
.unwrap_or_else(|_| "5.0".into());
1735+
let deployment_target =
1736+
self.apple_deployment_version(AppleOs::WatchOs, target, None);
17371737
cmd.args.push(
17381738
format!(
17391739
"--target={}-apple-watchos{}-simulator",
@@ -2336,7 +2336,7 @@ impl Build {
23362336
}
23372337
};
23382338

2339-
let min_version = self.apple_deployment_version(os, &target, arch_str);
2339+
let min_version = self.apple_deployment_version(os, &target, Some(arch_str));
23402340
let (sdk_prefix, sim_prefix) = match os {
23412341
AppleOs::MacOs => ("macosx", ""),
23422342
AppleOs::Ios => ("iphone", "ios-"),
@@ -3290,7 +3290,12 @@ impl Build {
32903290
Ok(ret)
32913291
}
32923292

3293-
fn apple_deployment_version(&self, os: AppleOs, target: &str, arch_str: &str) -> String {
3293+
fn apple_deployment_version(
3294+
&self,
3295+
os: AppleOs,
3296+
target: &str,
3297+
arch_str: Option<&str>,
3298+
) -> String {
32943299
fn rustc_provided_target(rustc: Option<&str>, target: &str) -> Option<String> {
32953300
let rustc = rustc?;
32963301
let output = Command::new(rustc)
@@ -3327,7 +3332,7 @@ impl Build {
33273332
.ok()
33283333
.or_else(|| rustc_provided_target(rustc, target))
33293334
.unwrap_or_else(|| {
3330-
if arch_str == "aarch64" {
3335+
if arch_str == Some("aarch64") {
33313336
"11.0"
33323337
} else {
33333338
"10.7"
@@ -3341,7 +3346,7 @@ impl Build {
33413346
AppleOs::WatchOs => env::var("WATCHOS_DEPLOYMENT_TARGET")
33423347
.ok()
33433348
.or_else(|| rustc_provided_target(rustc, target))
3344-
.unwrap_or_else(|| "2.0".into()),
3349+
.unwrap_or_else(|| "5.0".into()),
33453350
}
33463351
}
33473352

0 commit comments

Comments
 (0)