From 417445546873d83ef03e99ba88ed2bfdfc3d2638 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 12 Sep 2017 18:22:26 -0700 Subject: [PATCH 1/2] Add hostArch from Electron Forge --- targets.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/targets.js b/targets.js index d57af38f..b780fb0c 100644 --- a/targets.js +++ b/targets.js @@ -72,8 +72,18 @@ 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 = { createPlatformArchPairs: createPlatformArchPairs, + hostArch: hostArch, officialArchs: officialArchs, officialPlatformArchCombos: officialPlatformArchCombos, officialPlatforms: officialPlatforms, @@ -84,8 +94,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') { From 43397e8a473bfb5d09d0ef608050038cf33163cf Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Tue, 12 Sep 2017 18:30:12 -0700 Subject: [PATCH 2/2] Add allOfficialArchsForPlatformAndVersion() --- targets.js | 8 ++++++++ test/targets.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/targets.js b/targets.js index b780fb0c..b4d06e8b 100644 --- a/targets.js +++ b/targets.js @@ -82,6 +82,14 @@ 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') + } + + return archs + }, createPlatformArchPairs: createPlatformArchPairs, hostArch: hostArch, officialArchs: officialArchs, diff --git a/test/targets.js b/test/targets.js index 0b19d930..27d59654 100644 --- a/test/targets.js +++ b/test/targets.js @@ -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,