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

feat:(mac): Apple Silicon builds (arm64) #5426

Merged
merged 5 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- install-dep-cache-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- v-8.2.5-electron
- v-11.0.0-electron
- run:
command: node .yarn/releases/yarn-2.2.2.cjs install
- run:
Expand All @@ -25,7 +25,7 @@ jobs:
- run:
command: node .yarn/releases/yarn-2.2.2.cjs node ./test/out/helpers/downloadElectron.js
- save_cache:
key: v-8.2.5-electron
key: v-11.0.0-electron
paths:
- ~/.cache/electron

Expand All @@ -43,7 +43,7 @@ jobs:
- install-dep-cache-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- v-8.2.5-electron
- v-11.0.0-electron
# because in the build job we use circleci docker image and circleci restores cache to original user home
- run:
command: |
Expand Down
3 changes: 0 additions & 3 deletions packages/app-builder-lib/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ export class Platform {
}

const archToType = new Map()
if (this === Platform.MAC) {
archs = [Arch.x64]
}

for (const arch of (archs == null || archs.length === 0 ? [archFromString(process.arch)] : archs)) {
archToType.set(arch, type == null ? [] : (Array.isArray(type) ? type : [type]))
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
if (!hasMas || targets.length > 1) {
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged
nonMasPromise = (prepackaged ? Promise.resolve() : this.doPack(outDir, path.dirname(appPath), this.platform.nodeName as ElectronPlatformName, arch, this.platformSpecificBuildOptions, targets))
.then(() => this.packageInDistributableFormat(appPath, Arch.x64, targets, taskManager))
.then(() => this.packageInDistributableFormat(appPath, arch, targets, taskManager))
}

for (const target of targets) {
Expand Down
4 changes: 0 additions & 4 deletions packages/app-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ export class Packager {

function processTargets(platform: Platform, types: Array<string>) {
function commonArch(currentIfNotSpecified: boolean): Array<Arch> {
if (platform === Platform.MAC) {
return currentIfNotSpecified ? [Arch.x64] : []
}

const result = Array<Arch>()
return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
// tslint:disable-next-line:no-invalid-template-strings
pattern = defaultPattern || "${productName}-${version}-${arch}.${ext}"
}
else {
else if (this.platform !== Platform.MAC) {
// https://github.com/electron-userland/electron-builder/issues/3510
// always respect arch in user custom artifact pattern
skipArchIfX64 = false
Expand All @@ -487,7 +487,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

private computeArtifactName(pattern: any, ext: string, arch: Arch | null | undefined): string {
const archName = arch == null ? null : getArtifactArchName(arch, ext)
return this.expandMacro(pattern, this.platform === Platform.MAC ? null : archName, {
return this.expandMacro(pattern, archName, {
ext
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/targets/targetFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function computeArchToTargetNamesMap(raw: Map<Arch, Array<string>>, platf
}
}

const defaultArchs: Array<ArchType> = raw.size === 0 ? [platform === Platform.MAC ? "x64" : process.arch as ArchType] : Array.from(raw.keys()).map(it => Arch[it] as ArchType)
const defaultArchs: Array<ArchType> = raw.size === 0 ? [process.arch as ArchType] : Array.from(raw.keys()).map(it => Arch[it] as ArchType)
const result = new Map(raw)
for (const target of asArray(platformPackager.platformSpecificBuildOptions.target).map<TargetConfiguration>(it => typeof it === "string" ? {target: it} : it)) {
let name = target.target
Expand Down
12 changes: 7 additions & 5 deletions packages/dmg-builder/src/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { findIdentity, isSignAllowed } from "app-builder-lib/out/codeSign/macCod
import MacPackager from "app-builder-lib/out/macPackager"
import { createBlockmap } from "app-builder-lib/out/targets/differentialUpdateInfoBuilder"
import { executeAppBuilderAsJson } from "app-builder-lib/out/util/appBuilder"
import { Arch, AsyncTaskManager, exec, InvalidConfigurationError, isEmptyOrSpaces, log, spawn } from "builder-util"
import { Arch, AsyncTaskManager, exec, getArchSuffix, InvalidConfigurationError, isEmptyOrSpaces, log, spawn } from "builder-util"
import { CancellationToken } from "builder-util-runtime"
import { copyDir, copyFile, exists, statOrNull } from "builder-util/out/fs"
import { stat } from "fs-extra"
Expand All @@ -23,15 +23,15 @@ export class DmgTarget extends Target {
async build(appPath: string, arch: Arch) {
const packager = this.packager
// tslint:disable-next-line:no-invalid-template-strings
const artifactName = packager.expandArtifactNamePattern(packager.config.dmg, "dmg", null, "${productName}-" + (packager.platformSpecificBuildOptions.bundleShortVersion || "${version}") + ".${ext}")
const artifactName = packager.expandArtifactNamePattern(this.options, "dmg", arch, "${productName}-" + (packager.platformSpecificBuildOptions.bundleShortVersion || "${version}") + "-${arch}.${ext}", true)
const artifactPath = path.join(this.outDir, artifactName)
await packager.info.callArtifactBuildStarted({
targetPresentableName: "DMG",
file: artifactPath,
arch,
})

const volumeName = sanitizeFileName(this.computeVolumeName(this.options.title))
const volumeName = sanitizeFileName(this.computeVolumeName(arch, this.options.title))

const tempDmg = await createStageDmg(await packager.getTempFile(".dmg"), appPath, volumeName)

Expand Down Expand Up @@ -115,15 +115,17 @@ export class DmgTarget extends Target {
await exec("codesign", args)
}

computeVolumeName(custom?: string | null): string {
computeVolumeName(arch: Arch, custom?: string | null): string {
const appInfo = this.packager.appInfo
const shortVersion = this.packager.platformSpecificBuildOptions.bundleShortVersion || appInfo.version
const archString = getArchSuffix(arch)

if (custom == null) {
return `${appInfo.productFilename} ${shortVersion}`
return `${appInfo.productFilename} ${shortVersion}${archString}`
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
}

return custom
.replace(/\${arch}/g, archString)
.replace(/\${shortVersion}/g, shortVersion)
.replace(/\${version}/g, appInfo.version)
.replace(/\${name}/g, appInfo.name)
Expand Down
6 changes: 1 addition & 5 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export function normalizeOptions(args: CliOptions): BuildOptions {

function processTargets(platform: Platform, types: Array<string>) {
function commonArch(currentIfNotSpecified: boolean): Array<Arch> {
if (platform === Platform.MAC) {
return args.x64 || currentIfNotSpecified ? [Arch.x64] : []
}

const result = Array<Arch>()
if (args.x64) {
result.push(Arch.x64)
Expand Down Expand Up @@ -202,7 +198,7 @@ export function coerceTypes(host: any): any {
export function createTargets(platforms: Array<Platform>, type?: string | null, arch?: string | null): Map<Platform, Map<Arch, Array<string>>> {
const targets = new Map<Platform, Map<Arch, Array<string>>>()
for (const platform of platforms) {
const archs = platform === Platform.MAC ? [Arch.x64] : (arch === "all" ? [Arch.x64, Arch.ia32] : [archFromString(arch == null ? process.arch : arch)])
const archs = (arch === "all" ? (platform === Platform.MAC ? [Arch.x64, Arch.arm64] : [Arch.x64, Arch.ia32]) : [archFromString(arch == null ? process.arch : arch)])
const archToType = new Map<Arch, Array<string>>()
targets.set(platform, archToType)

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app-build-sub/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
electronVersion: 8.2.5
electronVersion: 11.0.0
appId: org.electron-builder.testApp
compression: store
npmRebuild: false
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app-one/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "8.2.5",
"electronVersion": "11.0.0",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "8.2.5",
"electronVersion": "11.0.0",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "8.2.5",
"electronVersion": "11.0.0",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "8.2.5",
"electronVersion": "11.0.0",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"build": {
"electronVersion": "8.2.5",
"electronVersion": "11.0.0",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
3 changes: 3 additions & 0 deletions test/snapshots/PublishManagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Object {
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"LSApplicationCategoryType": "your.app.category.type",
"LSRequiresNativeExecution": true,
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
Expand Down Expand Up @@ -273,6 +274,7 @@ Object {
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"LSApplicationCategoryType": "your.app.category.type",
"LSRequiresNativeExecution": true,
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
Expand Down Expand Up @@ -349,6 +351,7 @@ Object {
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"LSApplicationCategoryType": "your.app.category.type",
"LSRequiresNativeExecution": true,
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
Expand Down
1 change: 1 addition & 0 deletions test/snapshots/filesTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Array [
"lib/net45/v8_context_snapshot.bin",
"lib/net45/vk_swiftshader.dll",
"lib/net45/vk_swiftshader_icd.json",
"lib/net45/vulkan-1.dll",
"lib/net45/locales/en-US.pak",
"lib/net45/resources/app.asar",
"lib/net45/resources/platformSpecificR",
Expand Down
12 changes: 6 additions & 6 deletions test/snapshots/linux/debTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Array [
"/opt/Test App ßW/chrome-sandbox",
"/opt/Test App ßW/chrome_100_percent.pak",
"/opt/Test App ßW/chrome_200_percent.pak",
"/opt/Test App ßW/crashpad_handler",
"/opt/Test App ßW/icudtl.dat",
"/opt/Test App ßW/libEGL.so",
"/opt/Test App ßW/libffmpeg.so",
"/opt/Test App ßW/libGLESv2.so",
"/opt/Test App ßW/libvk_swiftshader.so",
"/opt/Test App ßW/libvulkan.so",
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/resources.pak",
Expand Down Expand Up @@ -99,12 +99,12 @@ Array [
"/opt/Test App ßW/chrome-sandbox",
"/opt/Test App ßW/chrome_100_percent.pak",
"/opt/Test App ßW/chrome_200_percent.pak",
"/opt/Test App ßW/crashpad_handler",
"/opt/Test App ßW/icudtl.dat",
"/opt/Test App ßW/libEGL.so",
"/opt/Test App ßW/libffmpeg.so",
"/opt/Test App ßW/libGLESv2.so",
"/opt/Test App ßW/libvk_swiftshader.so",
"/opt/Test App ßW/libvulkan.so",
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/resources.pak",
Expand Down Expand Up @@ -186,12 +186,12 @@ Array [
"/opt/Test App ßW/chrome-sandbox",
"/opt/Test App ßW/chrome_100_percent.pak",
"/opt/Test App ßW/chrome_200_percent.pak",
"/opt/Test App ßW/crashpad_handler",
"/opt/Test App ßW/icudtl.dat",
"/opt/Test App ßW/libEGL.so",
"/opt/Test App ßW/libffmpeg.so",
"/opt/Test App ßW/libGLESv2.so",
"/opt/Test App ßW/libvk_swiftshader.so",
"/opt/Test App ßW/libvulkan.so",
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/resources.pak",
Expand Down Expand Up @@ -271,12 +271,12 @@ Array [
"/opt/Test App ßW/chrome-sandbox",
"/opt/Test App ßW/chrome_100_percent.pak",
"/opt/Test App ßW/chrome_200_percent.pak",
"/opt/Test App ßW/crashpad_handler",
"/opt/Test App ßW/icudtl.dat",
"/opt/Test App ßW/libEGL.so",
"/opt/Test App ßW/libffmpeg.so",
"/opt/Test App ßW/libGLESv2.so",
"/opt/Test App ßW/libvk_swiftshader.so",
"/opt/Test App ßW/libvulkan.so",
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/resources.pak",
Expand Down Expand Up @@ -357,12 +357,12 @@ Array [
"/opt/Test App ßW/chrome-sandbox",
"/opt/Test App ßW/chrome_100_percent.pak",
"/opt/Test App ßW/chrome_200_percent.pak",
"/opt/Test App ßW/crashpad_handler",
"/opt/Test App ßW/icudtl.dat",
"/opt/Test App ßW/libEGL.so",
"/opt/Test App ßW/libffmpeg.so",
"/opt/Test App ßW/libGLESv2.so",
"/opt/Test App ßW/libvk_swiftshader.so",
"/opt/Test App ßW/libvulkan.so",
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/resources.pak",
Expand Down Expand Up @@ -471,12 +471,12 @@ Array [
"/opt/foo/chrome-sandbox",
"/opt/foo/chrome_100_percent.pak",
"/opt/foo/chrome_200_percent.pak",
"/opt/foo/crashpad_handler",
"/opt/foo/icudtl.dat",
"/opt/foo/libEGL.so",
"/opt/foo/libffmpeg.so",
"/opt/foo/libGLESv2.so",
"/opt/foo/libvk_swiftshader.so",
"/opt/foo/libvulkan.so",
"/opt/foo/LICENSE.electron.txt",
"/opt/foo/LICENSES.chromium.html",
"/opt/foo/resources.pak",
Expand Down
Loading