Make TX volatge for simu more flexible (#7124)
[opentx.git] / companion / targets / windows / companion.nsi.in
blob7ea693a1aa55d4e78214ae6f89a184a56f15033b
1 ;NSIS Modern User Interface
2 ;Start Menu Folder Selection Example Script
3 ;Written by Joost Verburg
5 ;--------------------------------
6 ;Include Modern UI
8 !include "MUI2.nsh"
9 !include "@CMAKE_CURRENT_SOURCE_DIR@\..\targets\windows\FileAssociation.nsh"
11 ;--------------------------------
12 ;General
14 ;Name and file
15 Name "OpenTX Companion @VERSION_FAMILY@"
16 OutFile "companion-windows-@VERSION@.exe"
18 ;Default installation folder
19 InstallDir "$PROGRAMFILES\OpenTX\Companion @VERSION_FAMILY@"
21 ;Get installation folder from registry if available
22 InstallDirRegKey HKCU "Software\OpenTX\Companion @VERSION_FAMILY@" ""
24 ;Compressor options
25 SetCompressor /FINAL /SOLID lzma
26 SetCompressorDictSize 64
28 ;Request application privileges for Windows Vista
29 RequestExecutionLevel admin
31 ;--------------------------------
32 ;Variables
34 Var StartMenuFolder
36 ;--------------------------------
37 ;Interface Settings
39 !define MUI_ABORTWARNING
41 ;--------------------------------
42 ;File Exists Macro
44 ; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
45 !macro !defineifexist _VAR_NAME _FILE_NAME
46 !tempfile _TEMPFILE
47 !ifdef NSIS_WIN32_MAKENSIS
48 ; Windows - cmd.exe
49 !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
50 !else
51 ; Posix - sh
52 !system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
53 !endif
54 !include '${_TEMPFILE}'
55 !delfile '${_TEMPFILE}'
56 !undef _TEMPFILE
57 !macroend
58 !define !defineifexist "!insertmacro !defineifexist"
60 ;--------------------------------
61 ;Pages
63 !insertmacro MUI_PAGE_LICENSE "@NSIS_DISTRO@\license.txt"
64 !insertmacro MUI_PAGE_COMPONENTS
65 !insertmacro MUI_PAGE_DIRECTORY
67 ;Start Menu Folder Page Configuration
68 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
69 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenTX\Companion @VERSION_FAMILY@"
70 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
72 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
74 !insertmacro MUI_PAGE_INSTFILES
76 # These indented statements modify settings for MUI_PAGE_FINISH
77 !define MUI_FINISHPAGE_NOAUTOCLOSE
78 !define MUI_FINISHPAGE_RUN
79 !define MUI_FINISHPAGE_RUN_CHECKED
80 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
81 # !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
82 # !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\readme.txt
83 !insertmacro MUI_PAGE_FINISH
85 !insertmacro MUI_UNPAGE_CONFIRM
86 !insertmacro MUI_UNPAGE_COMPONENTS
87 !insertmacro MUI_UNPAGE_INSTFILES
89 ;--------------------------------
90 ;Languages
92 !insertmacro MUI_LANGUAGE "English"
93 !insertmacro MUI_LANGUAGE "French"
95 ;--------------------------------
96 ;Installer Sections
98 Section "OpenTX Companion @VERSION_FAMILY@" SecDummy
100 Delete "$INSTDIR\opentx-*-simulator.dll"
101 RMDir /r "$INSTDIR\lang"
102 RMDir /r "$INSTDIR\phonon_backend"
104 SetOutPath "$INSTDIR"
106 ; Copy the complete distribution folder contents
107 File /r "@NSIS_DISTRO@\*"
109 ;Store installation folder
110 WriteRegStr HKCU "Software\OpenTX\Companion @VERSION_FAMILY@" "" $INSTDIR
112 ;Associate with extentions .otx
113 ${registerExtension} "$INSTDIR\companion.exe" ".otx" "OpenTX Settings File"
115 ;Create uninstaller
116 WriteUninstaller "$INSTDIR\Uninstall.exe"
118 ;Registry information for add/remove programs
119 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "DisplayName" "OpenTX Companion @VERSION_FAMILY@"
120 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
121 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "DisplayIcon" "$\"$INSTDIR\companion.exe$\""
122 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "Publisher" "OpenTX"
123 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "URLInfoAbout" "http://www.open-tx.org"
124 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
126 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
128 ;Create shortcuts
129 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
130 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Companion @VERSION_FAMILY@.lnk" "$INSTDIR\companion.exe"
131 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator @VERSION_FAMILY@.lnk" "$INSTDIR\simulator.exe"
132 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion @VERSION_FAMILY@.lnk" "$INSTDIR\Uninstall.exe"
134 !insertmacro MUI_STARTMENU_WRITE_END
136 SectionEnd
138 ;--------------------------------
139 ;Descriptions
141 ;Language strings
142 LangString DESC_SecDummy ${LANG_ENGLISH} "Models and settings editor for OpenTX"
143 LangString DESC_SecDummy ${LANG_FRENCH} "Editeur de r�glages et mod�les pour OpenTX"
145 ;Assign language strings to sections
146 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
147 !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
148 !insertmacro MUI_FUNCTION_DESCRIPTION_END
150 ;--------------------------------
151 ;Uninstaller Section
153 Section "un.OpenTX Companion @VERSION_FAMILY@"
155 SectionIn RO ; Not deselectable
157 Delete "$INSTDIR\license.txt"
158 Delete "$INSTDIR\companion.exe"
159 Delete "$INSTDIR\simulator.exe"
160 Delete "$INSTDIR\*opentx-*-simulator.dll"
161 Delete "$INSTDIR\SDL.dll"
162 ; MSVC-specific libs
163 Delete "$INSTDIR\msvcp140.dll"
164 Delete "$INSTDIR\vcruntime140.dll"
165 Delete "$INSTDIR\pthreadVC2.dll"
166 ; Qt libs
167 Delete "$INSTDIR\Qt5*.dll"
168 Delete "$INSTDIR\d3dcompiler_47.dll"
169 Delete "$INSTDIR\libEGL.dll"
170 Delete "$INSTDIR\libGLESV2.dll"
171 ; flashing utils
172 Delete "$INSTDIR\avrdude.exe"
173 Delete "$INSTDIR\avrdude.conf"
174 Delete "$INSTDIR\dfu-util.exe"
175 Delete "$INSTDIR\libusb0.dll"
176 Delete "$INSTDIR\libusb-1.0.dll"
177 ; OpenSSL libs
178 Delete "$INSTDIR\libeay32.dll"
179 Delete "$INSTDIR\ssleay32.dll"
180 ; MinGW libs
181 Delete "$INSTDIR\libgcc_s_dw2-1.dll"
182 Delete "$INSTDIR\libstdc++-6.dll"
183 Delete "$INSTDIR\libwinpthread-1.dll"
185 Delete "$INSTDIR\Uninstall.exe"
187 ; Qt plugin folders
188 RMDir /r "$INSTDIR\audio"
189 RMDir /r "$INSTDIR\bearer"
190 RMDir /r "$INSTDIR\iconengines"
191 RMDir /r "$INSTDIR\imageformats"
192 RMDir /r "$INSTDIR\mediaservice"
193 RMDir /r "$INSTDIR\platforms"
194 RMDir /r "$INSTDIR\playlistformats"
195 RMDir /r "$INSTDIR\printsupport"
197 RMDir "$INSTDIR"
199 ${unregisterExtension} ".bin" "BIN File"
200 ${unregisterExtension} ".hex" "HEX File"
201 ${unregisterExtension} ".eepm" "EEPE File"
202 ${unregisterExtension} ".otx" "OpenTX Settings File"
204 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
206 Delete "$SMPROGRAMS\$StartMenuFolder\Companion @VERSION_FAMILY@.lnk"
207 Delete "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator @VERSION_FAMILY@.lnk"
208 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion @VERSION_FAMILY@.lnk"
209 RMDir "$SMPROGRAMS\$StartMenuFolder"
211 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@"
212 SectionEnd
214 Section /o "un.Settings"
215 DeleteRegKey HKCU "Software\OpenTX\Companion @VERSION_FAMILY@"
216 SectionEnd
218 Function LaunchLink
219 ExecShell "" "$INSTDIR\companion.exe"
220 FunctionEnd