Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ jobs:
arch: x64
- platform: android
arch: arm64
- platform: android
arch: arm
- platform: android
arch: armv7
- platform: android
arch: armv6
- platform: android
arch: armv8a32
- platform: android
arch: x86
- platform: ios
arch: arm64

Expand Down
12 changes: 9 additions & 3 deletions apk/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ use anyhow::{Context, Result};
#[repr(u8)]
pub enum Target {
ArmV7a = 1,
Arm64V8a = 2,
X86 = 3,
X86_64 = 4,
Armeabi = 2,
Arm64V8a = 3,
X86 = 4,
X86_64 = 5,
Comment on lines 4 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the repr values here might not be desired, but I need to check where it is even used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright

ArmV6a = 6, // ARM 32-bit (ARMv6-A)
ArmV8a32 = 7, // ARM 32-bit (ARMv8-A)
}

impl Target {
/// Identifier used in the NDK to refer to the ABI
pub fn as_str(self) -> &'static str {
match self {
Self::Arm64V8a => "arm64-v8a",
Self::Armeabi => "armeabi",
Self::ArmV7a => "armeabi-v7a",
Self::X86 => "x86",
Self::X86_64 => "x86_64",
Self::ArmV6a => "armeabi-v6a",
Self::ArmV8a32 => "armv8a",
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions xbuild/src/devices/adb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,12 @@ impl Adb {
pub fn arch(&self, device: &str) -> Result<Arch> {
let arch = match self.getprop(device, "ro.product.cpu.abi")?.as_str() {
"arm64-v8a" => Arch::Arm64,
//"armeabi-v7a" => Arch::Arm,
"armeabi-v7a" => Arch::Armv7,
"armeabi-v6a" => Arch::Armv6,
"armv8a" => Arch::Armv8a32,
"armeabi" => Arch::Arm,
"x86_64" => Arch::X64,
//"x86" => Arch::X86,
"x86" => Arch::X86,
abi => anyhow::bail!("unrecognized abi {}", abi),
};
Ok(arch)
Expand Down
3 changes: 3 additions & 0 deletions xbuild/src/devices/imd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ impl IMobileDevice {
pub fn arch(&self, device: &str) -> Result<Arch> {
match self.getkey(device, "CPUArchitecture")?.as_str() {
"arm64" | "arm64e" => Ok(Arch::Arm64),
"armv7" => Ok(Arch::Armv7),
"arm" => Ok(Arch::Arm),
"x86_64" => Ok(Arch::X64),
Comment on lines 128 to +132
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is iOS code, did you confirm that it returns x86_64?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly didn't know what this does in first place

arch => anyhow::bail!("unsupported arch {}", arch),
}
}
Expand Down
28 changes: 22 additions & 6 deletions xbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ impl std::fmt::Display for Platform {

#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub enum Arch {
//Arm,
Armv7,
Arm,
Armv6, // ARM 32-bit (ARMv6)
Armv8a32, // ARM 32-bit (ARMv8-A)
Arm64,
X64,
//X86,
X86, // Intel 32-bit
}

impl Arch {
Expand Down Expand Up @@ -206,8 +209,13 @@ impl CompileTarget {
pub fn android_abi(self) -> apk::Target {
assert_eq!(self.platform(), Platform::Android);
match self.arch() {
Arch::Armv7 => apk::Target::ArmV7a,
Arch::Arm => apk::Target::Armeabi,
Arch::Armv6 => apk::Target::ArmV6a,
Arch::Armv8a32 => apk::Target::ArmV8a32,
Arch::Arm64 => apk::Target::Arm64V8a,
Arch::X64 => apk::Target::X86_64,
Arch::X86 => apk::Target::X86,
}
}

Expand All @@ -216,19 +224,27 @@ impl CompileTarget {
assert_eq!(self.platform(), Platform::Android);
match self.arch() {
Arch::Arm64 => "aarch64-linux-android",
//Arch::Arm => "arm-linux-androideabi",
//Arch::X86 => "i686-linux-android",
Arch::Arm => "arm-linux-androideabi",
Arch::Armv7 => "armv7a-linux-androideabi",
Arch::Armv6 => "armv6a-linux-androideabi",
Arch::Armv8a32 => "armv8a-linux-androideabi",
Arch::X64 => "x86_64-linux-android",
Arch::X86 => "i686-linux-android",
}
}

pub fn rust_triple(self) -> Result<&'static str> {
Ok(match (self.arch, self.platform) {
Ok(match (self.arch(), self.platform) {
(Arch::Arm64, Platform::Android) => "aarch64-linux-android",
(Arch::Armv7, Platform::Android) => "armv7-linux-androideabi",
(Arch::Arm, Platform::Android) => "arm-linux-androideabi",
(Arch::Armv6, Platform::Android) => "armv6-linux-androideabi",
(Arch::Armv8a32, Platform::Android) => "armv8a-linux-androideabi",
(Arch::X64, Platform::Android) => "x86_64-linux-android",
(Arch::X86, Platform::Android) => "i686-linux-android",
(Arch::Arm64, Platform::Ios) => "aarch64-apple-ios",
(Arch::Arm64, Platform::Linux) => "aarch64-unknown-linux-gnu",
(Arch::Arm64, Platform::Macos) => "aarch64-apple-darwin",
(Arch::X64, Platform::Android) => "x86_64-linux-android",
(Arch::X64, Platform::Linux) => "x86_64-unknown-linux-gnu",
(Arch::X64, Platform::Macos) => "x86_64-apple-darwin",
(Arch::X64, Platform::Windows) => "x86_64-pc-windows-msvc",
Expand Down
Loading