Update build script to build ARM64 version on Apple Silicon machines (#1918)

* $ Refactor build script

* * Update build script to build ARM64 on Apple Silicon
This commit is contained in:
PikachuEXE 2022-05-15 00:53:08 +08:00 committed by GitHub
parent 1cbf6b5159
commit 80b1e436f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -7,13 +7,22 @@ const { name, productName } = require('../package.json')
const args = process.argv const args = process.argv
let targets let targets
var platform = os.platform() const platform = os.platform()
const cpus = os.cpus()
if (platform == 'darwin') { if (platform === 'darwin') {
targets = Platform.MAC.createTarget() let arch = Arch.x64
} else if (platform == 'win32') {
// 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() targets = Platform.WINDOWS.createTarget()
} else if (platform == 'linux') { } else if (platform === 'linux') {
let arch = Arch.x64 let arch = Arch.x64
if (args[2] === 'arm64') { if (args[2] === 'arm64') {