Skip to content

Commit

Permalink
Merge pull request #9691 from dennisameling/windows-arm-support
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 committed Apr 6, 2021
2 parents 58067b8 + cdbbd80 commit 00fce6d
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 18 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -9,19 +9,23 @@ on:

jobs:
build:
name: ${{ matrix.friendlyName }}
name: ${{ matrix.friendlyName }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [14.x]
node: [14.15.4]
os: [macos-10.15, windows-2019]
arch: [x64, arm64]
include:
- os: macos-10.15
friendlyName: macOS
- os: windows-2019
friendlyName: Windows
timeout-minutes: 45
env:
# Needed for macOS arm64 until hosted macos-11.0 runners become available
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -44,8 +48,17 @@ jobs:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-
# This step can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
- name: Get NodeJS node-gyp lib for Windows arm64
if: ${{ matrix.os == 'windows-2019' && matrix.arch == 'arm64' }}
run: .\script\download-nodejs-win-arm64.ps1 ${{ matrix.node }}

- name: Install and build dependencies
run: yarn
env:
npm_config_arch: ${{ matrix.arch }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Lint
run: yarn lint
- name: Validate changelog
Expand All @@ -62,13 +75,19 @@ jobs:
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
DESKTOPBOT_TOKEN: ${{ secrets.DESKTOPBOT_TOKEN }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
npm_config_arch: ${{ matrix.arch }}
TARGET_ARCH: ${{ matrix.arch }}
- name: Prepare testing environment
if: matrix.arch == 'x64'
run: yarn test:setup
- name: Run unit tests
if: matrix.arch == 'x64'
run: yarn test:unit:cov
- name: Run script tests
if: matrix.arch == 'x64'
run: yarn test:script:cov
- name: Run integration tests
if: matrix.arch == 'x64'
timeout-minutes: 5
run: yarn test:integration
- name: Publish production app
Expand Down
1 change: 0 additions & 1 deletion app/.npmrc
@@ -1,4 +1,3 @@
runtime = electron
disturl = https://atom.io/download/electron
target = 11.1.1
arch = x64
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -127,7 +127,7 @@
"@types/codemirror": "0.0.76",
"@types/deep-equal": "^1.0.1",
"@types/double-ended-queue": "^2.1.0",
"@types/electron-winstaller": "^2.6.0",
"@types/electron-winstaller": "^4.0.0",
"@types/event-kit": "^1.2.28",
"@types/express": "^4.11.0",
"@types/extract-text-webpack-plugin": "^3.0.3",
Expand Down Expand Up @@ -172,6 +172,6 @@
"electron": "^11.1.1",
"electron-builder": "^22.7.0",
"electron-packager": "^15.1.0",
"electron-winstaller": "4.0.2"
"electron-winstaller": "^5.0.0"
}
}
5 changes: 3 additions & 2 deletions script/build.ts
Expand Up @@ -4,6 +4,7 @@
import * as path from 'path'
import * as cp from 'child_process'
import * as fs from 'fs-extra'
import * as os from 'os'
import packager, {
OfficialArch,
OsxNotarizeOptions,
Expand Down Expand Up @@ -141,15 +142,15 @@ function packageApp() {

const toPackageArch = (targetArch: string | undefined): OfficialArch => {
if (targetArch === undefined) {
return 'x64'
targetArch = os.arch()
}

if (targetArch === 'arm64' || targetArch === 'x64') {
return targetArch
}

throw new Error(
`Building Desktop for architecture '${targetArch}' is not supported`
`Building Desktop for architecture '${targetArch}' is not supported`
)
}

Expand Down
11 changes: 10 additions & 1 deletion script/dist-info.ts
@@ -1,5 +1,6 @@
import * as Path from 'path'
import * as Fs from 'fs'
import * as os from 'os'

import { getProductName, getVersion } from '../app/package-info'
import { getReleaseBranchName } from './build-platforms'
Expand All @@ -16,9 +17,17 @@ export function getDistRoot() {
}

export function getDistPath() {
let arch = os.arch()

if (process.env.npm_config_arch) {
// If a specific npm_config_arch is set, we use that one instead of the OS arch (to support cross compilation)
console.log('npm_config_arch detected: ' + process.env.npm_config_arch)
arch = process.env.npm_config_arch
}

return Path.join(
getDistRoot(),
`${getExecutableName()}-${process.platform}-x64`
`${getExecutableName()}-${process.platform}-${arch}`
)
}

Expand Down
22 changes: 22 additions & 0 deletions script/download-nodejs-win-arm64.ps1
@@ -0,0 +1,22 @@
# This script can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342

$nodeVersion = $args[0]

If ($null -eq $nodeVersion) {
Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 12.10.1"
exit 1
}

$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib"
$cacheFolder = "$env:LOCALAPPDATA\node-gyp\Cache\$nodeVersion\arm64"

If (!(Test-Path $cacheFolder)) {
New-Item -ItemType Directory -Force -Path $cacheFolder
}

$output = "$cacheFolder\node.lib"
$start_time = Get-Date

Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Downloaded arm64 NodeJS lib $nodeVersion in $((Get-Date).Subtract($start_time).Seconds) second(s)"
2 changes: 0 additions & 2 deletions script/test-appveyor.bat

This file was deleted.

18 changes: 10 additions & 8 deletions yarn.lock
Expand Up @@ -743,10 +743,12 @@
resolved "https://registry.yarnpkg.com/@types/double-ended-queue/-/double-ended-queue-2.1.0.tgz#adc862d8d53bdf7d1b23a7d85559815ec1fbb92c"
integrity sha512-pCS41/Odn6GMQyqnt8aPTSTQFGriAryYQwVONKk1QhUEhulxueLPE1kDNqDOuJqiv34VLVWXxF4I1EKz3+ftzQ==

"@types/electron-winstaller@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@types/electron-winstaller/-/electron-winstaller-2.6.0.tgz#703073ee2109fefe8a958fdadb746dfc0a827918"
integrity sha512-pQke6avqSYtkNunEec7NF2dTDSFsf2e1Ti9VkaJFzI15UfTEOjwz22lKoImja7nXPLu8nINYSaVaPgw0XHJEkA==
"@types/electron-winstaller@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/electron-winstaller/-/electron-winstaller-4.0.0.tgz#7377b2cdaab361956cbf1fc41419abb77172d8eb"
integrity sha512-IpgXedqMlSjBIq7+mpj7pkxxZHramuVnrQTyYZbV4M6eABRCNVkbLfXnD35F2+kW3lKFOW9qTcCDo5aGKn7rnQ==
dependencies:
electron-winstaller "*"

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
Expand Down Expand Up @@ -4128,10 +4130,10 @@ electron-publish@22.7.0:
lazy-val "^1.0.4"
mime "^2.4.5"

electron-winstaller@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/electron-winstaller/-/electron-winstaller-4.0.2.tgz#e3aa7e95db8232eeb337b28c11ad80b93dcafe6d"
integrity sha512-tYmzIyi+W0CXd9o/jmR0VT+vwJ+nOaE/dQz8f64IlbQ/J9d2lpwsmmOKxx6veAVKeYiJHYQHR1eYsLzznNzd5g==
electron-winstaller@*, electron-winstaller@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/electron-winstaller/-/electron-winstaller-5.0.0.tgz#0db968f34d498b16c69566a40848f562e70e7bcc"
integrity sha512-V+jFda7aVAm0htCG8Q95buPUpmXZW9ujh1HdhSlWY6y4QnJnw4TfrmxTlQWV4p2ioF/71JMI/1YF+/qbSICogA==
dependencies:
asar "^2.0.1"
debug "^4.1.1"
Expand Down

0 comments on commit 00fce6d

Please sign in to comment.