Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions boring-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ use crate::config::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.
const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[
("aarch64", &[("ANDROID_ABI", "arm64-v8a")]),
Expand Down Expand Up @@ -193,11 +207,13 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
return boringssl_cmake;
}

boringssl_cmake
.define("CMAKE_CROSSCOMPILING", "true")
.define("CMAKE_C_COMPILER_TARGET", &config.target)
.define("CMAKE_CXX_COMPILER_TARGET", &config.target)
.define("CMAKE_ASM_COMPILER_TARGET", &config.target);
if should_use_cmake_cross_compilation(config) {
boringssl_cmake
.define("CMAKE_CROSSCOMPILING", "true")
.define("CMAKE_C_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 {
boringssl_cmake.define("CMAKE_SYSROOT", sysroot);
Expand Down
Loading