Skip to content

Commit d738644

Browse files
dangeredwolfdevelar
authored andcommitted
feat(nsis): Windows on ARM support (#4228)
1 parent 8e0a57d commit d738644

File tree

11 files changed

+144
-69
lines changed

11 files changed

+144
-69
lines changed

packages/app-builder-lib/src/targets/AppxTarget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export default class AppXTarget extends Target {
232232
return splashScreenTag(userAssets)
233233

234234
case "arch":
235-
return arch === Arch.ia32 ? "x86" : "x64"
235+
return arch === Arch.ia32 ? "x86" : (arch === Arch.arm64 ? "arm64" : "x64")
236236

237237
case "resourceLanguages":
238238
return resourceLanguageTag(asArray(options.languages))

packages/app-builder-lib/src/targets/MsiTarget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class MsiTarget extends Target {
7575

7676
// noinspection SpellCheckingInspection
7777
const candleArgs = [
78-
"-arch", arch === Arch.ia32 ? "x86" : (arch === Arch.armv7l ? "arm" : "x64"),
78+
"-arch", arch === Arch.ia32 ? "x86" : (arch === Arch.arm64 ? "arm64" : "x64"),
7979
`-dappDir=${vm.toVmFile(appOutDir)}`,
8080
].concat(this.getCommonWixArgs())
8181
candleArgs.push("project.wxs")

packages/app-builder-lib/src/targets/nsis/NsisTarget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class NsisTarget extends Target {
193193
let estimatedSize = 0
194194
if (this.isPortable && options.useZip) {
195195
for (const [arch, dir] of this.archs.entries()) {
196-
defines[arch === Arch.x64 ? "APP_DIR_64" : "APP_DIR_32"] = dir
196+
defines[arch === Arch.x64 ? "APP_DIR_64" : (arch === Arch.arm64 ? "APP_DIR_ARM64" : "APP_DIR_32")] = dir
197197
}
198198
}
199199
else if (USE_NSIS_BUILT_IN_COMPRESSOR && this.archs.size === 1) {
@@ -203,7 +203,7 @@ export class NsisTarget extends Target {
203203
await BluebirdPromise.map(this.archs.keys(), async arch => {
204204
const fileInfo = await this.packageHelper.packArch(arch, this)
205205
const file = fileInfo.path
206-
const defineKey = arch === Arch.x64 ? "APP_64" : "APP_32"
206+
const defineKey = arch === Arch.x64 ? "APP_64" : (Arch.arm64 ? "APP_ARM64" : "APP_32")
207207
defines[defineKey] = file
208208
defines[`${defineKey}_NAME`] = path.basename(file)
209209
// nsis expect a hexadecimal string
@@ -674,4 +674,4 @@ async function createPackageFileInfo(file: string): Promise<PackageFileInfo> {
674674
size: (await stat(file)).size,
675675
sha512: await hashFile(file),
676676
}
677-
}
677+
}

packages/app-builder-lib/src/targets/nsis/nsisUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const NSIS_PATH = new Lazy(() => {
1717
return Promise.resolve(custom.trim())
1818
}
1919
// noinspection SpellCheckingInspection
20-
return getBinFromUrl("nsis", "3.0.3.2", "tUrlDPQtbjcooNbTrjUzLupttWlATLDNWqK57TVr+gAt3wkaxFxBS3k80AzEFJbmSeOWrUooO72FFOVGXcoxhA==")
20+
return getBinFromUrl("nsis", "3.0.4", "FVF4HClUCsTZ32vYOIC7rTo1qb2pvt2nZwzb86MbKbORukMH0rS3SGBYg/MHmT58PqvRCSlEFai6impEYDYp2Q==")
2121
})
2222

2323
export class AppPackageHelper {
@@ -100,4 +100,4 @@ export class CopyElevateHelper {
100100
this.copied.set(appOutDir, promise)
101101
return promise
102102
}
103-
}
103+
}

packages/app-builder-lib/templates/nsis/common.nsh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ Name "${PRODUCT_NAME}"
2323
Quit
2424
${EndIf}
2525

26-
!ifdef APP_64
26+
!ifdef APP_ARM64
2727
${If} ${RunningX64}
2828
SetRegView 64
29-
${Else}
30-
!ifndef APP_32
31-
MessageBox MB_OK|MB_ICONEXCLAMATION "$(x64WinRequired)"
32-
Quit
33-
!endif
3429
${EndIf}
30+
${If} ${IsNativeARM64}
31+
SetRegView 64
32+
${EndIf}
33+
!else
34+
!ifdef APP_64
35+
${If} ${RunningX64}
36+
SetRegView 64
37+
${Else}
38+
!ifndef APP_32
39+
MessageBox MB_OK|MB_ICONEXCLAMATION "$(x64WinRequired)"
40+
Quit
41+
!endif
42+
${EndIf}
43+
!endif
3544
!endif
3645
!macroend
3746

@@ -89,4 +98,4 @@ Name "${PRODUCT_NAME}"
8998
${endif}
9099

91100
${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$startAppArgs"
92-
!macroend
101+
!macroend

packages/app-builder-lib/templates/nsis/include/extractAppPackage.nsh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,32 @@
66
Var /GLOBAL packageArch
77

88
!ifdef APP_64
9+
!ifdef APP_ARM64
10+
StrCpy $packageArch "ARM64"
11+
!else
912
StrCpy $packageArch "64"
13+
!endif
1014

11-
!ifdef APP_32
12-
${if} ${RunningX64}
13-
!insertmacro x64_app_files
15+
!ifdef APP_32
16+
!ifdef APP_ARM64
17+
${if} ${IsNativeARM64} == true
18+
!insertmacro arm64_app_files
19+
${elseif} ${IsNativeAMD64} == true
20+
!insertmacro x64_app_files
1421
${else}
15-
!insertmacro ia32_app_files
22+
!insertmacro ia32_app_files
1623
${endIf}
1724
!else
18-
!insertmacro x64_app_files
25+
${if} ${RunningX64} == true
26+
!ifdef APP_32
27+
!insertmacro x64_app_files
28+
!endif
29+
${else}
30+
!insertmacro ia32_app_files
31+
${endIf}
1932
!endif
2033
!else
21-
!insertmacro ia32_app_files
34+
!insertmacro x64_app_files
2235
!endif
2336

2437
!ifdef COMPRESS
@@ -32,7 +45,11 @@
3245
!endif
3346

3447
# after decompression
35-
${if} $packageArch == "64"
48+
${if} $packageArch == "ARM64"
49+
!ifmacrodef customFiles_arm64
50+
!insertmacro customFiles_arm64
51+
!endif
52+
${elseif} $packageArch == "64"
3653
!ifmacrodef customFiles_x64
3754
!insertmacro customFiles_x64
3855
!endif
@@ -43,6 +60,10 @@
4360
${endIf}
4461
!macroend
4562

63+
!macro arm64_app_files
64+
File /oname=$PLUGINSDIR\app-arm64.${COMPRESSION_METHOD} "${APP_ARM64}"
65+
!macroend
66+
4667
!macro x64_app_files
4768
File /oname=$PLUGINSDIR\app-64.${COMPRESSION_METHOD} "${APP_64}"
4869
!macroend
@@ -54,4 +75,4 @@
5475

5576
!macro extractUsing7za FILE
5677
Nsis7z::Extract "${FILE}"
57-
!macroend
78+
!macroend

packages/app-builder-lib/templates/nsis/include/installer.nsh

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,26 @@
1818
${if} $packageFile == ""
1919
!ifdef APP_64_NAME
2020
!ifdef APP_32_NAME
21-
${if} ${RunningX64}
22-
StrCpy $packageFile "${APP_64_NAME}"
23-
StrCpy $1 "${APP_64_HASH}"
24-
${else}
25-
StrCpy $packageFile "${APP_32_NAME}"
26-
StrCpy $1 "${APP_32_HASH}"
27-
${endif}
21+
!ifdef APP_ARM64_NAME
22+
${if} ${IsNativeARM64}
23+
StrCpy $packageFile "${APP_ARM64_NAME}"
24+
StrCpy $1 "${APP_ARM64_HASH}"
25+
${elseif} ${IsNativeAMD64}
26+
StrCpy $packageFile "${APP_64_NAME}"
27+
StrCpy $1 "${APP_64_HASH}"
28+
${else}
29+
StrCpy $packageFile "${APP_32_NAME}"
30+
StrCpy $1 "${APP_32_HASH}"
31+
${endif}
32+
!else
33+
${if} ${RunningX64}
34+
StrCpy $packageFile "${APP_64_NAME}"
35+
StrCpy $1 "${APP_64_HASH}"
36+
${else}
37+
StrCpy $packageFile "${APP_32_NAME}"
38+
StrCpy $1 "${APP_32_HASH}"
39+
${endif}
40+
!endif
2841
!else
2942
StrCpy $packageFile "${APP_64_NAME}"
3043
StrCpy $1 "${APP_64_HASH}"
@@ -88,39 +101,40 @@
88101
!macroend
89102

90103
!macro registryAddInstallInfo
91-
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR"
92-
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts "true"
104+
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "$INSTDIR"
105+
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" KeepShortcuts "true"
93106
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" ShortcutName "${SHORTCUT_NAME}"
94107
!ifdef MENU_FILENAME
95108
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory "${MENU_FILENAME}"
96109
!endif
97110

98-
${if} $installMode == "all"
99-
StrCpy $0 "/allusers"
100-
StrCpy $1 ""
101-
${else}
102-
StrCpy $0 "/currentuser"
103-
StrCpy $1 ""
104-
${endIf}
111+
${if} $installMode == "all"
112+
StrCpy $0 "/allusers"
113+
StrCpy $1 ""
114+
${else}
115+
StrCpy $0 "/currentuser"
116+
StrCpy $1 ""
117+
${endIf}
105118

106119
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME}$1"
107120
# https://github.com/electron-userland/electron-builder/issues/750
108121
StrCpy $2 "$INSTDIR\${UNINSTALL_FILENAME}"
109122
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$2" $0'
110123
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" QuietUninstallString '"$2" $0 /S'
111124

112-
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
113-
!ifdef UNINSTALLER_ICON
114-
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico"
115-
!else
116-
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
117-
!endif
125+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
126+
!ifdef UNINSTALLER_ICON
127+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$INSTDIR\uninstallerIcon.ico"
128+
!else
129+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
130+
!endif
118131

119132
!ifdef COMPANY_NAME
120-
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}"
121-
!endif
122-
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoModify 1
123-
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoRepair 1
133+
WriteRegStr SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${COMPANY_NAME}"
134+
!endif
135+
136+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoModify 1
137+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" NoRepair 1
124138

125139
# allow user to define ESTIMATED_SIZE to avoid GetSize call
126140
!ifdef ESTIMATED_SIZE
@@ -129,7 +143,8 @@
129143
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
130144
IntFmt $0 "0x%08X" $0
131145
!endif
132-
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0"
146+
147+
WriteRegDWORD SHELL_CONTEXT "${UNINSTALL_REGISTRY_KEY}" "EstimatedSize" "$0"
133148
!macroend
134149

135150
!macro cleanupOldMenuDirectory
@@ -209,4 +224,4 @@
209224
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
210225
${endIf}
211226
!endif
212-
!macroend
227+
!macroend

packages/app-builder-lib/templates/nsis/include/webPackage.nsh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@
88
!ifdef APP_PACKAGE_URL_IS_INCOMLETE
99
!ifdef APP_64_NAME
1010
!ifdef APP_32_NAME
11-
${if} ${RunningX64}
12-
StrCpy $packageUrl "$packageUrl/${APP_64_NAME}"
13-
${else}
14-
StrCpy $packageUrl "$packageUrl/${APP_32_NAME}"
15-
${endif}
11+
!ifdef APP_ARM64_NAME
12+
${if} ${IsNativeARM64}
13+
StrCpy $packageUrl "$packageUrl/${APP_ARM64_NAME}"
14+
${elseif} ${IsNativeAMD64}
15+
StrCpy $packageUrl "$packageUrl/${APP_64_NAME}"
16+
${else}
17+
StrCpy $packageUrl "$packageUrl/${APP_32_NAME}"
18+
${endif}
19+
!else
20+
${if} ${IsNativeAMD64} == true
21+
StrCpy $packageUrl "$packageUrl/${APP_64_NAME}"
22+
${else}
23+
StrCpy $packageUrl "$packageUrl/${APP_32_NAME}"
24+
${endif}
25+
!endif
1626
!else
1727
StrCpy $packageUrl "$packageUrl/${APP_64_NAME}"
1828
!endif
@@ -21,7 +31,9 @@
2131
!endif
2232
!endif
2333

24-
${if} ${RunningX64}
34+
${if} ${IsNativeARM64}
35+
StrCpy $packageArch "ARM64"
36+
${elseif} ${IsNativeAMD64}
2537
StrCpy $packageArch "64"
2638
${else}
2739
StrCpy $packageArch "32"
@@ -49,4 +61,4 @@
4961
${endif}
5062

5163
StrCpy $packageFile "$PLUGINSDIR\package.7z"
52-
!macroend
64+
!macroend

packages/app-builder-lib/templates/nsis/portable.nsi

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,35 @@ FunctionEnd
1616
Section
1717
StrCpy $INSTDIR "$TEMP\${UNPACK_DIR_NAME}"
1818
RMDir /r $INSTDIR
19-
SetOutPath $INSTDIR
19+
SetOutPath $INSTDIR
2020

21-
!ifdef APP_DIR_64
22-
!ifdef APP_DIR_32
23-
${if} ${RunningX64}
24-
File /r "${APP_DIR_64}\*.*"
25-
${else}
26-
File /r "${APP_DIR_32}\*.*"
27-
${endIf}
21+
!ifdef APP_DIR_64
22+
!ifdef APP_DIR_ARM64
23+
!ifdef APP_DIR_32
24+
${if} ${IsNativeARM64}
25+
File /r "${APP_DIR_ARM64}\*.*"
26+
${elseif} ${RunningX64}
27+
File /r "${APP_DIR_64}\*.*"
28+
${else}
29+
File /r "${APP_DIR_32}\*.*"
30+
${endIf}
31+
!else
32+
${if} ${IsNativeARM64}
33+
File /r "${APP_DIR_ARM64}\*.*"
34+
${else}
35+
File /r "${APP_DIR_64}\*.*"
36+
{endIf}
37+
!endif
2838
!else
29-
File /r "${APP_DIR_64}\*.*"
39+
!ifdef APP_DIR_32
40+
${if} ${RunningX64}
41+
File /r "${APP_DIR_64}\*.*"
42+
${else}
43+
File /r "${APP_DIR_32}\*.*"
44+
${endIf}
45+
!else
46+
File /r "${APP_DIR_64}\*.*"
47+
!endif
3048
!endif
3149
!else
3250
!ifdef APP_DIR_32

test/src/helpers/testConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as os from "os"
22
import * as path from "path"
33

4-
export const ELECTRON_VERSION = "6.0.0"
4+
export const ELECTRON_VERSION = "6.0.8"
55

66
export function getElectronCacheDir() {
77
if (process.platform === "win32") {

test/src/windows/webInstallerTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test.ifNotCiMac("web installer", app({
1515
}))
1616

1717
test.ifAll.ifNotCiMac("web installer (default github)", app({
18-
targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.ia32, Arch.x64),
18+
targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.ia32, Arch.x64, Arch.arm64),
1919
config: {
2020
publish: {
2121
provider: "github",
@@ -38,4 +38,4 @@ test.ifAll.ifNotCiMac("web installer, safe name on github", app({
3838
artifactName: "${productName}.${ext}",
3939
},
4040
},
41-
}))
41+
}))

0 commit comments

Comments
 (0)