-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate @electron/universal (#1346)
* feat: integrate @electron/universal * chore: fix platform typo * spec: add universal generation tests * spec: fix tests * fix: add universal to supported list for mas * spec: fix tests * spec: fix tests * docs: update usage * Update README.md * Update usage.txt Co-authored-by: Erick Zhao <erick@hotmail.ca>
- Loading branch information
1 parent
b66e97f
commit c6849c2
Showing
11 changed files
with
137 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict' | ||
|
||
const universal = require('@electron/universal') | ||
const common = require('./common') | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
|
||
async function packageUniversalMac (packageForPlatformAndArchWithOpts, buildDir, comboOpts, downloadOpts, tempBase) { | ||
// In order to generate a universal macOS build we actually need to build the x64 and the arm64 app | ||
// and then glue them together | ||
common.info(`Packaging app for platform ${comboOpts.platform} universal using electron v${comboOpts.electronVersion} - Building x64 and arm64 slices now`, comboOpts.quiet) | ||
await fs.mkdirp(tempBase) | ||
const tempDir = await fs.mkdtemp(path.resolve(tempBase, 'electron-packager-universal-')) | ||
|
||
const { App } = require('./mac') | ||
const app = new App(comboOpts, buildDir) | ||
const universalStagingPath = app.stagingPath | ||
const finalUniversalPath = common.generateFinalPath(app.opts) | ||
|
||
if (await fs.pathExists(finalUniversalPath)) { | ||
if (comboOpts.overwrite) { | ||
await fs.remove(finalUniversalPath) | ||
} else { | ||
common.info(`Skipping ${comboOpts.platform} ${comboOpts.arch} (output dir already exists, use --overwrite to force)`, comboOpts.quiet) | ||
return true | ||
} | ||
} | ||
|
||
const [x64AppPath, arm64AppPath] = await Promise.all(['x64', 'arm64'].map((tempArch) => { | ||
const tempOpts = { | ||
...comboOpts, | ||
arch: tempArch, | ||
out: tempDir | ||
} | ||
const tempDownloadOpts = { | ||
...downloadOpts, | ||
arch: tempArch | ||
} | ||
// Do not sign or notarize the individual slices, we sign and notarize the merged app later | ||
delete tempOpts.osxSign | ||
delete tempOpts.osxNotarize | ||
|
||
return packageForPlatformAndArchWithOpts(tempOpts, tempDownloadOpts) | ||
})) | ||
|
||
common.info(`Stitching universal app for platform ${comboOpts.platform}`, comboOpts.quiet) | ||
|
||
const generatedFiles = await fs.readdir(x64AppPath) | ||
const appName = generatedFiles.filter(file => path.extname(file) === '.app')[0] | ||
|
||
await universal.makeUniversalApp({ | ||
...comboOpts.osxUniversal, | ||
x64AppPath: path.resolve(x64AppPath, appName), | ||
arm64AppPath: path.resolve(arm64AppPath, appName), | ||
outAppPath: path.resolve(universalStagingPath, appName) | ||
}) | ||
|
||
await app.signAppIfSpecified() | ||
await app.notarizeAppIfSpecified() | ||
await app.move() | ||
|
||
for (const generatedFile of generatedFiles) { | ||
if (path.extname(generatedFile) === '.app') continue | ||
|
||
await fs.copy(path.resolve(x64AppPath, generatedFile), path.resolve(finalUniversalPath, generatedFile)) | ||
} | ||
|
||
await fs.remove(tempDir) | ||
|
||
return finalUniversalPath | ||
} | ||
|
||
module.exports = { | ||
packageUniversalMac | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters