Fix integration of SSL libs into non-ARM64 Android builds. (#4563)

* Fix integration of SSL libs into non-ARM64 Android builds.

* Fix formatting in request.rs.
This commit is contained in:
Alexandr Priezzhev authored and GitHub committed 2025-08-18 16:03:26 -07:00
1 parent 4e33bad5bf
commit 8a07a24704
1 file changed
+33 -16
+33 -16
View File
@@ -202,6 +202,10 @@
//! libmyapp.so
//! arm64-v8a/
//! libmyapp.so
//! x86/
//! libmyapp.so
//! x86_64/
//! libmyapp.so
//! ```
//! Notice that we *could* feasibly build this ourselves :)
//!
@@ -344,7 +348,7 @@ use std::{
},
time::{SystemTime, UNIX_EPOCH},
};
use target_lexicon::{Environment, OperatingSystem, Triple};
use target_lexicon::{Architecture, Environment, OperatingSystem, Triple};
use tempfile::{NamedTempFile, TempDir};
use tokio::{io::AsyncBufReadExt, process::Command};
use uuid::Uuid;
@@ -1171,6 +1175,7 @@ impl BuildRequest {
async fn write_frameworks(&self, _ctx: &BuildContext, direct_rustc: &RustcArgs) -> Result<()> {
let framework_dir = self.frameworks_folder();
_ = std::fs::create_dir_all(&framework_dir);
// We have some prebuilt stuff that needs to be copied into the framework dir
let openssl_dir = AndroidTools::openssl_lib_dir(&self.triple);
@@ -1188,8 +1193,6 @@ impl BuildRequest {
tracing::debug!("Copying framework from {from:?} to {to:?}");
_ = std::fs::create_dir_all(&framework_dir);
// in dev and on normal oses, we want to symlink the file
// otherwise, just copy it (since in release you want to distribute the framework)
if cfg!(any(windows, unix)) && !self.release {
@@ -1219,13 +1222,15 @@ impl BuildRequest {
// Copy over libssl and libcrypto if they are present in the link args
if self.bundle == BundleFormat::Android && arg.contains(openssl_dir_disp.as_str()) {
let libssl = openssl_dir.join("libssl.so");
let libcrypto = openssl_dir.join("libcrypto.so");
std::fs::copy(&libssl, framework_dir.join("libssl.so")).with_context(|| {
format!("Failed to copy libssl.so into bundle from {libssl:?}")
let libssl_source = openssl_dir.join("libssl.so");
let libcrypto_source = openssl_dir.join("libcrypto.so");
let libssl_target = framework_dir.join("libssl.so");
let libcrypto_target = framework_dir.join("libcrypto.so");
std::fs::copy(&libssl_source, &libssl_target).with_context(|| {
format!("Failed to copy libssl.so into bundle\nfrom {libssl_source:?}\nto {libssl_target:?}")
})?;
std::fs::copy(&libcrypto, framework_dir.join("libcrypto.so")).with_context(
|| format!("Failed to copy libcrypto.so into bundle from {libcrypto:?}"),
std::fs::copy(&libcrypto_source, &libcrypto_target).with_context(
|| format!("Failed to copy libcrypto.so into bundle\nfrom {libcrypto_source:?}\nto {libcrypto_target:?}"),
)?;
}
}
@@ -1239,13 +1244,25 @@ impl BuildRequest {
self.root_dir().join("Contents").join("Frameworks")
}
OperatingSystem::IOS(_) => self.root_dir().join("Frameworks"),
OperatingSystem::Linux if self.bundle == BundleFormat::Android => self
.root_dir()
.join("app")
.join("src")
.join("main")
.join("jniLibs")
.join("arm64-v8a"),
OperatingSystem::Linux if self.bundle == BundleFormat::Android => {
let arch = match self.triple.architecture {
Architecture::Aarch64(_) => "arm64-v8a",
Architecture::Arm(_) => "armeabi-v7a",
Architecture::X86_32(_) => "x86",
Architecture::X86_64 => "x86_64",
_ => panic!(
"Unsupported architecture for Android: {:?}",
self.triple.architecture
),
};
self.root_dir()
.join("app")
.join("src")
.join("main")
.join("jniLibs")
.join(arch)
}
OperatingSystem::Linux | OperatingSystem::Windows => self.root_dir(),
_ => self.root_dir(),
}