Skip to content

Commit 7bab6be

Browse files
committed
Add script to build windows installer
1 parent 3851224 commit 7bab6be

File tree

2 files changed

+411
-0
lines changed

2 files changed

+411
-0
lines changed

install/win-installer.nsi

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
; NSIS script file
2+
3+
4+
;==============================;
5+
; Configuration ;
6+
;==============================;
7+
8+
!ifndef APP_ARCH
9+
!define APP_ARCH x86_64
10+
!endif
11+
12+
!ifndef INSTALLER_FILE
13+
!define INSTALLER_FILE GCodeWorkShop_${APP_ARCH}_Setup.exe
14+
!endif
15+
16+
; Directories
17+
18+
!define APP_BIN_DIR bin
19+
!define PKG_BIN_DIR ${APP_BIN_DIR}
20+
!define APP_DOC_DIR doc
21+
!define PKG_DOC_DIR ${APP_DOC_DIR}
22+
!define APP_EXAMPLES_DIR examples
23+
!define PKG_EXAMPLES_DIR ${APP_EXAMPLES_DIR}
24+
!define APP_I18N_DIR lang
25+
!define PKG_I18N_DIR ${APP_I18N_DIR}
26+
27+
28+
;==============================;
29+
; General ;
30+
;==============================;
31+
32+
; The icon for the installer and uninstaller.
33+
; MUI_ICON icon_file
34+
; MUI_UNICON icon_file
35+
36+
Unicode true
37+
Name "GCodeWorkShop"
38+
OutFile "${INSTALLER_FILE}"
39+
40+
!if ${APP_ARCH} == "x86_64"
41+
InstallDir "$PROGRAMFILES64\GCodeWorkShop"
42+
!else
43+
InstallDir "$PROGRAMFILES32\GCodeWorkShop"
44+
!endif
45+
46+
InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\GCodeWorkShop" ""
47+
; SetCompressor lzma
48+
49+
50+
; Modern UI
51+
52+
!include "MUI.nsh"
53+
!define MUI_ABORTWARNING
54+
55+
56+
;==============================;
57+
; Pages ;
58+
;==============================;
59+
60+
Var STARTMENU_FOLDER
61+
62+
!insertmacro MUI_PAGE_WELCOME
63+
!insertmacro MUI_PAGE_LICENSE LICENSE.txt
64+
!insertmacro MUI_PAGE_DIRECTORY
65+
66+
;Start Menu Folder Page Configuration
67+
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKEY_LOCAL_MACHINE
68+
!define MUI_STARTMENUPAGE_REGISTRY_KEY "SOFTWARE\GCodeWorkShop"
69+
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
70+
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
71+
72+
!insertmacro MUI_PAGE_INSTFILES
73+
!insertmacro MUI_PAGE_FINISH
74+
75+
; Uninstaller pages
76+
!insertmacro MUI_UNPAGE_WELCOME
77+
!insertmacro MUI_UNPAGE_CONFIRM
78+
!insertmacro MUI_UNPAGE_INSTFILES
79+
!insertmacro MUI_UNPAGE_FINISH
80+
81+
82+
;==============================;
83+
; Languages ;
84+
;==============================;
85+
86+
!insertmacro MUI_LANGUAGE "English"
87+
!insertmacro MUI_LANGUAGE "Catalan"
88+
!insertmacro MUI_LANGUAGE "Czech"
89+
!insertmacro MUI_LANGUAGE "Dutch"
90+
!insertmacro MUI_LANGUAGE "Finnish"
91+
!insertmacro MUI_LANGUAGE "German"
92+
!insertmacro MUI_LANGUAGE "Polish"
93+
!insertmacro MUI_LANGUAGE "Russian"
94+
!insertmacro MUI_LANGUAGE "Spanish"
95+
96+
97+
;==============================;
98+
; Main section ;
99+
;==============================;
100+
101+
Section "-Install"
102+
SetOutPath "$INSTDIR"
103+
File LICENSE.txt
104+
105+
SetOutPath "$INSTDIR\${PKG_BIN_DIR}"
106+
File /oname=GCodeWorkShop.exe ${APP_BIN_DIR}\gcodeworkshop.exe
107+
File /oname=GCodeFileServer.exe ${APP_BIN_DIR}\gcodefileserver.exe
108+
109+
;Store installation folder
110+
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\GCodeWorkShop" "" "$INSTDIR"
111+
112+
;Create uninstaller
113+
WriteUninstaller "$INSTDIR\uninst.exe"
114+
115+
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
116+
;Create shortcuts
117+
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
118+
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GCodeWorkShop.lnk" "$INSTDIR\${PKG_BIN_DIR}\GCodeWorkShop.exe"
119+
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninst.exe"
120+
!insertmacro MUI_STARTMENU_WRITE_END
121+
SectionEnd
122+
123+
Section "Uninstall"
124+
Push $R0
125+
!insertmacro MUI_STARTMENU_GETFOLDER Application $R0
126+
Delete "$SMPROGRAMS\$R0\Uninstall.lnk"
127+
Delete "$SMPROGRAMS\$R0\GCodeWorkShop.lnk"
128+
RMDir "$SMPROGRAMS\$R0"
129+
Pop $R0
130+
131+
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\GCodeWorkShop"
132+
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GCodeWorkShop"
133+
134+
Delete "$INSTDIR\${PKG_BIN_DIR}\GCodeWorkShop.exe"
135+
Delete "$INSTDIR\${PKG_BIN_DIR}\GCodeFileServer.exe"
136+
Delete "$INSTDIR\LICENSE.txt"
137+
Delete "$INSTDIR\uninst.exe"
138+
139+
RMDir "$INSTDIR\${PKG_BIN_DIR}"
140+
RMDir "$INSTDIR"
141+
SectionEnd
142+
143+
144+
;==============================;
145+
; Internationalisation ;
146+
;==============================;
147+
148+
Section "-Install i18n"
149+
SetOutPath "$INSTDIR\${PKG_I18N_DIR}"
150+
File "${APP_I18N_DIR}\*.qm"
151+
SectionEnd
152+
153+
Section "un.Install i18n"
154+
RMDir /r "$INSTDIR\${PKG_I18N_DIR}"
155+
RMDir "$INSTDIR"
156+
SectionEnd
157+
158+
159+
;==============================;
160+
; Documentation ;
161+
;==============================;
162+
163+
Section "-Install doc"
164+
SetOutPath "$INSTDIR\${PKG_DOC_DIR}"
165+
File /r "${APP_DOC_DIR}\*.html"
166+
SectionEnd
167+
168+
Section "un.Install doc"
169+
RMDir /r "$INSTDIR\${PKG_DOC_DIR}"
170+
RMDir "$INSTDIR"
171+
SectionEnd
172+
173+
174+
;==============================;
175+
; Examples ;
176+
;==============================;
177+
178+
Section "-Install Examples"
179+
SetOutPath "$INSTDIR\${PKG_EXAMPLES_DIR}"
180+
File /r "${APP_EXAMPLES_DIR}\*.nc"
181+
File "${APP_EXAMPLES_DIR}\cnc_tips.txt"
182+
SectionEnd
183+
184+
Section "un.Install Examples"
185+
RMDir /r "$INSTDIR\${PKG_EXAMPLES_DIR}"
186+
RMDir "$INSTDIR"
187+
SectionEnd
188+
189+
190+
;==============================;
191+
; dependencies ;
192+
;==============================;
193+
194+
Section "-Install Dependencies"
195+
SetOutPath "$INSTDIR\${PKG_BIN_DIR}"
196+
File ${APP_BIN_DIR}\qt.conf
197+
File /nonfatal /r "${APP_BIN_DIR}\*.dll"
198+
SectionEnd
199+
200+
Section "un.Install Dependencies"
201+
RMDir /r "$INSTDIR\${PKG_BIN_DIR}"
202+
RMDir "$INSTDIR"
203+
SectionEnd

0 commit comments

Comments
 (0)