Skip to content

Commit f9c4c20

Browse files
committed
refactor(maker): use the target platform/arch API from Packager to determine "all" archs
Adds arm64 support to `make --arch=all`
1 parent 1e7c175 commit f9c4c20

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"electron-forge-template-react": "^1.0.2",
110110
"electron-forge-template-react-typescript": "^1.0.3",
111111
"electron-forge-template-vue": "^1.0.2",
112-
"electron-packager": "^9.0.0",
112+
"electron-packager": "^9.1.0",
113113
"electron-rebuild": "^1.6.0",
114114
"form-data": "^2.1.4",
115115
"fs-extra": "^4.0.0",

src/api/make.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import electronHostArch from '../util/electron-host-arch';
77
import getForgeConfig from '../util/forge-config';
88
import runHook from '../util/hook';
99
import { info, warn } from '../util/messages';
10+
import parseArchs from '../util/parse-archs';
1011
import readPackageJSON from '../util/read-package-json';
1112
import { requireSearchRaw } from '../util/require-search';
1213
import resolveDir from '../util/resolve-dir';
@@ -116,33 +117,15 @@ export default async (providedOptions = {}) => {
116117
warn(interactive, 'WARNING: Skipping the packaging step, this could result in an out of date build'.red);
117118
}
118119

119-
const declaredArch = arch;
120-
121120
info(interactive, 'Making for the following targets:', `${targets.join(', ')}`.cyan);
122121

123-
let targetArchs = declaredArch.split(',');
124-
if (declaredArch === 'all') {
125-
switch (platform) {
126-
case 'darwin':
127-
targetArchs = ['x64'];
128-
break;
129-
case 'linux':
130-
targetArchs = ['ia32', 'x64', 'armv7l'];
131-
break;
132-
case 'win32':
133-
default:
134-
targetArchs = ['ia32', 'x64'];
135-
break;
136-
}
137-
}
138-
139122
const packageJSON = await readPackageJSON(dir);
140123
const appName = forgeConfig.electronPackagerConfig.name || packageJSON.productName || packageJSON.name;
141124
let outputs = [];
142125

143126
await runHook(forgeConfig, 'preMake');
144127

145-
for (const targetArch of targetArchs) {
128+
for (const targetArch of parseArchs(platform, arch, packageJSON.devDependencies['electron-prebuilt-compile'])) {
146129
const packageDir = path.resolve(outDir, `${appName}-${platform}-${targetArch}`);
147130
if (!(await fs.pathExists(packageDir))) {
148131
throw new Error(`Couldn't find packaged app at: ${packageDir}`);

src/util/parse-archs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { allOfficialArchsForPlatformAndVersion } from 'electron-packager/targets';
2+
3+
export default function parseArchs(platform, declaredArch, electronVersion) {
4+
if (declaredArch === 'all') {
5+
return allOfficialArchsForPlatformAndVersion(platform, electronVersion) || ['x64'];
6+
}
7+
8+
return declaredArch.split(',');
9+
}

test/fast/parse-archs_spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect } from 'chai';
2+
3+
import parseArchs from '../../src/util/parse-archs';
4+
5+
describe('parse-archs', () => {
6+
it('should make an Array out of one arch', () => {
7+
expect(parseArchs('linux', 'x64', '1.7.0')).to.deep.equal(['x64']);
8+
});
9+
10+
it('should transform comma-separated values into an Array', () => {
11+
expect(parseArchs('linux', 'ia32,x64', '1.7.0')).to.deep.equal(['ia32', 'x64']);
12+
});
13+
14+
it('should use the official Electron arch list when arch is "all"', () => {
15+
expect(parseArchs('win32', 'all', '1.7.0')).to.deep.equal(['ia32', 'x64']);
16+
});
17+
18+
it('should default to [x64] when the platform is unknown', () => {
19+
expect(parseArchs('nonexistent', 'all', '1.7.0')).to.deep.equal(['x64']);
20+
});
21+
});

0 commit comments

Comments
 (0)