diff --git a/.changeset/stupid-avocados-appear.md b/.changeset/stupid-avocados-appear.md
new file mode 100644
index 00000000000..f6678d2222d
--- /dev/null
+++ b/.changeset/stupid-avocados-appear.md
@@ -0,0 +1,7 @@
+---
+"app-builder-lib": minor
+"builder-util": minor
+"electron-builder": minor
+---
+
+feat: support riscv64 architecture for electron-builder (requires custom prebuilt artifact via `electronDist`)
diff --git a/docs/api/electron-builder.md b/docs/api/electron-builder.md
index 7b4c0125196..adc34d709a3 100644
--- a/docs/api/electron-builder.md
+++ b/docs/api/electron-builder.md
@@ -36,6 +36,7 @@ Developer API only. See [Configuration](../configuration/configuration.md) for u
armv7l
arm64
universal
+riscv64
electron-builder.build(rawOptions)
⇒ Promise<Array<String>>
diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json
index bff6304725c..8e2a2fe12c4 100644
--- a/packages/app-builder-lib/scheme.json
+++ b/packages/app-builder-lib/scheme.json
@@ -311,6 +311,7 @@
"arm64",
"armv7l",
"ia32",
+ "riscv64",
"universal",
"x64"
],
@@ -5941,6 +5942,7 @@
"arm64",
"armv7l",
"ia32",
+ "riscv64",
"universal",
"x64"
],
diff --git a/packages/app-builder-lib/src/linuxPackager.ts b/packages/app-builder-lib/src/linuxPackager.ts
index a3c6fb862f0..71592e3fb14 100644
--- a/packages/app-builder-lib/src/linuxPackager.ts
+++ b/packages/app-builder-lib/src/linuxPackager.ts
@@ -81,6 +81,8 @@ export function toAppImageOrSnapArch(arch: Arch): string {
return "arm"
case Arch.arm64:
return "arm_aarch64"
+ case Arch.riscv64:
+ return "riscv64"
default:
throw new Error(`Unsupported arch ${arch}`)
diff --git a/packages/app-builder-lib/src/targets/snap.ts b/packages/app-builder-lib/src/targets/snap.ts
index 1a007cb451c..4069233fdc1 100644
--- a/packages/app-builder-lib/src/targets/snap.ts
+++ b/packages/app-builder-lib/src/targets/snap.ts
@@ -328,6 +328,8 @@ function archNameToTriplet(arch: Arch): string {
return "arm-linux-gnueabihf"
case Arch.arm64:
return "aarch64-linux-gnu"
+ case Arch.riscv64:
+ return "riscv64-linux-gnu"
default:
throw new Error(`Unsupported arch ${arch}`)
diff --git a/packages/builder-util/src/arch.ts b/packages/builder-util/src/arch.ts
index b7dfe3b6624..a75330211f2 100644
--- a/packages/builder-util/src/arch.ts
+++ b/packages/builder-util/src/arch.ts
@@ -4,9 +4,10 @@ export enum Arch {
armv7l,
arm64,
universal,
+ riscv64,
}
-export type ArchType = "x64" | "ia32" | "armv7l" | "arm64" | "universal"
+export type ArchType = "x64" | "ia32" | "armv7l" | "arm64" | "universal" | "riscv64"
export function toLinuxArchString(arch: Arch, targetName: string): string {
switch (arch) {
@@ -18,14 +19,15 @@ export function toLinuxArchString(arch: Arch, targetName: string): string {
return targetName === "snap" || targetName === "deb" ? "armhf" : targetName === "flatpak" ? "arm" : "armv7l"
case Arch.arm64:
return targetName === "pacman" || targetName === "rpm" || targetName === "flatpak" ? "aarch64" : "arm64"
-
+ case Arch.riscv64:
+ return "riscv64"
default:
throw new Error(`Unsupported arch ${arch}`)
}
}
export function getArchCliNames(): Array {
- return [Arch[Arch.ia32], Arch[Arch.x64], Arch[Arch.armv7l], Arch[Arch.arm64]]
+ return [Arch[Arch.ia32], Arch[Arch.x64], Arch[Arch.armv7l], Arch[Arch.arm64], Arch[Arch.riscv64]]
}
export function getArchSuffix(arch: Arch, defaultArch?: string): string {
@@ -45,6 +47,8 @@ export function archFromString(name: string): Arch {
return Arch.armv7l
case "universal":
return Arch.universal
+ case "riscv64":
+ return Arch.riscv64
default:
throw new Error(`Unsupported arch ${name}`)
}
diff --git a/packages/electron-builder/src/builder.ts b/packages/electron-builder/src/builder.ts
index cf463587dc5..88c47be73b1 100644
--- a/packages/electron-builder/src/builder.ts
+++ b/packages/electron-builder/src/builder.ts
@@ -18,6 +18,7 @@ export interface CliOptions extends PackagerOptions, PublishOptions {
armv7l?: boolean
arm64?: boolean
universal?: boolean
+ riscv64?: boolean
dir?: boolean
}
@@ -48,6 +49,9 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
if (args.universal) {
result.push(Arch.universal)
}
+ if (args.riscv64) {
+ result.push(Arch.riscv64)
+ }
return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result
}
diff --git a/test/src/helpers/downloadElectron.ts b/test/src/helpers/downloadElectron.ts
index 7e75949e5e9..09b2c1eae9c 100644
--- a/test/src/helpers/downloadElectron.ts
+++ b/test/src/helpers/downloadElectron.ts
@@ -42,13 +42,17 @@ export function downloadAllRequiredElectronVersions(): Promise {
const versions: Array = []
for (const platform of platforms) {
- const archs: string[] =
+ const archs =
platform === "mas" || platform === "darwin"
? ["x64"]
: platform === "win32"
? ["ia32", "x64"]
: require(`${path.join(__dirname, "../../..")}/packages/builder-util/out/util`).getArchCliNames()
for (const arch of archs) {
+ if (arch === "riscv64") {
+ // No prebuilt electron for riscv64
+ continue
+ }
if (gte(ELECTRON_VERSION, "19.0.0") && platform === "linux" && arch === "ia32") {
// Chromium dropped support for ia32 linux binaries in 102.0.4999.0
// https://www.electronjs.org/docs/latest/breaking-changes#removed-ia32-linux-binaries