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

Improve handling/logging for Android builds #563

Merged
merged 1 commit into from
Oct 11, 2024
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
39 changes: 24 additions & 15 deletions aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,7 @@ impl CmakeBuilder {
}

if target_os() == "android" {
cmake_cfg.define("CMAKE_SYSTEM_NAME", "Android");

let target = target();
let proc = target.split('-').next().unwrap();
match proc {
"armv7" => {
cmake_cfg.define("CMAKE_SYSTEM_PROCESSOR", "armv7-a");
}
"arm" => {
cmake_cfg.define("CMAKE_SYSTEM_PROCESSOR", "armv6");
}
_ => {
cmake_cfg.define("CMAKE_SYSTEM_PROCESSOR", proc);
}
}
self.configure_android(&mut cmake_cfg);
}

if target_vendor() == "apple" && target_os().to_lowercase() == "ios" {
Expand All @@ -221,6 +207,29 @@ impl CmakeBuilder {
cmake_cfg
}

fn configure_android(&self, _cmake_cfg: &mut cmake::Config) {
// If we leave CMAKE_SYSTEM_PROCESSOR unset, then cmake-rs should handle properly setting
// CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR:
// https://github.com/rust-lang/cmake-rs/blob/b689783b5448966e810d515c798465f2e0ab56fd/src/lib.rs#L450-L499

// Log relevant environment variables.
if let Some(value) = option_env("ANDROID_NDK_ROOT") {
emit_warning(&format!("Found ANDROID_NDK_ROOT={value}"));
} else {
emit_warning("ANDROID_NDK_ROOT not set.");
}
if let Some(value) = option_env("ANDROID_NDK") {
emit_warning(&format!("Found ANDROID_NDK={value}"));
} else {
emit_warning("ANDROID_NDK not set.");
}
if let Some(value) = option_env("ANDROID_STANDALONE_TOOLCHAIN") {
emit_warning(&format!("Found ANDROID_STANDALONE_TOOLCHAIN={value}"));
} else {
emit_warning("ANDROID_STANDALONE_TOOLCHAIN not set.");
}
}

fn configure_windows(&self, cmake_cfg: &mut cmake::Config) {
match (target_env().as_str(), target_arch().as_str()) {
("msvc", "aarch64") => {
Expand Down
Loading