Skip to content
Permalink
Browse files

fix(mac): mac build fails against electron v4.0.0-beta.3

Close #3412
  • Loading branch information...
christophpre authored and develar committed Oct 26, 2018
1 parent 44c8fd0 commit 7fc9a2965358fdeff3d757633695609236d7759d
@@ -3,15 +3,15 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:10.10.0
- image: circleci/node:10.12.0
steps:
- checkout
- restore_cache:
keys:
- deps-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- v-2.0.5-electron
- v-3.0.6-electron
- run:
command: yarn --frozen-lockfile
- run:
@@ -23,7 +23,7 @@ jobs:
- run:
command: node ./test/out/helpers/downloadElectron.js
- save_cache:
key: v-2.0.5-electron
key: v-3.0.6-electron
paths:
- ~/.cache/electron

@@ -41,7 +41,7 @@ jobs:
- deps-{{ checksum "yarn.lock" }}
- restore_cache:
keys:
- v-2.0.5-electron
- v-3.0.6-electron
# because in the build job we use circleci docker image and circleci restores cache to original user home
- run:
command: |
@@ -1,10 +1,10 @@
import BluebirdPromise from "bluebird-lst"
import { asArray, getPlatformIconFileName, InvalidConfigurationError, log } from "builder-util"
import { copyOrLinkFile, unlinkIfExists } from "builder-util/out/fs"
import { orIfFileNotExist } from "builder-util/out/promise"
import { readFile, rename, utimes, writeFile } from "fs-extra-p"
import * as path from "path"
import { build as buildPlist, parse as parsePlist } from "plist"
import { orIfFileNotExist } from "builder-util/out/promise"
import { filterCFBundleIdentifier } from "../appInfo"
import { AsarIntegrity } from "../asar/integrity"
import MacPackager from "../macPackager"
@@ -14,14 +14,25 @@ function doRename(basePath: string, oldName: string, newName: string) {
return rename(path.join(basePath, oldName), path.join(basePath, newName))
}

function moveHelpers(frameworksPath: string, appName: string, prefix: string): Promise<any> {
return BluebirdPromise.map([" Helper", " Helper EH", " Helper NP"], suffix => {
function moveHelpers(helperSuffixes: Array<string>, frameworksPath: string, appName: string, prefix: string): Promise<any> {
return BluebirdPromise.map(helperSuffixes, suffix => {
const executableBasePath = path.join(frameworksPath, `${prefix}${suffix}.app`, "Contents", "MacOS")
return doRename(executableBasePath, `${prefix}${suffix}`, appName + suffix)
.then(() => doRename(frameworksPath, `${prefix}${suffix}.app`, `${appName}${suffix}.app`))
})
}

function getAvailableHelperSuffixes(helperEHPlist: string | null, helperNPPlist: string | null) {
const result = [" Helper"]
if (helperEHPlist != null) {
result.push(" Helper EH")
}
if (helperNPPlist != null) {
result.push(" Helper NP")
}
return result
}

/** @internal */
export async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null) {
const appInfo = packager.appInfo
@@ -48,8 +59,8 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
], it => it == null ? it : orIfFileNotExist(readFile(it, "utf8"), null))
const appPlist = parsePlist(fileContents[0]!!)
const helperPlist = parsePlist(fileContents[1]!!)
const helperEHPlist = parsePlist(fileContents[2]!!)
const helperNPPlist = parsePlist(fileContents[3]!!)
const helperEHPlist = fileContents[2] == null ? null : parsePlist(fileContents[2]!!)
const helperNPPlist = fileContents[3] == null ? null : parsePlist(fileContents[3]!!)
const helperLoginPlist = fileContents[4] == null ? null : parsePlist(fileContents[4]!!)

// if an extend-info file was supplied, copy its contents in first
@@ -66,31 +77,28 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
await packager.applyCommonInfo(appPlist, contentsPath)

helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperEHPlist.CFBundleExecutable = `${appFilename} Helper EH`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`
if (helperLoginPlist != null) {
helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`
}

helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperEHPlist.CFBundleDisplayName = `${appInfo.productName} Helper EH`
helperNPPlist.CFBundleDisplayName = `${appInfo.productName} Helper NP`
if (helperLoginPlist != null) {
helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperPlist.CFBundleVersion = appPlist.CFBundleVersion

function configureHelper(helper: any, postfix: string) {
helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`
helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`
helper.CFBundleIdentifier = `${helperBundleIdentifier}.${postfix}`
helper.CFBundleVersion = appPlist.CFBundleVersion
}

helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperEHPlist.CFBundleIdentifier = `${helperBundleIdentifier}.EH`
helperNPPlist.CFBundleIdentifier = `${helperBundleIdentifier}.NP`
if (helperEHPlist != null) {
configureHelper(helperEHPlist, "EH")
}
if (helperNPPlist != null) {
configureHelper(helperNPPlist, "NP")
}
if (helperLoginPlist != null) {
helperLoginPlist.CFBundleExecutable = `${appFilename} Login Helper`
helperLoginPlist.CFBundleDisplayName = `${appInfo.productName} Login Helper`
// noinspection SpellCheckingInspection
helperLoginPlist.CFBundleIdentifier = `${appInfo.macBundleIdentifier}.loginhelper`
}

helperPlist.CFBundleVersion = appPlist.CFBundleVersion
helperEHPlist.CFBundleVersion = appPlist.CFBundleVersion
helperNPPlist.CFBundleVersion = appPlist.CFBundleVersion
if (helperLoginPlist != null) {
helperLoginPlist.CFBundleVersion = appPlist.CFBundleVersion
}

@@ -109,8 +117,6 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
})
}

const resourcesPath = path.join(contentsPath, "Resources")

const fileAssociations = packager.fileAssociations
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
@@ -119,7 +125,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
let iconFile = appPlist.CFBundleIconFile
if (customIcon != null) {
iconFile = path.basename(customIcon)
await copyOrLinkFile(customIcon, path.join(resourcesPath, iconFile))
await copyOrLinkFile(customIcon, path.join(path.join(contentsPath, "Resources"), iconFile))
}

const result = {
@@ -143,15 +149,15 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
await Promise.all([
writeFile(appPlistFilename, buildPlist(appPlist)),
writeFile(helperPlistFilename, buildPlist(helperPlist)),
writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
helperEHPlist == null ? Promise.resolve() : writeFile(helperEHPlistFilename, buildPlist(helperEHPlist)),
helperNPPlist == null ? Promise.resolve() : writeFile(helperNPPlistFilename, buildPlist(helperNPPlist)),
helperLoginPlist == null ? Promise.resolve() : writeFile(helperLoginPlistFilename, buildPlist(helperLoginPlist)),
doRename(path.join(contentsPath, "MacOS"), packager.electronDistMacOsExecutableName, appPlist.CFBundleExecutable),
unlinkIfExists(path.join(appOutDir, "LICENSE")),
unlinkIfExists(path.join(appOutDir, "LICENSES.chromium.html")),
])

await moveHelpers(frameworksPath, appFilename, packager.electronDistMacOsExecutableName)
await moveHelpers(getAvailableHelperSuffixes(helperEHPlist, helperNPPlist), frameworksPath, appFilename, packager.electronDistMacOsExecutableName)

if (helperLoginPlist != null) {
const prefix = packager.electronDistMacOsExecutableName
@@ -160,6 +166,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix)
.then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`))
}

const appPath = path.join(appOutDir, `${appFilename}.app`)
await rename(path.dirname(contentsPath), appPath)
// https://github.com/electron-userland/electron-builder/issues/840
@@ -34,7 +34,6 @@ declare const PACKAGE_VERSION: string

async function createFrameworkInfo(configuration: Configuration, packager: Packager): Promise<Framework> {
if (configuration.protonNodeVersion != null) {
// require("proton-builder/out/ProtonFramework")
return createProtonFrameworkSupport(configuration.protonNodeVersion!!, packager.appInfo)
}
else {
@@ -18,7 +18,7 @@ async function main() {

let changed = false
for (const name of Object.keys(deps)) {
if (name.startsWith("electron-builder-") || name === "electron-publish" || name.endsWith("-builder") || name.startsWith("builder-") || name === "app-builder-lib") {
if (name.startsWith("electron-builder-") || name === "electron-publish" || name.endsWith("-builder") || name.startsWith("builder-") || name === "app-builder-lib" || name === "electron-is-dev") {
continue
}

@@ -1,4 +1,4 @@
electronVersion: 2.0.5
electronVersion: 3.0.6
appId: org.electron-builder.testApp
compression: store
npmRebuild: false
@@ -8,7 +8,7 @@
"author": "Foo Bar <foo@example.com>",
"license": "MIT",
"build": {
"electronVersion": "2.0.5",
"electronVersion": "3.0.6",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
@@ -7,7 +7,7 @@
"author": "Foo Bar <foo@example.com>",
"license": "MIT",
"build": {
"electronVersion": "2.0.5",
"electronVersion": "3.0.6",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
@@ -7,7 +7,7 @@
"author": "Foo Bar <foo@example.com>",
"license": "MIT",
"build": {
"electronVersion": "2.0.5",
"electronVersion": "3.0.6",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
@@ -7,7 +7,7 @@
"author": "Foo Bar <foo@example.com>",
"license": "MIT",
"build": {
"electronVersion": "2.0.5",
"electronVersion": "3.0.6",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
@@ -1,7 +1,7 @@
{
"private": true,
"build": {
"electronVersion": "2.0.5",
"electronVersion": "3.0.6",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
@@ -157,8 +157,6 @@ Object {
"CFBundleName": "Test App ßW",
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"DTSDKBuild": "14D125",
"DTSDKName": "macosx10.1010.10",
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSHighResolutionCapable": true,
@@ -245,8 +243,6 @@ Object {
"CFBundleName": "Test App ßW",
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"DTSDKBuild": "14D125",
"DTSDKName": "macosx10.1010.10",
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSHighResolutionCapable": true,
@@ -306,8 +302,6 @@ Object {
"CFBundleName": "Test App ßW",
"CFBundlePackageType": "APPL",
"CFBundleShortVersionString": "1.1.0",
"DTSDKBuild": "14D125",
"DTSDKName": "macosx10.1010.10",
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSHighResolutionCapable": true,
@@ -89,13 +89,12 @@ Array [
"lib/net45/msvcp140.dll",
"lib/net45/natives_blob.bin",
"lib/net45/node.dll",
"lib/net45/pdf_viewer_resources.pak",
"lib/net45/snapshot_blob.bin",
"lib/net45/Test App ßW.exe",
"lib/net45/Test App ßW_ExecutionStub.exe",
"lib/net45/ucrtbase.dll",
"lib/net45/ui_resources_200_percent.pak",
"lib/net45/Update.exe",
"lib/net45/v8_context_snapshot.bin",
"lib/net45/vcruntime140.dll",
"lib/net45/views_resources_200_percent.pak",
"lib/net45/locales/en-US.pak",
@@ -30,10 +30,9 @@ Array [
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/natives_blob.bin",
"/opt/Test App ßW/pdf_viewer_resources.pak",
"/opt/Test App ßW/snapshot_blob.bin",
"/opt/Test App ßW/testapp",
"/opt/Test App ßW/ui_resources_200_percent.pak",
"/opt/Test App ßW/v8_context_snapshot.bin",
"/opt/Test App ßW/views_resources_200_percent.pak",
"/usr/share/",
"/opt/Test App ßW/resources/",
@@ -107,10 +106,9 @@ Array [
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/natives_blob.bin",
"/opt/Test App ßW/pdf_viewer_resources.pak",
"/opt/Test App ßW/snapshot_blob.bin",
"/opt/Test App ßW/testapp",
"/opt/Test App ßW/ui_resources_200_percent.pak",
"/opt/Test App ßW/v8_context_snapshot.bin",
"/opt/Test App ßW/views_resources_200_percent.pak",
"/usr/share/",
"/opt/Test App ßW/resources/",
@@ -209,9 +207,8 @@ Array [
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/natives_blob.bin",
"/opt/Test App ßW/pdf_viewer_resources.pak",
"/opt/Test App ßW/snapshot_blob.bin",
"/opt/Test App ßW/ui_resources_200_percent.pak",
"/opt/Test App ßW/v8_context_snapshot.bin",
"/opt/Test App ßW/views_resources_200_percent.pak",
"/usr/share/",
"/opt/Test App ßW/resources/",
@@ -296,10 +293,9 @@ Array [
"/opt/Test App ßW/LICENSE.electron.txt",
"/opt/Test App ßW/LICENSES.chromium.html",
"/opt/Test App ßW/natives_blob.bin",
"/opt/Test App ßW/pdf_viewer_resources.pak",
"/opt/Test App ßW/snapshot_blob.bin",
"/opt/Test App ßW/testapp",
"/opt/Test App ßW/ui_resources_200_percent.pak",
"/opt/Test App ßW/v8_context_snapshot.bin",
"/opt/Test App ßW/views_resources_200_percent.pak",
"/usr/share/",
"/opt/Test App ßW/resources/",

0 comments on commit 7fc9a29

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