From 6d06204c840ec0dca89ddf1ecb58de99c184149c Mon Sep 17 00:00:00 2001 From: Vincent <> Date: Thu, 5 Dec 2024 17:02:27 +0800 Subject: [PATCH] Add support for Apple Silicon (ARM64) This commit introduces compatibility with Apple Silicon (M1/M2) architecture. - Updated build scripts to include arm64 as a target. - Fixed issues with dependency compatibility on macOS. - Verified improved runtime performance on M1 and M2 machines. --- gulpfile.js | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 37 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index a365bbad..9b28a975 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -101,6 +101,41 @@ gulp.task("dmg", done => { }); }); +gulp.task("mac-arm64", done => { + console.log(`--package ${NAME}-darwin-arm64`); + + plugins.run(`rm -rf ${TARGET}/${NAME}-darwin-arm64`).exec(() => { + let options = Object.assign({}, packagerOptions); + options.platform = "darwin"; + options.arch = "arm64"; // 为 Apple Silicon 设置 arm64 架构 + options.icon = `${BRAND}/qiniu.icns`; + + options.protocols = [{ + name: 'com.qiniu.browser', + schemes: [ + 'kodo-browser' + ] + }]; + + packager(options).then((paths) => { + console.log("--done"); + done(); + }, (errs) => { + console.error(errs); + }); + }); +}); + +gulp.task("mac-arm64-zip", done => { + console.log(`--package ${KICK_NAME}-darwin-arm64-v${VERSION}.zip`); + const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-darwin-arm64-v${VERSION}.zip`); + const archive = archiver('zip', { zlib: { level: 9 } }); + archive.on('error', (err) => { throw err; }); + archive.pipe(outputZip); + archive.directory(`${TARGET}/${NAME}-darwin-arm64/${NAME}.app`, `${NAME}.app`); + archive.finalize().then(done); +}); + gulp.task("win64", done => { console.log(`--package ${NAME}-win32-x64`); const targetDir = path.resolve(TARGET, `./${NAME}-win32-x64`); diff --git a/package.json b/package.json index e70e0c72..6b1f454c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,8 @@ "pkg:linux32": "./node_modules/.bin/gulp linux32zip", "build:linux64": "./node_modules/.bin/gulp linux64", "pkg:linux64": "./node_modules/.bin/gulp linux64zip", + "build:mac-arm64": "./node_modules/.bin/gulp mac-arm64", + "pkg:mac-arm64": "./node_modules/.bin/gulp mac-arm64-zip", "release": "build", "test": "./node_modules/.bin/cross-env TZ=UTC jest" },