Skip to content
Permalink
Browse files

refactor(maker): use the target platform/arch API from Packager to de…

…termine "all" archs

Adds arm64 support to `make --arch=all`
  • Loading branch information
malept committed Sep 10, 2017
1 parent 1e7c175 commit f9c4c20c3540877c758800992d698d8a98569f4c
Showing with 33 additions and 20 deletions.
  1. +1 −1 package.json
  2. +2 −19 src/api/make.js
  3. +9 −0 src/util/parse-archs.js
  4. +21 −0 test/fast/parse-archs_spec.js
@@ -109,7 +109,7 @@
"electron-forge-template-react": "^1.0.2",
"electron-forge-template-react-typescript": "^1.0.3",
"electron-forge-template-vue": "^1.0.2",
"electron-packager": "^9.0.0",
"electron-packager": "^9.1.0",
"electron-rebuild": "^1.6.0",
"form-data": "^2.1.4",
"fs-extra": "^4.0.0",
@@ -7,6 +7,7 @@ import electronHostArch from '../util/electron-host-arch';
import getForgeConfig from '../util/forge-config';
import runHook from '../util/hook';
import { info, warn } from '../util/messages';
import parseArchs from '../util/parse-archs';
import readPackageJSON from '../util/read-package-json';
import { requireSearchRaw } from '../util/require-search';
import resolveDir from '../util/resolve-dir';
@@ -116,33 +117,15 @@ export default async (providedOptions = {}) => {
warn(interactive, 'WARNING: Skipping the packaging step, this could result in an out of date build'.red);
}

const declaredArch = arch;

info(interactive, 'Making for the following targets:', `${targets.join(', ')}`.cyan);

let targetArchs = declaredArch.split(',');
if (declaredArch === 'all') {
switch (platform) {
case 'darwin':
targetArchs = ['x64'];
break;
case 'linux':
targetArchs = ['ia32', 'x64', 'armv7l'];
break;
case 'win32':
default:
targetArchs = ['ia32', 'x64'];
break;
}
}

const packageJSON = await readPackageJSON(dir);
const appName = forgeConfig.electronPackagerConfig.name || packageJSON.productName || packageJSON.name;
let outputs = [];

await runHook(forgeConfig, 'preMake');

for (const targetArch of targetArchs) {
for (const targetArch of parseArchs(platform, arch, packageJSON.devDependencies['electron-prebuilt-compile'])) {
const packageDir = path.resolve(outDir, `${appName}-${platform}-${targetArch}`);
if (!(await fs.pathExists(packageDir))) {
throw new Error(`Couldn't find packaged app at: ${packageDir}`);
@@ -0,0 +1,9 @@
import { allOfficialArchsForPlatformAndVersion } from 'electron-packager/targets';

export default function parseArchs(platform, declaredArch, electronVersion) {
if (declaredArch === 'all') {
return allOfficialArchsForPlatformAndVersion(platform, electronVersion) || ['x64'];
}

return declaredArch.split(',');
}
@@ -0,0 +1,21 @@
import { expect } from 'chai';

import parseArchs from '../../src/util/parse-archs';

describe('parse-archs', () => {
it('should make an Array out of one arch', () => {
expect(parseArchs('linux', 'x64', '1.7.0')).to.deep.equal(['x64']);
});

it('should transform comma-separated values into an Array', () => {
expect(parseArchs('linux', 'ia32,x64', '1.7.0')).to.deep.equal(['ia32', 'x64']);
});

it('should use the official Electron arch list when arch is "all"', () => {
expect(parseArchs('win32', 'all', '1.7.0')).to.deep.equal(['ia32', 'x64']);
});

it('should default to [x64] when the platform is unknown', () => {
expect(parseArchs('nonexistent', 'all', '1.7.0')).to.deep.equal(['x64']);
});
});

0 comments on commit f9c4c20

Please sign in to comment.
You can’t perform that action at this time.