Skip to content

Commit 6e5b335

Browse files
authored
chore: use libaosc to get arch name (#22)
1 parent ecfebf4 commit 6e5b335

File tree

4 files changed

+14
-37
lines changed

4 files changed

+14
-37
lines changed

src-tauri/Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ sysinfo = "0.35"
3737
tauri-plugin-shell = "2.0.0"
3838
tauri-plugin-dialog = "2.0.0"
3939
tauri-plugin-cli = "2.0.0"
40+
libaosc = { version = "0.3", default-features = false, features = ["arch"] }
4041

4142
[features]
4243
# this feature is used for production builds or when `devPath` points to the filesystem

src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ async fn set_config(state: State<'_, DkState<'_>>, config: &str) -> TauriResult<
432432

433433
#[tauri::command]
434434
fn get_arch_name() -> TauriResult<&'static str> {
435-
let res = utils::get_arch_name().context("Failed to get arch name")?;
435+
let res = libaosc::arch::get_arch_name().context("Failed to get arch name")?;
436436

437437
Ok(res)
438438
}

src-tauri/src/utils.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashMap;
22
use std::path::Path;
33

44
use eyre::{OptionExt, Result};
5+
use libaosc::arch::get_arch_name;
56
use reqwest::Client;
67
use serde::de::DeserializeOwned;
78
use serde::{Deserialize, Serialize};
@@ -217,42 +218,6 @@ pub async fn get_mirror_speed_score(mirror_url: &str, client: &Client) -> Result
217218
Ok((result_time, download_len))
218219
}
219220

220-
// AOSC OS specific architecture mapping for ppc64
221-
#[cfg(target_arch = "powerpc64")]
222-
#[inline]
223-
pub(crate) fn get_arch_name() -> Option<&'static str> {
224-
let mut endian: libc::c_int = -1;
225-
let result;
226-
unsafe {
227-
result = libc::prctl(libc::PR_GET_ENDIAN, &mut endian as *mut libc::c_int);
228-
}
229-
if result < 0 {
230-
return None;
231-
}
232-
match endian {
233-
libc::PR_ENDIAN_LITTLE | libc::PR_ENDIAN_PPC_LITTLE => Some("ppc64el"),
234-
libc::PR_ENDIAN_BIG => Some("ppc64"),
235-
_ => None,
236-
}
237-
}
238-
239-
/// AOSC OS specific architecture mapping table
240-
#[cfg(not(target_arch = "powerpc64"))]
241-
#[inline]
242-
pub(crate) fn get_arch_name() -> Option<&'static str> {
243-
use std::env::consts::ARCH;
244-
match ARCH {
245-
"x86_64" => Some("amd64"),
246-
"x86" => Some("i486"),
247-
"powerpc" => Some("powerpc"),
248-
"aarch64" => Some("arm64"),
249-
"mips64" => Some("loongson3"),
250-
"riscv64" => Some("riscv64"),
251-
"loongarch64" => Some("loongarch64"),
252-
_ => None,
253-
}
254-
}
255-
256221
pub fn control_window_above(pin_pids: &[u32], enable: bool) -> Result<()> {
257222
let mut fined = false;
258223

0 commit comments

Comments
 (0)