Skip to content

Commit

Permalink
Merge pull request #800 from electron-userland/mips64el-support
Browse files Browse the repository at this point in the history
Add support for official MIPS64EL arch on Linux
  • Loading branch information
malept committed Feb 7, 2018
2 parents f09ac9e + b6e4082 commit aacf297
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
9 changes: 9 additions & 0 deletions NEWS.md
Expand Up @@ -4,6 +4,15 @@

[Unreleased]: https://github.com/electron-userland/electron-packager/compare/v10.1.2...master

### Added

* `linux` platform, `mips64el` arch builds (Electron 1.8.2-beta.5 and above) (#800)

### Changed

* `all` or `platform=linux, arch=all` now include `arch=mips64el` if the Electron version specified
is 1.8.2-beta.5 or above (#800)

## [10.1.2] - 2018-01-26

[10.1.2]: https://github.com/electron-userland/electron-packager/compare/v10.1.1...v10.1.2
Expand Down
3 changes: 2 additions & 1 deletion docs/api.md
Expand Up @@ -90,7 +90,8 @@ 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`, `armv7l`, `arm64` _(Electron 1.8.0 and above)_, `all`
Allowed values: `ia32`, `x64`, `armv7l`, `arm64` _(Electron 1.8.0 and above)_, `mips64el`
_(Electron 1.8.2-beta.5 and above)_, `all`

The target system architecture(s) to build for.
Not required if the [`all`](#all) option is set.
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -52,7 +52,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 x86, x86_64, armv7l, and arm64 architectures)
* Linux (for x86, x86_64, armv7l, arm64, and mips64el 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
28 changes: 19 additions & 9 deletions targets.js
Expand Up @@ -4,15 +4,20 @@ const common = require('./common')
const execSync = require('child_process').execSync
const semver = require('semver')

const officialArchs = ['ia32', 'x64', 'armv7l', 'arm64']
const officialArchs = ['ia32', 'x64', 'armv7l', 'arm64', 'mips64el']
const officialPlatforms = ['darwin', 'linux', 'mas', 'win32']
const officialPlatformArchCombos = {
darwin: ['x64'],
linux: ['ia32', 'x64', 'armv7l', 'arm64'],
linux: ['ia32', 'x64', 'armv7l', 'arm64', 'mips64el'],
mas: ['x64'],
win32: ['ia32', 'x64']
}

const minimumLinuxArchBuildVersions = {
arm64: '1.8.0',
mips64el: '1.8.2-beta.5'
}

// Maps to module filename for each platform (lazy-required if used)
const osModules = {
darwin: './mac',
Expand All @@ -34,9 +39,12 @@ function createPlatformArchPairs (opts, selectedPlatforms, selectedArchs, ignore
if (!validOfficialPlatformArch(opts, platform, arch)) {
warnIfAllNotSpecified(opts, `The platform/arch combination ${platform}/${arch} is not currently supported by Electron Packager`)
continue
} else if (platform === 'linux' && arch === 'arm64' && !officialLinuxARM64BuildExists(opts)) {
warnIfAllNotSpecified(opts, 'Official linux/arm64 support only exists in Electron 1.8.0 and above')
continue
} else if (platform === 'linux') {
const minimumBuildVersion = minimumLinuxArchBuildVersions[arch]
if (minimumBuildVersion && !officialLinuxBuildExists(opts, minimumBuildVersion)) {
warnIfAllNotSpecified(opts, `Official linux/${arch} support only exists in Electron ${minimumBuildVersion} and above`)
continue
}
}
if (typeof ignoreFunc === 'function' && ignoreFunc(platform, arch)) continue
}
Expand All @@ -59,8 +67,8 @@ function validOfficialPlatformArch (opts, platform, arch) {
return officialPlatformArchCombos[platform] && officialPlatformArchCombos[platform].indexOf(arch) !== -1
}

function officialLinuxARM64BuildExists (opts) {
return semver.gte(opts.electronVersion, '1.8.0')
function officialLinuxBuildExists (opts, minimumBuildVersion) {
return semver.gte(opts.electronVersion, minimumBuildVersion)
}

function allPlatformsOrArchsSpecified (opts) {
Expand Down Expand Up @@ -91,8 +99,10 @@ function hostArch () {
module.exports = {
allOfficialArchsForPlatformAndVersion: function allOfficialArchsForPlatformAndVersion (platform, electronVersion) {
const archs = officialPlatformArchCombos[platform]
if (platform === 'linux' && !officialLinuxARM64BuildExists({electronVersion: electronVersion})) {
return archs.filter((arch) => arch !== 'arm64')
if (platform === 'linux') {
const excludedArchs = Object.keys(minimumLinuxArchBuildVersions)
.filter(arch => !officialLinuxBuildExists({electronVersion: electronVersion}, minimumLinuxArchBuildVersions[arch]))
return archs.filter(arch => excludedArchs.indexOf(arch) === -1)
}

return archs
Expand Down
2 changes: 1 addition & 1 deletion test/_util.js
Expand Up @@ -44,7 +44,7 @@ function testSinglePlatform (name, testFunction, testFunctionArgs, parallel) {
}

module.exports = {
allPlatformArchCombosCount: 8,
allPlatformArchCombosCount: 9,
areFilesEqual: function areFilesEqual (file1, file2) {
let buffer1, buffer2

Expand Down
17 changes: 13 additions & 4 deletions test/targets.js
Expand Up @@ -45,6 +45,13 @@ test('allOfficialArchsForPlatformAndVersion returns arm64 when the correct versi
'should not be found when version is < 1.8.0')
})

test('allOfficialArchsForPlatformAndVersion returns mips64el when the correct version is specified', t => {
t.not(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.2').indexOf('mips64el'), -1,
'should be found when version is >= 1.8.2-beta.5')
t.is(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').indexOf('mips64el'), -1,
'should not be found when version is < 1.8.2-beta.5')
})

test('validateListFromOptions does not take non-Array/String values', t => {
targets.supported.digits = new Set(['64', '65'])
t.false(targets.validateListFromOptions({digits: 64}, 'digits') instanceof Array,
Expand All @@ -63,13 +70,13 @@ test('validateListFromOptions works for armv7l host and target arch', t => {
sandbox.restore()
})

testMultiTarget('build for all available official targets', {all: true, electronVersion: '1.8.0'},
testMultiTarget('build for all available official targets', {all: true, electronVersion: '1.8.2'},
util.allPlatformArchCombosCount,
'Packages should be generated for all possible platforms')
testMultiTarget('build for all available official targets for a version without arm64 support',
testMultiTarget('build for all available official targets for a version without arm64 or mips64el support',
{all: true},
util.allPlatformArchCombosCount - 1,
'Packages should be generated for all possible platforms (except arm64)')
util.allPlatformArchCombosCount - 2,
'Packages should be generated for all possible platforms (except arm64 and mips64el)')
testMultiTarget('platform=all (one arch)', {arch: 'ia32', platform: 'all'}, 2,
'Packages should be generated for both 32-bit platforms')
testMultiTarget('arch=all test (one platform)', {arch: 'all', platform: 'linux'}, 3,
Expand Down Expand Up @@ -125,6 +132,8 @@ test('hostArch cannot determine ARM version', t => {
testMultiTarget('invalid official combination', {arch: 'ia32', platform: 'darwin'}, 0, 'Package should not be generated for invalid official combination')
testMultiTarget('platform=linux and arch=arm64 with a supported official Electron version', {arch: 'arm64', platform: 'linux', electronVersion: '1.8.0'}, 1, 'Package should be generated for arm64')
testMultiTarget('platform=linux and arch=arm64 with an unsupported official Electron version', {arch: 'arm64', platform: 'linux'}, 0, 'Package should not be generated for arm64')
testMultiTarget('platform=linux and arch=mips64el with a supported official Electron version', {arch: 'mips64el', platform: 'linux', electronVersion: '1.8.2-beta.5'}, 1, 'Package should be generated for mips64el')
testMultiTarget('platform=linux and arch=mips64el with an unsupported official Electron version', {arch: 'mips64el', platform: 'linux'}, 0, 'Package should not be generated for mips64el')
testMultiTarget('unofficial arch', {arch: 'z80', platform: 'linux', download: {mirror: 'mirror'}}, 1,
'Package should be generated for non-standard arch from non-official mirror')
testMultiTarget('unofficial platform', {arch: 'ia32', platform: 'minix', download: {mirror: 'mirror'}}, 1,
Expand Down
4 changes: 2 additions & 2 deletions usage.txt
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, armv7l, arm64 (comma-delimited if multiple).
Defaults to the host arch
arch all, or one or more of: ia32, x64, armv7l, arm64, mips64el (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 aacf297

Please sign in to comment.