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:
1 parent
4e33bad5bf
commit
8a07a24704
1 file changed
+33
-16
@@ -202,6 +202,10 @@
|
|||||||
//! libmyapp.so
|
//! libmyapp.so
|
||||||
//! arm64-v8a/
|
//! arm64-v8a/
|
||||||
//! libmyapp.so
|
//! libmyapp.so
|
||||||
|
//! x86/
|
||||||
|
//! libmyapp.so
|
||||||
|
//! x86_64/
|
||||||
|
//! libmyapp.so
|
||||||
//! ```
|
//! ```
|
||||||
//! Notice that we *could* feasibly build this ourselves :)
|
//! Notice that we *could* feasibly build this ourselves :)
|
||||||
//!
|
//!
|
||||||
@@ -344,7 +348,7 @@ use std::{
|
|||||||
},
|
},
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
use target_lexicon::{Environment, OperatingSystem, Triple};
|
use target_lexicon::{Architecture, Environment, OperatingSystem, Triple};
|
||||||
use tempfile::{NamedTempFile, TempDir};
|
use tempfile::{NamedTempFile, TempDir};
|
||||||
use tokio::{io::AsyncBufReadExt, process::Command};
|
use tokio::{io::AsyncBufReadExt, process::Command};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@@ -1171,6 +1175,7 @@ impl BuildRequest {
|
|||||||
|
|
||||||
async fn write_frameworks(&self, _ctx: &BuildContext, direct_rustc: &RustcArgs) -> Result<()> {
|
async fn write_frameworks(&self, _ctx: &BuildContext, direct_rustc: &RustcArgs) -> Result<()> {
|
||||||
let framework_dir = self.frameworks_folder();
|
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
|
// We have some prebuilt stuff that needs to be copied into the framework dir
|
||||||
let openssl_dir = AndroidTools::openssl_lib_dir(&self.triple);
|
let openssl_dir = AndroidTools::openssl_lib_dir(&self.triple);
|
||||||
@@ -1188,8 +1193,6 @@ impl BuildRequest {
|
|||||||
|
|
||||||
tracing::debug!("Copying framework from {from:?} to {to:?}");
|
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
|
// 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)
|
// otherwise, just copy it (since in release you want to distribute the framework)
|
||||||
if cfg!(any(windows, unix)) && !self.release {
|
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
|
// 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()) {
|
if self.bundle == BundleFormat::Android && arg.contains(openssl_dir_disp.as_str()) {
|
||||||
let libssl = openssl_dir.join("libssl.so");
|
let libssl_source = openssl_dir.join("libssl.so");
|
||||||
let libcrypto = openssl_dir.join("libcrypto.so");
|
let libcrypto_source = openssl_dir.join("libcrypto.so");
|
||||||
std::fs::copy(&libssl, framework_dir.join("libssl.so")).with_context(|| {
|
let libssl_target = framework_dir.join("libssl.so");
|
||||||
format!("Failed to copy libssl.so into bundle from {libssl:?}")
|
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(
|
std::fs::copy(&libcrypto_source, &libcrypto_target).with_context(
|
||||||
|| format!("Failed to copy libcrypto.so into bundle from {libcrypto:?}"),
|
|| 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")
|
self.root_dir().join("Contents").join("Frameworks")
|
||||||
}
|
}
|
||||||
OperatingSystem::IOS(_) => self.root_dir().join("Frameworks"),
|
OperatingSystem::IOS(_) => self.root_dir().join("Frameworks"),
|
||||||
OperatingSystem::Linux if self.bundle == BundleFormat::Android => self
|
OperatingSystem::Linux if self.bundle == BundleFormat::Android => {
|
||||||
.root_dir()
|
let arch = match self.triple.architecture {
|
||||||
.join("app")
|
Architecture::Aarch64(_) => "arm64-v8a",
|
||||||
.join("src")
|
Architecture::Arm(_) => "armeabi-v7a",
|
||||||
.join("main")
|
Architecture::X86_32(_) => "x86",
|
||||||
.join("jniLibs")
|
Architecture::X86_64 => "x86_64",
|
||||||
.join("arm64-v8a"),
|
_ => 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(),
|
OperatingSystem::Linux | OperatingSystem::Windows => self.root_dir(),
|
||||||
_ => self.root_dir(),
|
_ => self.root_dir(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user