boring-sys: Don't use CMake cross-compilation for macOS->iOS

(or macOS->macOS)
This commit is contained in:
Jordan Rose 2023-11-10 16:34:06 -08:00 committed by Anthony Ramine
parent 9cf03ae4c1
commit af0c36a22f
1 changed files with 21 additions and 5 deletions

View File

@ -11,6 +11,20 @@ use crate::config::Config;
mod config; mod config;
fn should_use_cmake_cross_compilation(config: &Config) -> bool {
if config.host == config.target {
return false;
}
match config.target_os.as_str() {
"macos" | "ios" => {
// Cross-compiling for Apple platforms on macOS is supported using the normal Xcode
// tools, along with the settings from `cmake_params_apple`.
!config.host.ends_with("-darwin")
}
_ => true,
}
}
// Android NDK >= 19. // Android NDK >= 19.
const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[ const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[
("aarch64", &[("ANDROID_ABI", "arm64-v8a")]), ("aarch64", &[("ANDROID_ABI", "arm64-v8a")]),
@ -193,11 +207,13 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
return boringssl_cmake; return boringssl_cmake;
} }
boringssl_cmake if should_use_cmake_cross_compilation(config) {
.define("CMAKE_CROSSCOMPILING", "true") boringssl_cmake
.define("CMAKE_C_COMPILER_TARGET", &config.target) .define("CMAKE_CROSSCOMPILING", "true")
.define("CMAKE_CXX_COMPILER_TARGET", &config.target) .define("CMAKE_C_COMPILER_TARGET", &config.target)
.define("CMAKE_ASM_COMPILER_TARGET", &config.target); .define("CMAKE_CXX_COMPILER_TARGET", &config.target)
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
}
if let Some(sysroot) = &config.env.sysroot { if let Some(sysroot) = &config.env.sysroot {
boringssl_cmake.define("CMAKE_SYSROOT", sysroot); boringssl_cmake.define("CMAKE_SYSROOT", sysroot);