Skip to content

Commit 6735da5

Browse files
committed
feat: Support for Electron for ARM
Close #778
1 parent 4b47adb commit 6735da5

File tree

9 files changed

+29
-15
lines changed

9 files changed

+29
-15
lines changed

src/builder.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface CliOptions extends PackagerOptions, PublishOptions {
2828

2929
x64?: boolean
3030
ia32?: boolean
31+
armv7l?: boolean
3132

3233
dir?: boolean
3334

@@ -60,18 +61,18 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
6061
}
6162

6263
function commonArch(): Array<Arch> {
63-
if (args.ia32 && args.x64) {
64-
return [Arch.x64, Arch.ia32]
64+
const result = Array<Arch>()
65+
if (args.x64) {
66+
result.push(Arch.x64)
6567
}
66-
else if (args.ia32) {
67-
return [Arch.ia32]
68+
if (args.armv7l) {
69+
result.push(Arch.armv7l)
6870
}
69-
else if (args.x64) {
70-
return [Arch.x64]
71-
}
72-
else {
73-
return [archFromString(process.arch)]
71+
if (args.ia32) {
72+
result.push(Arch.ia32)
7473
}
74+
75+
return result.length === 0 ? [archFromString(process.arch)] : result
7576
}
7677

7778
let archToType = targets.get(platform)
@@ -161,6 +162,7 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
161162

162163
delete result.ia32
163164
delete result.x64
165+
delete result.armv7l
164166
return result
165167
}
166168

src/cliOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export function createYargs(): any {
4040
describe: "Build for ia32",
4141
type: "boolean",
4242
})
43+
.option("armv7l", {
44+
group: buildGroup,
45+
describe: "Build for armv7l",
46+
type: "boolean",
47+
})
4348
.option("dir", {
4449
group: buildGroup,
4550
describe: "Build unpacked dir. Useful to test.",

src/metadata.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ export class Platform {
446446
}
447447

448448
export enum Arch {
449-
ia32, x64
449+
ia32, x64, armv7l
450450
}
451451

452452
export function archFromString(name: string): Arch {
@@ -456,6 +456,9 @@ export function archFromString(name: string): Arch {
456456
if (name === "ia32") {
457457
return Arch.ia32
458458
}
459+
if (name === "armv7l") {
460+
return Arch.armv7l
461+
}
459462

460463
throw new Error(`Unsupported arch ${name}`)
461464
}

src/node-gyp-rebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const __awaiter = require("./util/awaiter")
1212

1313
const args: any = yargs
1414
.option("arch", {
15-
choices: ["ia32", "x64"],
15+
choices: ["ia32", "x64", "armv7l"],
1616
}).argv
1717

1818
const projectDir = process.cwd()

src/packager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export function normalizePlatforms(rawPlatforms: Array<string | Platform> | stri
257257
return [Platform.MAC, Platform.LINUX, Platform.WINDOWS]
258258
}
259259
else if (process.platform === Platform.LINUX.nodeName) {
260-
// MacOS code sign works only on MacOS
260+
// macOS code sign works only on macOS
261261
return [Platform.LINUX, Platform.WINDOWS]
262262
}
263263
else {

src/targets/fpm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class FpmTarget extends TargetEx {
8080
const args = [
8181
"-s", "dir",
8282
"-t", target,
83-
"--architecture", arch === Arch.ia32 ? "i386" : "amd64",
83+
"--architecture", arch === Arch.ia32 ? "i386" : (arch === Arch.x64 ? "amd64" : "armv7l"),
8484
"--name", appInfo.name,
8585
"--force",
8686
"--after-install", scripts[0],

test/src/helpers/packTester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions
221221
}
222222
}))
223223

224-
const packageFile = `${outDir}/TestApp-${appInfo.version}-${arch === Arch.ia32 ? "ia32" : "amd64"}.deb`
224+
const packageFile = `${outDir}/TestApp-${appInfo.version}-${arch === Arch.ia32 ? "ia32" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb`
225225
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
226226
if (arch === Arch.ia32) {
227227
assertThat(await getContents(`${outDir}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)

test/src/helpers/runTests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ function downloadAllRequiredElectronVersions(): Promise<any> {
9191
}
9292

9393
for (let platform of platforms) {
94-
for (let arch of (platform === "mas" || platform === "darwin" ? ["x64"] : ["ia32", "x64"])) {
94+
const archs = (platform === "mas" || platform === "darwin") ? ["x64"] : (platform === "win32" ? ["ia32", "x64"] : ["ia32", "x64", "armv7l"])
95+
for (let arch of archs) {
9596
downloadPromises.push(downloadElectron({
9697
version: ELECTRON_VERSION,
9798
arch: arch,

test/src/linuxPackagerTest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { modifyPackageJson, app, appThrows } from "./helpers/packTester"
33
import { remove } from "fs-extra-p"
44
import * as path from "path"
55
import { Platform } from "out"
6+
import { Arch } from "out/metadata"
67

78
//noinspection JSUnusedLocalSymbols
89
const __awaiter = require("out/util/awaiter")
910

1011
test.ifNotWindows("deb", app({targets: Platform.LINUX.createTarget("deb")}))
1112

13+
test.ifNotWindows("arm deb", app({targets: Platform.LINUX.createTarget("deb", Arch.armv7l)}))
14+
1215
test.ifDevOrLinuxCi("AppImage", app({targets: Platform.LINUX.createTarget()}))
1316

1417
test.ifDevOrLinuxCi("AppImage - default icon", app({targets: Platform.LINUX.createTarget("appimage")}, {

0 commit comments

Comments
 (0)