Skip to content

Commit e76ec87

Browse files
authored
add macos catalyst support (#556)
1 parent 107493d commit e76ec87

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

src/lib.rs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,14 @@ impl Build {
14591459
cmd.args
14601460
.push(format!("--target={}-apple-darwin", arch).into());
14611461
}
1462+
} else if target.contains("macabi") {
1463+
if let Some(arch) =
1464+
map_darwin_target_from_rust_to_compiler_architecture(target)
1465+
{
1466+
let ios = if arch == "arm64" { "ios" } else { "ios13.0" };
1467+
cmd.args
1468+
.push(format!("--target={}-apple-{}-macabi", arch, ios).into());
1469+
}
14621470
} else {
14631471
cmd.args.push(format!("--target={}", target).into());
14641472
}
@@ -1881,6 +1889,7 @@ impl Build {
18811889
enum ArchSpec {
18821890
Device(&'static str),
18831891
Simulator(&'static str),
1892+
Catalyst(&'static str),
18841893
}
18851894

18861895
let target = self.get_target()?;
@@ -1890,18 +1899,38 @@ impl Build {
18901899
"Unknown architecture for iOS target.",
18911900
)
18921901
})?;
1893-
let arch = match arch {
1894-
"arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"),
1895-
"armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"),
1896-
"arm64e" => ArchSpec::Device("arm64e"),
1897-
"arm64" | "aarch64" => ArchSpec::Device("arm64"),
1898-
"i386" | "i686" => ArchSpec::Simulator("-m32"),
1899-
"x86_64" => ArchSpec::Simulator("-m64"),
1900-
_ => {
1901-
return Err(Error::new(
1902-
ErrorKind::ArchitectureInvalid,
1903-
"Unknown architecture for iOS target.",
1904-
));
1902+
1903+
let is_catalyst = match target.split('-').nth(3) {
1904+
Some(v) => v == "macabi",
1905+
None => false,
1906+
};
1907+
1908+
let arch = if is_catalyst {
1909+
match arch {
1910+
"arm64e" => ArchSpec::Catalyst("arm64e"),
1911+
"arm64" | "aarch64" => ArchSpec::Catalyst("arm64"),
1912+
"x86_64" => ArchSpec::Catalyst("-m64"),
1913+
_ => {
1914+
return Err(Error::new(
1915+
ErrorKind::ArchitectureInvalid,
1916+
"Unknown architecture for iOS target.",
1917+
));
1918+
}
1919+
}
1920+
} else {
1921+
match arch {
1922+
"arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"),
1923+
"armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"),
1924+
"arm64e" => ArchSpec::Device("arm64e"),
1925+
"arm64" | "aarch64" => ArchSpec::Device("arm64"),
1926+
"i386" | "i686" => ArchSpec::Simulator("-m32"),
1927+
"x86_64" => ArchSpec::Simulator("-m64"),
1928+
_ => {
1929+
return Err(Error::new(
1930+
ErrorKind::ArchitectureInvalid,
1931+
"Unknown architecture for iOS target.",
1932+
));
1933+
}
19051934
}
19061935
};
19071936

@@ -1922,6 +1951,7 @@ impl Build {
19221951
.push(format!("-mios-simulator-version-min={}", min_version).into());
19231952
"iphonesimulator"
19241953
}
1954+
ArchSpec::Catalyst(_) => "macosx",
19251955
};
19261956

19271957
self.print(&format!("Detecting iOS SDK path for {}", sdk));

0 commit comments

Comments
 (0)