Skip to content

Commit

Permalink
feat: Support for Electron for ARM
Browse files Browse the repository at this point in the history
Close #778
  • Loading branch information
develar committed Sep 25, 2016
1 parent 4b47adb commit 6735da5
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
20 changes: 11 additions & 9 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface CliOptions extends PackagerOptions, PublishOptions {

x64?: boolean
ia32?: boolean
armv7l?: boolean

dir?: boolean

Expand Down Expand Up @@ -60,18 +61,18 @@ export function normalizeOptions(args: CliOptions): BuildOptions {
}

function commonArch(): Array<Arch> {
if (args.ia32 && args.x64) {
return [Arch.x64, Arch.ia32]
const result = Array<Arch>()
if (args.x64) {
result.push(Arch.x64)
}
else if (args.ia32) {
return [Arch.ia32]
if (args.armv7l) {
result.push(Arch.armv7l)
}
else if (args.x64) {
return [Arch.x64]
}
else {
return [archFromString(process.arch)]
if (args.ia32) {
result.push(Arch.ia32)
}

return result.length === 0 ? [archFromString(process.arch)] : result
}

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

delete result.ia32
delete result.x64
delete result.armv7l
return result
}

Expand Down
5 changes: 5 additions & 0 deletions src/cliOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export function createYargs(): any {
describe: "Build for ia32",
type: "boolean",
})
.option("armv7l", {
group: buildGroup,
describe: "Build for armv7l",
type: "boolean",
})
.option("dir", {
group: buildGroup,
describe: "Build unpacked dir. Useful to test.",
Expand Down
5 changes: 4 additions & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export class Platform {
}

export enum Arch {
ia32, x64
ia32, x64, armv7l
}

export function archFromString(name: string): Arch {
Expand All @@ -456,6 +456,9 @@ export function archFromString(name: string): Arch {
if (name === "ia32") {
return Arch.ia32
}
if (name === "armv7l") {
return Arch.armv7l
}

throw new Error(`Unsupported arch ${name}`)
}
2 changes: 1 addition & 1 deletion src/node-gyp-rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const __awaiter = require("./util/awaiter")

const args: any = yargs
.option("arch", {
choices: ["ia32", "x64"],
choices: ["ia32", "x64", "armv7l"],
}).argv

const projectDir = process.cwd()
Expand Down
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export function normalizePlatforms(rawPlatforms: Array<string | Platform> | stri
return [Platform.MAC, Platform.LINUX, Platform.WINDOWS]
}
else if (process.platform === Platform.LINUX.nodeName) {
// MacOS code sign works only on MacOS
// macOS code sign works only on macOS
return [Platform.LINUX, Platform.WINDOWS]
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/targets/fpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class FpmTarget extends TargetEx {
const args = [
"-s", "dir",
"-t", target,
"--architecture", arch === Arch.ia32 ? "i386" : "amd64",
"--architecture", arch === Arch.ia32 ? "i386" : (arch === Arch.x64 ? "amd64" : "armv7l"),
"--name", appInfo.name,
"--force",
"--after-install", scripts[0],
Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions
}
}))

const packageFile = `${outDir}/TestApp-${appInfo.version}-${arch === Arch.ia32 ? "ia32" : "amd64"}.deb`
const packageFile = `${outDir}/TestApp-${appInfo.version}-${arch === Arch.ia32 ? "ia32" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb`
assertThat(await getContents(packageFile)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${outDir}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
Expand Down
3 changes: 2 additions & 1 deletion test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function downloadAllRequiredElectronVersions(): Promise<any> {
}

for (let platform of platforms) {
for (let arch of (platform === "mas" || platform === "darwin" ? ["x64"] : ["ia32", "x64"])) {
const archs = (platform === "mas" || platform === "darwin") ? ["x64"] : (platform === "win32" ? ["ia32", "x64"] : ["ia32", "x64", "armv7l"])
for (let arch of archs) {
downloadPromises.push(downloadElectron({
version: ELECTRON_VERSION,
arch: arch,
Expand Down
3 changes: 3 additions & 0 deletions test/src/linuxPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { modifyPackageJson, app, appThrows } from "./helpers/packTester"
import { remove } from "fs-extra-p"
import * as path from "path"
import { Platform } from "out"
import { Arch } from "out/metadata"

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

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

test.ifNotWindows("arm deb", app({targets: Platform.LINUX.createTarget("deb", Arch.armv7l)}))

test.ifDevOrLinuxCi("AppImage", app({targets: Platform.LINUX.createTarget()}))

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

0 comments on commit 6735da5

Please sign in to comment.