From 0ef914f6eea7ea39608dc3dfa06ccc357114db70 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sun, 28 Aug 2016 17:55:51 -0700 Subject: [PATCH] Add Linux ARMv7 support --- NEWS.md | 2 ++ common.js | 12 ++++++++++-- docs/api.md | 2 +- package.json | 3 ++- readme.md | 2 +- test/multitarget.js | 15 ++++++++------- usage.txt | 4 ++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index c6e71a34..a1217044 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,9 +5,11 @@ ### Added * `win32metadata` option (#331, #463) +* `linux` platform, `armv7l` arch support (#106, #474) ### Changed +* `all` now includes the `linux` platform, `armv7l` arch combination * Default the `platform` option to the host platform (#464) * Default the `arch` option to the host arch (#36, #464) * Default the `prune` option to `true` (#235, #472) diff --git a/common.js b/common.js index fc593f98..166c0485 100644 --- a/common.js +++ b/common.js @@ -10,9 +10,10 @@ const minimist = require('minimist') const os = require('os') const path = require('path') const sanitize = require('sanitize-filename') +const semver = require('semver') const series = require('run-series') -const archs = ['ia32', 'x64'] +const archs = ['ia32', 'x64', 'armv7l'] const platforms = ['darwin', 'linux', 'mas', 'win32'] function parseCLIArgs (argv) { @@ -122,7 +123,7 @@ function createAsarOpts (opts) { } function createDownloadOpts (opts, platform, arch) { - let downloadOpts = opts.download || {} + let downloadOpts = Object.assign({}, opts.download) subOptionWarning(downloadOpts, 'download', 'platform', platform) subOptionWarning(downloadOpts, 'download', 'arch', arch) @@ -149,6 +150,8 @@ module.exports = { for (let platform of selectedPlatforms) { // Electron does not have 32-bit releases for Mac OS X, so skip that combination if (isPlatformMac(platform) && arch === 'ia32') continue + // Electron only has armv7l releases for Linux + if (arch === 'armv7l' && platform !== 'linux') continue if (typeof ignoreFunc === 'function' && ignoreFunc(platform, arch)) continue combinations.push(createDownloadOpts(opts, platform, arch)) } @@ -158,6 +161,11 @@ module.exports = { }, downloadElectronZip: function downloadElectronZip (downloadOpts, cb) { + // armv7l builds have only been backfilled for Electron >= 1.0.0. + // See: https://github.com/electron/electron/pull/6986 + if (downloadOpts.arch === 'armv7l' && semver.lt(downloadOpts.version, '1.0.0')) { + downloadOpts.arch = 'arm' + } debug(`Downloading Electron with options ${JSON.stringify(downloadOpts)}`) download(downloadOpts, cb) }, diff --git a/docs/api.md b/docs/api.md index ea0af308..85f82a3e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -67,7 +67,7 @@ The release version of the application. By default the `version` property in the *String* (default: the arch of the host computer running Node) -Allowed values: `ia32`, `x64`, `all` +Allowed values: `ia32`, `x64`, `armv7l`, `all` The target system architecture(s) to build for. Not required if the [`all`](#all) option is set. diff --git a/package.json b/package.json index 3604ec90..8158dbb6 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "rcedit": "^0.7.0", "resolve": "^1.1.6", "run-series": "^1.1.1", - "sanitize-filename": "^1.6.0" + "sanitize-filename": "^1.6.0", + "semver": "^5.3.0" }, "devDependencies": { "buffer-equal": "^1.0.0", diff --git a/readme.md b/readme.md index 17423e3c..f63d5478 100644 --- a/readme.md +++ b/readme.md @@ -33,7 +33,7 @@ It generates executables/bundles for the following **target** platforms: * Windows (also known as `win32`, for both 32/64 bit) * OS X (also known as `darwin`) / [Mac App Store](http://electron.atom.io/docs/v0.36.0/tutorial/mac-app-store-submission-guide/) (also known as `mas`)* -* Linux (for both x86/x86_64) +* Linux (for x86, x86_64, and armv7l architectures) * *Note for OS X / MAS target bundles: the `.app` bundle can only be signed when building on a host OS X platform.* diff --git a/test/multitarget.js b/test/multitarget.js index 50bda733..ce9fe9b2 100644 --- a/test/multitarget.js +++ b/test/multitarget.js @@ -25,7 +25,7 @@ function verifyPackageExistence (finalPaths, callback) { util.setup() test('all test', function (t) { - t.timeoutAfter(config.timeout * 5) // 4-5 packages will be built during this test + t.timeoutAfter(config.timeout * 7) // 5-7 packages will be built during this test var opts = { name: 'basicTest', @@ -34,13 +34,13 @@ test('all test', function (t) { all: true } - var expectedAppCount = 6 + var expectedAppCount = 7 waterfall([ function (cb) { if (process.platform === 'win32') { isAdmin().then((admin) => { - if (!admin) expectedAppCount = 4 + if (!admin) expectedAppCount = 5 cb() }) } else { @@ -92,8 +92,9 @@ test('platform=all test (one arch)', function (t) { util.teardown() util.setup() -test('arch=all test (one platform)', function (t) { - t.timeoutAfter(config.timeout * 2) // 2 packages will be built during this test +test('arch=all test (one platform)', (t) => { + const LINUX_ARCH_COUNT = 3 + t.timeoutAfter(config.timeout * LINUX_ARCH_COUNT) var opts = { name: 'basicTest', @@ -107,10 +108,10 @@ test('arch=all test (one platform)', function (t) { function (cb) { packager(opts, cb) }, function (finalPaths, cb) { - t.equal(finalPaths.length, 2, 'packager call should resolve with expected number of paths') + t.equal(finalPaths.length, LINUX_ARCH_COUNT, 'packager call should resolve with expected number of paths') verifyPackageExistence(finalPaths, cb) }, function (exists, cb) { - t.true(exists, 'Packages should be generated for both architectures') + t.true(exists, 'Packages should be generated for all expected architectures') cb() } ], function (err) { diff --git a/usage.txt b/usage.txt index 3d2ba464..92197a9a 100644 --- a/usage.txt +++ b/usage.txt @@ -17,8 +17,8 @@ appname the name of the app, if it needs to be different from the "pr all equivalent to --platform=all --arch=all app-copyright human-readable copyright line for the app app-version release version to set for the app -arch all, or one or more of: ia32, x64 (comma-delimited if multiple). Defaults to - the host arch +arch all, or one or more of: ia32, x64, armv7l (comma-delimited if multiple). Defaults + to the host arch asar whether to package the source code within your app into an archive. You can either pass --asar by itself to use the default configuration, OR use dot notation to configure a list of sub-properties, e.g. --asar.unpackDir=sub_dir - do not use