Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target arch API #727

Merged
merged 2 commits into from Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 28 additions & 2 deletions targets.js
Expand Up @@ -72,8 +72,26 @@ function warnIfAllNotSpecified (opts, message) {
}
}

function hostArch () {
/* istanbul ignore if */
if (process.arch === 'arm' && process.config.variables.arm_version === '7') {
return 'armv7l'
}

return process.arch
}

module.exports = {
allOfficialArchsForPlatformAndVersion: function allOfficialArchsForPlatformAndVersion (platform, electronVersion) {
const archs = officialPlatformArchCombos[platform]
if (platform === 'linux' && !officialLinuxARM64BuildExists({electronVersion: electronVersion})) {
return archs.filter((arch) => arch !== 'arm64')
}

return archs
},
createPlatformArchPairs: createPlatformArchPairs,
hostArch: hostArch,
officialArchs: officialArchs,
officialPlatformArchCombos: officialPlatformArchCombos,
officialPlatforms: officialPlatforms,
Expand All @@ -84,8 +102,16 @@ module.exports = {
validateListFromOptions: function validateListFromOptions (opts, name) {
if (opts.all) return Array.from(supported[name].values())

let list = opts[name] || process[name]
if (list === 'all') return Array.from(supported[name].values())
let list = opts[name]
if (!list) {
if (name === 'arch') {
list = hostArch()
} else {
list = process[name]
}
} else if (list === 'all') {
return Array.from(supported[name].values())
}

if (!Array.isArray(list)) {
if (typeof list === 'string') {
Expand Down
18 changes: 18 additions & 0 deletions test/targets.js
Expand Up @@ -30,6 +30,24 @@ function testCombinations (testcaseDescription, arch, platform) {
'Packages should be generated for all combinations of specified archs and platforms')
}

test('allOfficialArchsForPlatformAndVersion is undefined for unknown platforms', (t) => {
t.equal(targets.allOfficialArchsForPlatformAndVersion('unknown', '1.0.0'), undefined)
t.end()
})

test('allOfficialArchsForPlatformAndVersion returns the correct arches for a known platform', (t) => {
t.deepEqual(targets.allOfficialArchsForPlatformAndVersion('darwin', '1.0.0'), ['x64'])
t.end()
})

test('allOfficialArchsForPlatformAndVersion returns arm64 when the correct version is specified', (t) => {
t.notEqual(targets.allOfficialArchsForPlatformAndVersion('linux', '1.8.0').indexOf('arm64'), -1,
'should be found when version is >= 1.8.0')
t.equal(targets.allOfficialArchsForPlatformAndVersion('linux', '1.7.0').indexOf('arm64'), -1,
'should not be found when version is < 1.8.0')
t.end()
})

test('validateListFromOptions does not take non-Array/String values', (t) => {
targets.supported.digits = new Set(['64', '65'])
t.notOk(targets.validateListFromOptions({digits: 64}, 'digits') instanceof Array,
Expand Down