Fix Android builds

For starters, they should link against libc++, as they have always
intended to use STL "c++_shared".

824f2a7a20/Modules/Platform/Android-Common.cmake (L70-L75)

Also, fix the variable names we define, as far as I know cmake never
cared about ANDROID_NATIVE_API_LEVEL nor ANDROID_STL.
This commit is contained in:
Anthony Ramine 2025-12-22 10:55:01 +01:00 committed by Kornel
parent c299b1476b
commit 3ac364abc4
2 changed files with 10 additions and 11 deletions

View File

@ -10,6 +10,7 @@ pub(crate) struct Config {
pub(crate) target: String,
pub(crate) target_arch: String,
pub(crate) target_os: String,
pub(crate) unix: bool,
pub(crate) target_env: String,
pub(crate) features: Features,
pub(crate) env: Env,
@ -48,6 +49,7 @@ impl Config {
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
let unix = env::var("CARGO_CFG_UNIX").is_ok();
let features = Features::from_env();
let env = Env::from_env(&host, &target, features.is_fips_like());
@ -65,6 +67,7 @@ impl Config {
target,
target_arch,
target_os,
unix,
target_env,
features,
env,

View File

@ -1,5 +1,4 @@
use fslock::LockFile;
use std::env;
use std::ffi::OsString;
use std::fs;
use std::io;
@ -263,8 +262,8 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
boringssl_cmake.define("CMAKE_TOOLCHAIN_FILE", toolchain_file);
// 21 is the minimum level tested. You can give higher value.
boringssl_cmake.define("ANDROID_NATIVE_API_LEVEL", "21");
boringssl_cmake.define("ANDROID_STL", "c++_shared");
boringssl_cmake.define("CMAKE_SYSTEM_VERSION", "21");
boringssl_cmake.define("CMAKE_ANDROID_STL_TYPE", "c++_shared");
}
"macos" => {
@ -552,14 +551,11 @@ fn get_cpp_runtime_lib(config: &Config) -> Option<String> {
return cpp_lib.clone().into_string().ok();
}
// TODO(rmehra): figure out how to do this for windows
if env::var_os("CARGO_CFG_UNIX").is_some() {
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_ref() {
"macos" | "ios" | "freebsd" => Some("c++".into()),
_ => Some("stdc++".into()),
}
} else {
None
match &*config.target_os {
"macos" | "ios" | "freebsd" | "android" => Some("c++".into()),
_ if config.unix => Some("stdc++".into()),
// TODO(rmehra): figure out how to do this for windows
_ => None,
}
}