feat: basic support for linux riscv64 (#12602)

This commit is contained in:
Levi Zim 2025-03-17 03:33:17 +08:00 committed by GitHub
parent 2b960dfd9f
commit f981a5ee8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 72 additions and 2 deletions

View File

@ -0,0 +1,8 @@
---
'tauri-cli': 'minor:enhance'
'tauri-utils': 'minor:enhance'
'tauri-bundler': 'minor:enhance'
'@tauri-apps/cli': 'minor:enhance'
---
Add basic support for linux riscv64 platform.

View File

@ -92,6 +92,15 @@ jobs:
rustup target add aarch64-unknown-linux-musl
pnpm build --target aarch64-unknown-linux-musl
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
- host: ubuntu-22.04
architecture: x64
target: riscv64gc-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu -y
build: |
pnpm build --target=riscv64gc-unknown-linux-gnu
riscv64-linux-gnu-strip *.node
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
steps:

View File

@ -46,6 +46,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
Arch::AArch64 => "arm64",
Arch::Armhf => "armhf",
Arch::Armel => "armel",
Arch::Riscv64 => "riscv64",
target => {
return Err(crate::Error::ArchError(format!(
"Unsupported architecture: {:?}",

View File

@ -29,6 +29,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
Arch::AArch64 => "aarch64",
Arch::Armhf => "armhfp",
Arch::Armel => "armel",
Arch::Riscv64 => "riscv64",
target => {
return Err(crate::Error::ArchError(format!(
"Unsupported architecture: {:?}",

View File

@ -57,6 +57,8 @@ pub fn target_triple() -> Result<String, crate::Error> {
"armv7".into()
} else if cfg!(target_arch = "aarch64") {
"aarch64".into()
} else if cfg!(target_arch = "riscv64") {
"riscv64".into()
} else {
return Err(crate::Error::ArchError(String::from(
"Unable to determine target-architecture",

View File

@ -723,6 +723,8 @@ pub enum Arch {
Armhf,
/// For the AArch32 / ARM32 instruction sets with soft-float (32 bits).
Armel,
/// For the RISC-V instruction sets (64 bits).
Riscv64,
/// For universal macOS applications.
Universal,
}
@ -900,6 +902,8 @@ impl Settings {
Arch::Armel
} else if self.target.starts_with("aarch64") {
Arch::AArch64
} else if self.target.starts_with("riscv64") {
Arch::Riscv64
} else if self.target.starts_with("universal") {
Arch::Universal
} else {

View File

@ -794,8 +794,9 @@ impl AppSettings for RustAppSettings {
config: &Config,
features: &[String],
) -> crate::Result<BundleSettings> {
let arch64bits =
self.target_triple.starts_with("x86_64") || self.target_triple.starts_with("aarch64");
let arch64bits = self.target_triple.starts_with("x86_64")
|| self.target_triple.starts_with("aarch64")
|| self.target_triple.starts_with("riscv64");
let updater_enabled = config.bundle.create_updater_artifacts != Updater::Bool(false);
let v1_compatible = matches!(config.bundle.create_updater_artifacts, Updater::String(_));

View File

@ -191,6 +191,8 @@ pub fn target_triple() -> crate::Result<String> {
"armv7"
} else if cfg!(target_arch = "aarch64") {
"aarch64"
} else if cfg!(target_arch = "riscv64") {
"riscv64"
} else {
return Err(crate::Error::Architecture);
};

View File

@ -12,6 +12,9 @@ rustflags = ["-C", "target-feature=-crt-static"]
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.riscv64gc-unknown-linux-gnu]
linker = "riscv64-linux-gnu-gcc"
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
[target.i686-pc-windows-msvc]

View File

@ -0,0 +1,3 @@
# `@tauri-apps/cli-linux-riscv64-gnu`
This is the **riscv64gc-unknown-linux-gnu** binary for `@tauri-apps/cli`

View File

@ -0,0 +1,35 @@
{
"name": "@tauri-apps/cli-linux-riscv64-gnu",
"version": "0.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/tauri-apps/tauri.git"
},
"homepage": "https://github.com/tauri-apps/tauri#readme",
"bugs": {
"url": "https://github.com/tauri-apps/tauri/issues"
},
"contributors": [
"Tauri Programme within The Commons Conservancy"
],
"license": "Apache-2.0 OR MIT",
"publishConfig": {
"access": "public"
},
"os": [
"linux"
],
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"main": "cli.linux-riscv64-gnu.node",
"files": [
"cli.linux-riscv64-gnu.node"
],
"engines": {
"node": ">= 10"
}
}

View File

@ -32,6 +32,7 @@
"aarch64-unknown-linux-musl",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"riscv64gc-unknown-linux-gnu",
"i686-pc-windows-msvc",
"aarch64-pc-windows-msvc"
]