Compare commits

...

1 Commits

Author SHA1 Message Date
Jordan Rose
9810010e9e Add support for Mac Catalyst (on Intel and Apple Silicon chips)
This is a Tier 3 target, but apart from working around a hardcoded
version in the 'cc' crate everything does work.
2022-10-12 17:22:15 -07:00

View File

@ -70,6 +70,20 @@ const CMAKE_PARAMS_IOS: &[(&str, &[(&str, &str)])] = &[
("CMAKE_OSX_SYSROOT", "iphonesimulator"), ("CMAKE_OSX_SYSROOT", "iphonesimulator"),
], ],
), ),
(
"aarch64-apple-ios-macabi",
&[
("CMAKE_OSX_ARCHITECTURES", "arm64"),
("CMAKE_OSX_SYSROOT", "macosx"),
],
),
(
"x86_64-apple-ios-macabi",
&[
("CMAKE_OSX_ARCHITECTURES", "x86_64"),
("CMAKE_OSX_SYSROOT", "macosx"),
],
),
]; ];
fn cmake_params_ios() -> &'static [(&'static str, &'static str)] { fn cmake_params_ios() -> &'static [(&'static str, &'static str)] {
@ -178,16 +192,28 @@ fn get_boringssl_cmake_config() -> cmake::Config {
// Bitcode is always on. // Bitcode is always on.
let bitcode_cflag = "-fembed-bitcode"; let bitcode_cflag = "-fembed-bitcode";
// Hack for Xcode 10.1. if target.ends_with("-macabi") {
let target_cflag = if arch == "x86_64" { // Mac Catalyst
"-target x86_64-apple-ios-simulator" let compiler_flags = format!("{} -target {}", bitcode_cflag, target);
boringssl_cmake.define("CMAKE_ASM_FLAGS", &compiler_flags);
// Work around hardcoded deployment target in cc crate by defining CMAKE_C_FLAGS
// instead of using the cflag builder.
boringssl_cmake.define("CMAKE_C_FLAGS", &compiler_flags);
boringssl_cmake.define("CMAKE_CXX_FLAGS", &compiler_flags);
} else { } else {
"" // Normal iOS
};
let cflag = format!("{} {}", bitcode_cflag, target_cflag); // Hack for Xcode 10.1.
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag); let target_cflag = if arch == "x86_64" {
boringssl_cmake.cflag(&cflag); "-target x86_64-apple-ios-simulator"
} else {
""
};
let cflag = format!("{} {}", bitcode_cflag, target_cflag);
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag);
boringssl_cmake.cflag(&cflag);
}
} }
"windows" => { "windows" => {
@ -424,7 +450,7 @@ fn main() {
// so let's disable all alignment tests and hope for the best. // so let's disable all alignment tests and hope for the best.
// //
// [1]: https://github.com/rust-lang/rust-bindgen/issues/1651 // [1]: https://github.com/rust-lang/rust-bindgen/issues/1651
"aarch64-apple-ios" | "aarch64-apple-ios-sim" => { "aarch64-apple-ios" | "aarch64-apple-ios-sim" | "aarch64-apple-ios-macabi" => {
builder = builder.layout_tests(false); builder = builder.layout_tests(false);
} }
_ => {} _ => {}