Skip to content

Commit

Permalink
Add Linux ARMv7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Sep 3, 2016
1 parent 97d0847 commit 0ef914f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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))
}
Expand All @@ -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)
},
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)<sup>*</sup>
* Linux (for both x86/x86_64)
* Linux (for x86, x86_64, and armv7l architectures)

<sup>*</sup> *Note for OS X / MAS target bundles: the `.app` bundle can only be signed when building on a host OS X platform.*

Expand Down
15 changes: 8 additions & 7 deletions test/multitarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 {
Expand Down Expand Up @@ -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',
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0ef914f

Please sign in to comment.