-
Notifications
You must be signed in to change notification settings - Fork 10
Separate mac builds to ARM64 and Intel #346
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,14 @@ const gulp = require('gulp'), | |
| princePackager = require('./src/js/prince-packager'), | ||
| debInstaller = require('electron-installer-debian'), | ||
| dmgInstaller = require('electron-installer-dmg'), | ||
| packageJson = require("./package.json"), | ||
| AdmZip = require('adm-zip'); | ||
| packageJson = require("./package.json"); | ||
|
|
||
| const APP_NAME = 'BTT-Writer', | ||
| JS_FILES = './src/js/**/*.js', | ||
| UNIT_TEST_FILES = './unit_tests/**/*.js', | ||
| BUILD_DIR = 'out/', | ||
| RELEASE_DIR = 'release/'; | ||
| RELEASE_DIR = 'release/', | ||
| MAC_ARCHS = ['arm64', 'x64']; | ||
|
|
||
|
|
||
| function clean(done) { | ||
|
|
@@ -55,14 +55,6 @@ gulp.task('prince', function(done) { | |
| .catch(() => done()); | ||
| }); | ||
|
|
||
| function zipDirectory(sourceDir, destPath, outPath) { | ||
| return new Promise((resolve, reject) => { | ||
| const zip = new AdmZip(undefined, {}); | ||
| zip.addLocalFolder(sourceDir, destPath); | ||
| zip.writeZip(outPath, err => err ? reject(err) : resolve()); | ||
| }); | ||
| } | ||
|
|
||
| function build(done) { | ||
|
|
||
| const platforms = []; | ||
|
|
@@ -98,26 +90,28 @@ function build(done) { | |
| // Also ignore all dot files and folders | ||
| ignored.push(/[/\\]\.[^/\\]+/); | ||
|
|
||
| packager({ | ||
| arch: ['x64', 'universal'], | ||
| platform: platforms, | ||
| dir: '.', | ||
| prune: true, | ||
| ignore: ignored, | ||
| out: BUILD_DIR, | ||
| appVersion: packageJson.version, | ||
| icon: './icons/icon', | ||
| osxUniversal: { | ||
| 'x64ArchFiles': '*' | ||
| }, | ||
| afterCopy: [ | ||
| (buildPath, electronVersion, platform, arch, callback) => { | ||
| rebuild.rebuild({ buildPath, electronVersion, arch }) | ||
| .then(() => callback()) | ||
| .catch((error) => callback(error)); | ||
| }, | ||
| ], | ||
| }).then(() => done()) | ||
| const packagePlatform = function (platform) { | ||
| return packager({ | ||
| arch: platform === 'darwin' ? MAC_ARCHS : ['x64'], | ||
| platform: platform, | ||
| dir: '.', | ||
| prune: true, | ||
| ignore: ignored, | ||
| out: BUILD_DIR, | ||
| appVersion: packageJson.version, | ||
| icon: './icons/icon', | ||
| afterCopy: [ | ||
| (buildPath, electronVersion, platform, arch, callback) => { | ||
| rebuild.rebuild({ buildPath, electronVersion, arch }) | ||
| .then(() => callback()) | ||
| .catch((error) => callback(error)); | ||
| }, | ||
| ], | ||
| }); | ||
| }; | ||
|
|
||
| Promise.all(platforms.map(packagePlatform)) | ||
| .then(() => done()) | ||
| .catch(err => { | ||
| console.log(err) | ||
| done() | ||
|
|
@@ -212,11 +206,12 @@ function release(done){ | |
| } | ||
|
|
||
| const releaseDmg = function (arch) { | ||
| const name = `BTT-Writer-${packageJson.version}-osx`; | ||
| const name = `BTT-Writer-${packageJson.version}-osx-${arch}`; | ||
| let buildPath = BUILD_DIR + `BTT-Writer-darwin-${arch}/BTT-Writer.app`; | ||
| const options = { | ||
| appPath: buildPath, | ||
| name: name, | ||
| title: APP_NAME, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you made the title |
||
| out: RELEASE_DIR, | ||
| icon: "icons/icon.icns" | ||
| } | ||
|
|
@@ -237,37 +232,34 @@ function release(done){ | |
| return await releaseWin('64', os); | ||
|
|
||
| case 'darwin': | ||
| let arch = 'universal'; | ||
| let macBuildPath = BUILD_DIR + `BTT-Writer-darwin-${arch}/`; | ||
| if (!fs.existsSync(macBuildPath)) { | ||
| // fallback to x64 arch | ||
| arch = "x64"; | ||
| macBuildPath = BUILD_DIR + `BTT-Writer-darwin-${arch}/`; | ||
| } | ||
|
|
||
| if (!fs.existsSync(macBuildPath)) { | ||
| throw new Error('Missing build'); | ||
| } | ||
| const macPaths = []; | ||
|
|
||
| const macDest = `${RELEASE_DIR}BTT-Writer-${packageJson.version}-osx-${arch}.zip`; | ||
| // TRICKY: appdmg mounts a volume per dmg, so the archs are | ||
| // released one after the other instead of in parallel | ||
| for (const arch of MAC_ARCHS) { | ||
| if (!fs.existsSync(BUILD_DIR + `BTT-Writer-darwin-${arch}/`)) { | ||
| throw new Error(`Missing ${arch} build`); | ||
| } | ||
|
|
||
| await zipDirectory(macBuildPath + 'BTT-Writer.app/', 'BTT-Writer.app', macDest); | ||
| await releaseDmg(arch); | ||
| await releaseDmg(arch); | ||
| macPaths.push(`${RELEASE_DIR}BTT-Writer-${packageJson.version}-osx-${arch}.dmg`); | ||
| } | ||
|
|
||
| return {os: os, status: 'ok', path: macDest}; | ||
| return {os: os, status: 'ok', path: macPaths.join(', ')}; | ||
|
|
||
| case 'linux': | ||
| const linuxBuildPath = BUILD_DIR + 'BTT-Writer-linux-x64/'; | ||
| if (!fs.existsSync(linuxBuildPath)) { | ||
| throw new Error('Missing build'); | ||
| } | ||
|
|
||
| const linuxDest = `${RELEASE_DIR}BTT-Writer-${packageJson.version}-linux-x64.zip`; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the Linux .zip download? The .deb target only works for Debian-based Linux targets. |
||
|
|
||
| await zipDirectory(linuxBuildPath, 'BTT-Writer', linuxDest); | ||
| await releaseDeb("amd64", os); | ||
|
|
||
| return {os: os, status: 'ok', path: linuxDest}; | ||
| return { | ||
| os: os, | ||
| status: 'ok', | ||
| path: `${RELEASE_DIR}btt-writer_${packageJson.version}_amd64.deb` | ||
| }; | ||
|
|
||
| default: | ||
| console.warn('No release procedure for ' + os); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, this catch() will log the error and then call
done(), allowing the build to continue. I think we should consider erroring out instead so that we don't accidentally (and silently) release a broken build.