Feat: Android Dynamic Arch Support (#3215)

* feat: android multi-arch support

* revision: make krate immutable

* revision: minor tweaks

* revision: make pub crate

* revision: dedup arch access

* revision: minor tweaks
This commit is contained in:
Miles Murgaw authored and GitHub committed 2024-11-14 13:24:48 -05:00
1 parent 5ecbb6594c
commit af53354b28
10 files changed
+205 -58

No files matched your search

+7 -1
View File
@@ -745,7 +745,13 @@ impl AppBundle {
)?;
}
let output = Command::new("./gradlew")
let gradle_exec_name = match cfg!(windows) {
true => "gradlew.bat",
false => "gradlew",
};
let gradle_exec = self.build.root_dir().join(gradle_exec_name);
let output = Command::new(gradle_exec)
.arg("assembleDebug")
.current_dir(self.build.root_dir())
.stderr(std::process::Stdio::piped())
+5 -4
View File
@@ -114,10 +114,11 @@ impl BuildRequest {
// We don't want to overwrite the user's .cargo/config.toml since that gets committed to git
// and we want everyone's install to be the same.
if self.build.platform() == Platform::Android {
let linker = self
let ndk = self
.krate
.android_linker()
.android_ndk()
.context("Could not autodetect android linker")?;
let linker = self.build.target_args.arch().android_linker(&ndk);
tracing::trace!("Using android linker: {linker:?}");
@@ -252,7 +253,7 @@ impl BuildRequest {
Some(true) => Some("aarch64-apple-ios"),
_ => Some("aarch64-apple-ios-sim"),
},
Platform::Android => Some("aarch64-linux-android"),
Platform::Android => Some(self.build.target_args.arch().android_target_triplet()),
Platform::Server => None,
// we're assuming we're building for the native platform for now... if you're cross-compiling
// the targets here might be different
@@ -536,7 +537,7 @@ impl BuildRequest {
.join("src")
.join("main")
.join("jniLibs")
.join("arm64-v8a"),
.join(self.build.target_args.arch().android_jnilib()),
// these are all the same, I think?
Platform::Windows
+12 -5
View File
@@ -134,13 +134,20 @@ impl BuildRequest {
/// will do its best to fill in the missing bits by exploring the sdk structure
/// IE will attempt to use the Java installed from android studio if possible.
pub(crate) async fn verify_android_tooling(&self, _rustup: RustupShow) -> Result<()> {
if self.krate.android_linker().is_none() {
return Err(anyhow::anyhow!(
"Android linker not found. Please set the ANDROID_NDK_HOME environment variable to the root of your NDK installation."
).into());
let result = self
.krate
.android_ndk()
.map(|ndk| self.build.target_args.arch().android_linker(&ndk));
if let Some(path) = result {
if path.exists() {
return Ok(());
}
}
Ok(())
Err(anyhow::anyhow!(
"Android linker not found. Please set the `ANDROID_NDK_HOME` environment variable to the root of your NDK installation."
).into())
}
/// Ensure the right dependencies are installed for linux apps.