From 80b1e436f8e8779f18986815c4d01d1acea190ac Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Sun, 15 May 2022 00:53:08 +0800 Subject: [PATCH] Update build script to build ARM64 version on Apple Silicon machines (#1918) * $ Refactor build script * * Update build script to build ARM64 on Apple Silicon --- _scripts/build.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/_scripts/build.js b/_scripts/build.js index 7052fca8..7d92b13b 100644 --- a/_scripts/build.js +++ b/_scripts/build.js @@ -7,13 +7,22 @@ const { name, productName } = require('../package.json') const args = process.argv let targets -var platform = os.platform() +const platform = os.platform() +const cpus = os.cpus() -if (platform == 'darwin') { - targets = Platform.MAC.createTarget() -} else if (platform == 'win32') { +if (platform === 'darwin') { + let arch = Arch.x64 + +// Macbook Air 2020 with M1 = 'Apple M1' + // Macbook Pro 2021 with M1 Pro = 'Apple M1 Pro' + if (cpus[0].model.startsWith('Apple')) { + arch = Arch.arm64 + } + + targets = Platform.MAC.createTarget(['dmg'], arch) +} else if (platform === 'win32') { targets = Platform.WINDOWS.createTarget() -} else if (platform == 'linux') { +} else if (platform === 'linux') { let arch = Arch.x64 if (args[2] === 'arm64') {