blob: 5bc2098ba28b1cb5dbb234a1eeedf31d172daaa2 [file] [log] [blame]
David Pinedoc21fdb92016-01-04 16:31:57 -07001# NSIS Script for creating the Windows Vulkan RT installer.
2#
David Pinedo1e368f72016-02-04 17:04:44 -07003# Copyright (c) 2015-2016 The Khronos Group Inc.
4# Copyright (c) 2015-2016 Valve Corporation
5# Copyright (c) 2015-2016 LunarG, Inc.
David Pinedoc21fdb92016-01-04 16:31:57 -07006#
Jon Ashburn3ebf1252016-04-19 11:30:31 -06007# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
David Pinedoc21fdb92016-01-04 16:31:57 -070010#
Jon Ashburn3ebf1252016-04-19 11:30:31 -060011# http://www.apache.org/licenses/LICENSE-2.0
David Pinedoc21fdb92016-01-04 16:31:57 -070012#
Jon Ashburn3ebf1252016-04-19 11:30:31 -060013# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
David Pinedo1e368f72016-02-04 17:04:44 -070018#
19# Author: David Pinedo <david@LunarG.com>
20# Author: Mark Young <mark@LunarG.com>
David Pinedoc21fdb92016-01-04 16:31:57 -070021#
22
23
24# Version information
David Pinedo3bdbe5d2016-01-12 16:14:53 -070025# Set VERSION_BUILDNO to:
David Pinedo657bd742016-05-05 13:52:37 -060026# x.devbuild.z for development builds
David Pinedo3bdbe5d2016-01-12 16:14:53 -070027# x for releases
28#
Lenny Komowbc37ec22016-11-03 15:43:59 -060029
30# Set the default name to "Vulkan", but allow this to be overriden
31!ifndef APINAME
32 !define APINAME "Vulkan"
Lenny Komow307f0e52016-11-07 15:20:54 -070033 !define APILOWER "vulkan"
Lenny Komowbc37ec22016-11-03 15:43:59 -060034!endif
35
Lenny Komowbc37ec22016-11-03 15:43:59 -060036!define PRODUCTNAME "${APINAME}RT"
37
Lenny Komow841d97a2016-08-04 10:32:27 -060038!ifndef HIDE_VERSION
39 !define VERSION_ABI_MAJOR "1"
40 !define VERSION_API_MAJOR "1"
41 !define VERSION_MINOR "0"
42 !define VERSION_PATCH "12"
43 !define VERSION_BUILDNO "0.devbuild.1"
44!endif
45!ifndef HIDE_PUBLISHER
46 !define PUBLISHER "YourCompany, Inc."
47!endif
Lenny Komow23073822017-04-26 14:55:48 -060048!ifndef COPYRIGHT
49 !define COPYRIGHT ""
50!endif
David Pinedo3bdbe5d2016-01-12 16:14:53 -070051#!define VERSION_BUILDNO "0"
52!define PRODUCTVERSION "${VERSION_API_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILDNO}"
David Pinedoc21fdb92016-01-04 16:31:57 -070053
David Pinedoe8e52032016-01-06 09:59:58 -070054# Includes
55!include LogicLib.nsh
56
David Pinedoc21fdb92016-01-04 16:31:57 -070057# This number is determined by doing an install, and then from Windows Explorer,
58# doing a "Properties" on the install directory. Add to this the size of the
59# files installed to C:\Windows\System32. And then add a little bit more.
David Pinedo94e29b72016-01-04 16:38:15 -070060# The units are 1K bytes.
David Pinedo261d9782016-02-03 13:38:40 -070061!define ESTIMATEDSIZE "1700"
David Pinedoc21fdb92016-01-04 16:31:57 -070062
Mark Youngf1bdefc2016-01-29 16:09:29 -070063# This is used for the error message if a problem occurs during install.
64!define errorMessage1 "Installation of ${PRODUCTNAME} failed!$\r$\n"
David Pinedoe80978b2016-02-13 14:06:55 -070065!define errorMessage1un "Uninstall of ${PRODUCTNAME} failed!$\r$\n"
Mark Youngf1bdefc2016-01-29 16:09:29 -070066!define errorMessage2 "Uninstalling any installed items and exiting.$\r$\n"
67
David Pinedoc21fdb92016-01-04 16:31:57 -070068# Set the icon
David Pinedof79938f2016-02-02 16:10:39 -070069!define ICOFILE "V.ico"
David Pinedoc21fdb92016-01-04 16:31:57 -070070Icon ${ICOFILE}
71UninstallIcon ${ICOFILE}
72WindowIcon off
73
David Pinedo5925ba02016-03-03 21:25:45 -070074# If /DUNINSTALLER was specified, Create the uinstaller
75!ifdef UNINSTALLER
76 !echo "Creating RT uninstaller...."
77 OutFile "$%TEMP%\tempinstaller.exe"
78 SetCompress off
79!else
80 !echo "Creating RT installer...."
81
82 # Define name of installer
Lenny Komowbc37ec22016-11-03 15:43:59 -060083 OutFile "${PRODUCTNAME}-${PRODUCTVERSION}-Installer.exe"
David Pinedo5925ba02016-03-03 21:25:45 -070084 SetCompressor /SOLID lzma
85
86!endif
David Pinedoc21fdb92016-01-04 16:31:57 -070087
88# Define default installation directory
Mark Young4b8b5482016-01-15 15:09:39 -070089InstallDir "$PROGRAMFILES\${PRODUCTNAME}\${PRODUCTVERSION}"
David Pinedoc21fdb92016-01-04 16:31:57 -070090
David Pinedo32eb2ec2016-02-09 09:15:34 -070091# Version string used in file names
David Pinedoe8e52032016-01-06 09:59:58 -070092Var FileVersion
David Pinedoc21fdb92016-01-04 16:31:57 -070093
David Pinedo32eb2ec2016-02-09 09:15:34 -070094# Directory RT was installed to.
95# The uninstaller can't just use $INSTDIR because it is set to the
96# directory the uninstaller exe file is located in.
David Pinedo5925ba02016-03-03 21:25:45 -070097!ifdef UNINSTALLER
David Pinedo32eb2ec2016-02-09 09:15:34 -070098Var IDir
David Pinedo5925ba02016-03-03 21:25:45 -070099!endif
David Pinedo32eb2ec2016-02-09 09:15:34 -0700100
David Pinedo9d092772016-02-09 14:44:05 -0700101# Install count
102Var IC
103
David Pinedoe8e52032016-01-06 09:59:58 -0700104#############################################
105# StrRep - string replace
106
107!define StrRep "!insertmacro StrRep"
108!macro StrRep output string old new
109 Push `${string}`
110 Push `${old}`
111 Push `${new}`
112 !ifdef __UNINSTALL__
113 Call un.StrRep
114 !else
115 Call StrRep
116 !endif
117 Pop ${output}
118!macroend
119
120!macro Func_StrRep un
121 Function ${un}StrRep
122 Exch $R2 ;new
123 Exch 1
124 Exch $R1 ;old
125 Exch 2
126 Exch $R0 ;string
127 Push $R3
128 Push $R4
129 Push $R5
130 Push $R6
131 Push $R7
132 Push $R8
133 Push $R9
134
135 StrCpy $R3 0
136 StrLen $R4 $R1
137 StrLen $R6 $R0
138 StrLen $R9 $R2
139 loop:
140 StrCpy $R5 $R0 $R4 $R3
141 StrCmp $R5 $R1 found
142 StrCmp $R3 $R6 done
143 IntOp $R3 $R3 + 1 ;move offset by 1 to check the next character
144 Goto loop
145 found:
146 StrCpy $R5 $R0 $R3
147 IntOp $R8 $R3 + $R4
148 StrCpy $R7 $R0 "" $R8
149 StrCpy $R0 $R5$R2$R7
150 StrLen $R6 $R0
151 IntOp $R3 $R3 + $R9 ;move offset by length of the replacement string
152 Goto loop
153 done:
154
155 Pop $R9
156 Pop $R8
157 Pop $R7
158 Pop $R6
159 Pop $R5
160 Pop $R4
161 Pop $R3
162 Push $R0
163 Push $R1
164 Pop $R0
165 Pop $R1
166 Pop $R0
167 Pop $R2
168 Exch $R1
169 FunctionEnd
170!macroend
171!insertmacro Func_StrRep ""
172!insertmacro Func_StrRep "un."
173
174#############################################
175# x64 macros
176
177!define IsWow64 `"" IsWow64 ""`
178!macro _IsWow64 _a _b _t _f
179 !insertmacro _LOGICLIB_TEMP
180 System::Call kernel32::GetCurrentProcess()p.s
181 System::Call kernel32::IsWow64Process(ps,*i0s)
182 Pop $_LOGICLIB_TEMP
183 !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
184!macroend
185
186!define RunningX64 `"" RunningX64 ""`
187!macro _RunningX64 _a _b _t _f
188 !if ${NSIS_PTR_SIZE} > 4
189 !insertmacro LogicLib_JumpToBranch `${_t}` `${_f}`
190 !else
191 !insertmacro _IsWow64 `${_a}` `${_b}` `${_t}` `${_f}`
192 !endif
193!macroend
194
195!define DisableX64FSRedirection "!insertmacro DisableX64FSRedirection"
196!macro DisableX64FSRedirection
197 System::Call kernel32::Wow64EnableWow64FsRedirection(i0)
198!macroend
199
200!define EnableX64FSRedirection "!insertmacro EnableX64FSRedirection"
201!macro EnableX64FSRedirection
202 System::Call kernel32::Wow64EnableWow64FsRedirection(i1)
203!macroend
204
David Pinedoc21fdb92016-01-04 16:31:57 -0700205
David Pinedoc21fdb92016-01-04 16:31:57 -0700206# Need admin to write to C:\Windows\System32 and install dir
207RequestExecutionLevel admin
208
Mark Youngf1bdefc2016-01-29 16:09:29 -0700209Function .onInit
David Pinedo1e368f72016-02-04 17:04:44 -0700210
David Pinedo5925ba02016-03-03 21:25:45 -0700211!ifdef UNINSTALLER
212 ; Write out the uinstaller and quit
213 WriteUninstaller "$%TEMP%\Uninstall${PRODUCTNAME}.exe"
214 Quit
215!endif
216
Mark Youngf1bdefc2016-01-29 16:09:29 -0700217FunctionEnd
218
David Pinedoc21fdb92016-01-04 16:31:57 -0700219AddBrandingImage left 150
220Caption "${PRODUCTNAME} ${PRODUCTVERSION} Setup"
221Name "${PRODUCTNAME} ${PRODUCTVERSION}"
David Pinedo41eb93f2016-01-29 12:20:49 -0700222LIcenseData "VULKANRT_LICENSE.rtf"
David Pinedoc21fdb92016-01-04 16:31:57 -0700223Page custom brandimage "" ": Brand Image"
David Pinedo41eb93f2016-01-29 12:20:49 -0700224Page license
David Pinedoc21fdb92016-01-04 16:31:57 -0700225Page directory
226Page instfiles
227UninstallCaption "\${PRODUCTNAME} ${PRODUCTVERSION} Uninstall"
228UninstallText "This wizard will uninstall ${PRODUCTNAME} ${PRODUCTVERSION} from your computer. Click Uninstall to start the uninstallation."
229UninstPage custom un.brandimage "" ": Brand Image"
230UninstPage uninstConfirm
231UninstPage instFiles
232
David Pinedo37976332016-02-10 16:20:45 -0700233# File Properties
234VIProductVersion "${PRODUCTVERSION}"
Lenny Komowbc37ec22016-11-03 15:43:59 -0600235VIAddVersionKey "ProductName" "${APINAME} Runtime"
David Pinedo37976332016-02-10 16:20:45 -0700236VIAddVersionKey "FileVersion" "${PRODUCTVERSION}"
237VIAddVersionKey "ProductVersion" "${PRODUCTVERSION}"
Lenny Komow23073822017-04-26 14:55:48 -0600238VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
David Pinedo37976332016-02-10 16:20:45 -0700239
David Pinedoe1af1b02016-04-08 16:33:29 -0600240!ifdef UNINSTALLER
Lenny Komowbc37ec22016-11-03 15:43:59 -0600241 VIAddVersionKey "FileDescription" "${APINAME} Runtime Uninstaller"
David Pinedoe1af1b02016-04-08 16:33:29 -0600242!else
Lenny Komowbc37ec22016-11-03 15:43:59 -0600243 VIAddVersionKey "FileDescription" "${APINAME} Runtime Installer"
David Pinedoe1af1b02016-04-08 16:33:29 -0600244!endif
245
David Pinedo19fc3962016-06-07 09:35:56 -0600246
Lenny Komow769b9df2016-08-12 13:26:20 -0600247# Function to run ConfigureRT program.
David Pinedo19fc3962016-06-07 09:35:56 -0600248# Return value is in $0 - 0 is success, all else is failure.
249!macro ConfigLayersAndVulkanDLL un
250Function ${un}ConfigLayersAndVulkanDLL
Lenny Komow769b9df2016-08-12 13:26:20 -0600251
252 # Execute the configuration program
Lenny Komowcaa3ab82016-11-04 10:38:39 -0600253 nsExec::ExecToStack 'ConfigureRT.exe --abi-major ${VERSION_ABI_MAJOR} --api-name ${APINAME}'
Lenny Komow4443fe82016-08-31 10:41:19 -0600254 Delete "$TEMP\VulkanRT\configure_rt.log"
Lenny Komow769b9df2016-08-12 13:26:20 -0600255 Rename "configure_rt.log" "$TEMP\VulkanRT\configure_rt.log"
256 pop $0
257
258 # Ignore errors. If something went wrong, the return value will indicate it.
David Pinedod1282e52016-06-10 11:37:44 -0600259 ClearErrors
260
David Pinedo19fc3962016-06-07 09:35:56 -0600261FunctionEnd
262!macroend
263!insertmacro ConfigLayersAndVulkanDLL ""
264!insertmacro ConfigLayersAndVulkanDLL "un."
265
266
Lenny Komow769b9df2016-08-12 13:26:20 -0600267# Function to run diagnostics if ConfigureRT program failed.
268# On entry $0, contains the return value from ConfigureRT.exe. It shouldn't be changed.
David Pinedo19fc3962016-06-07 09:35:56 -0600269!macro DiagConfigLayersAndVulkanDLL un
Lenny Komow769b9df2016-08-12 13:26:20 -0600270Function ${un}DiagConfigLayersAndVulkanDLL
271 # Report the failure
272 LogText "ConfigureRT.exe failed with return code $0"
273
David Pinedod1282e52016-06-10 11:37:44 -0600274 # Ignore errors
275 ClearErrors
276
David Pinedo19fc3962016-06-07 09:35:56 -0600277FunctionEnd
278!macroend
279!insertmacro DiagConfigLayersAndVulkanDLL ""
280!insertmacro DiagConfigLayersAndVulkanDLL "un."
281
David Pinedoc21fdb92016-01-04 16:31:57 -0700282# Start default section
283Section
284
David Pinedoef68bbe2016-03-29 13:46:12 -0600285 # Turn on logging
286 LogSet on
287
Mark Younga8557b82016-01-15 16:01:46 -0700288 # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable.
Mark Youngdd9eca72016-01-15 14:11:32 -0700289 ${If} ${RunningX64}
Mark Youngf1bdefc2016-01-29 16:09:29 -0700290
Mark Youngdd9eca72016-01-15 14:11:32 -0700291 ${DisableX64FSRedirection}
292 SetRegView 64
David Pinedoc21fdb92016-01-04 16:31:57 -0700293
Mark Young4b8b5482016-01-15 15:09:39 -0700294 ${Endif}
David Pinedoc21fdb92016-01-04 16:31:57 -0700295
David Pinedo7f44f4f2016-03-18 13:15:27 -0600296 # Create our temp directory, with minimal permissions
David Pinedo19fc3962016-06-07 09:35:56 -0600297 RmDir /R "$TEMP\VulkanRT"
298 SetOutPath "$TEMP\VulkanRT"
299 AccessControl::DisableFileInheritance $TEMP\VulkanRT
300 AccessControl::SetFileOwner $TEMP\VulkanRT "Administrators"
301 AccessControl::ClearOnFile $TEMP\VulkanRT "Administrators" "FullAccess"
302 AccessControl::SetOnFile $TEMP\VulkanRT "SYSTEM" "FullAccess"
303 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ListDirectory"
304 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericExecute"
305 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "GenericRead"
306 AccessControl::GrantOnFile $TEMP\VulkanRT "Everyone" "ReadAttributes"
David Pinedo7f44f4f2016-03-18 13:15:27 -0600307 StrCpy $1 10
308 Call CheckForError
309
310 # Check the registry to see if we are already installed
David Pinedo55805972016-02-08 12:20:11 -0700311 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir"
David Pinedo6ab257c2016-02-10 11:03:29 -0700312
313 # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors.
314 ${If} ${Errors}
315
316 # Nothing else to do since there is no previous install
317 ClearErrors
318
319 ${Else}
320
321 # Use the previous install directory, so we don't have to keep tracking every possible runtime install.
322 strcmp $INSTDIR $0 notinstalled
323
324 ${If} $0 != ""
Lenny Komowbc37ec22016-11-03 15:43:59 -0600325 MessageBox MB_OK "The Windows ${APINAME} Runtime is already installed to $0. It will be re-installed to the same folder." /SD IDOK
David Pinedo6ab257c2016-02-10 11:03:29 -0700326 Strcpy $INSTDIR $0
327 ${Endif}
328
329 notinstalled:
330
331 ${EndIf}
David Pinedo55805972016-02-08 12:20:11 -0700332
Mark Youngf1bdefc2016-01-29 16:09:29 -0700333 SetOutPath "$INSTDIR"
David Pinedo7f44f4f2016-03-18 13:15:27 -0600334 AccessControl::DisableFileInheritance $INSTDIR
335 AccessControl::SetFileOwner $INSTDIR "Administrators"
336 AccessControl::ClearOnFile $INSTDIR "Administrators" "FullAccess"
337 AccessControl::SetOnFile $INSTDIR "SYSTEM" "FullAccess"
338 AccessControl::GrantOnFile $INSTDIR "Everyone" "ListDirectory"
339 AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericExecute"
340 AccessControl::GrantOnFile $INSTDIR "Everyone" "GenericRead"
341 AccessControl::GrantOnFile $INSTDIR "Everyone" "ReadAttributes"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700342 File ${ICOFILE}
343 File VULKANRT_LICENSE.RTF
David Pinedob5d98a92016-04-19 13:36:49 -0600344 File /oname=LICENSE.txt ..\COPYRIGHT.txt
Lenny Komow769b9df2016-08-12 13:26:20 -0600345 File Release\ConfigureRT.exe
David Pinedo7f44f4f2016-03-18 13:15:27 -0600346 StrCpy $1 15
David Pinedo6ab257c2016-02-10 11:03:29 -0700347 Call CheckForError
Mark Youngf1bdefc2016-01-29 16:09:29 -0700348
David Pinedo5925ba02016-03-03 21:25:45 -0700349 # Add the signed uninstaller
350 !ifndef UNINSTALLER
351 SetOutPath $INSTDIR
352 File "Uninstall${PRODUCTNAME}.exe"
353 !endif
354
David Pinedo7f44f4f2016-03-18 13:15:27 -0600355 StrCpy $1 20
David Pinedo6ab257c2016-02-10 11:03:29 -0700356 Call CheckForError
Mark Youngf1bdefc2016-01-29 16:09:29 -0700357
358 # Reference count the number of times we have been installed.
David Pinedo9d092772016-02-09 14:44:05 -0700359 # The reference count is stored in the registry value InstallCount
Mark Youngf1bdefc2016-01-29 16:09:29 -0700360 ReadRegDword $1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount"
361 IntOp $1 $1 + 1
David Pinedo9d092772016-02-09 14:44:05 -0700362 StrCpy $IC $1
363
364 # We need to create a new folder for each install. Since we are using counted installs,
365 # an uninstall when the count is greater than one would result in the install
366 # count being decremented and nothing being removed. But Windows Add/Remove Programs
367 # generates a warning Window if the install dir for a package that is removed is not
368 # deleted. So we create a unique folder for each counted install.
369 # We fudge it a little and only create one folder, and rename it after each
370 # install/uninstall.
371
372 # Create the install instance folder. We rename the install instance folder if it already exists.
373 # Then copy the uninstaller to it.
374 ${If} $IC > 2
375 IntOp $1 $IC - 1
376 Rename "$INSTDIR\Instance_$1" "$INSTDIR\Instance_$IC"
377 CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC"
378 ${ElseIf} $IC = 2
379 CreateDirectory "$INSTDIR\Instance_$IC"
380 CopyFiles /SILENT "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$INSTDIR\Instance_$IC"
381 ${EndIf}
382
David Pinedo1e368f72016-02-04 17:04:44 -0700383
Mark Youngf1bdefc2016-01-29 16:09:29 -0700384 # If the registry entry isn't there, it will throw an error as well as return a blank value. So, clear the errors.
385 ${If} ${Errors}
386 ClearErrors
387 ${EndIf}
388
Mark Youngf1bdefc2016-01-29 16:09:29 -0700389 # Modify registry for Programs and Features
Lenny Komowbc37ec22016-11-03 15:43:59 -0600390 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayName" "${APINAME} Run Time Libraries ${PRODUCTVERSION}"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700391 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "UninstallString" "$INSTDIR\Uninstall${PRODUCTNAME}.exe"
David Pinedo55805972016-02-08 12:20:11 -0700392 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "Publisher" "${PUBLISHER}"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700393 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayVersion" "${PRODUCTVERSION}"
394 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "EstimatedSize" ${ESTIMATEDSIZE}
395 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\""
David Pinedo55805972016-02-08 12:20:11 -0700396 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir" "$INSTDIR"
David Pinedo9d092772016-02-09 14:44:05 -0700397 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $IC
398
399 ${If} $IC > 1
Lenny Komowbc37ec22016-11-03 15:43:59 -0600400 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayName" "${APINAME} Run Time Libraries ${PRODUCTVERSION}"
David Pinedo9d092772016-02-09 14:44:05 -0700401 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "UninstallString" "$INSTDIR\Instance_$IC\Uninstall${PRODUCTNAME}.exe"
402 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "Publisher" "${PUBLISHER}"
403 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayVersion" "${PRODUCTVERSION}"
404 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "EstimatedSize" ${ESTIMATEDSIZE}
405 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "DisplayIcon" "$\"$INSTDIR\${ICOFILE}$\""
406 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallDir" "$INSTDIR\Instance_$IC"
407 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "InstallCount" $IC
408 ${EndIf}
409
410 # Set SystemComponent to 1 for those instances that are not to be visible to Add/Remove Programs.
411 # Set SystemComponent to 0 for the instance that is to be visible to Add/Remove Programs.
Lenny Komowe0231d92017-07-18 11:20:05 -0600412 ${If} $IC > 1
413 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 1
David Pinedo9d092772016-02-09 14:44:05 -0700414 ${Else}
Lenny Komowe0231d92017-07-18 11:20:05 -0600415 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 1
David Pinedo9d092772016-02-09 14:44:05 -0700416 ${EndIf}
417
David Pinedo7f44f4f2016-03-18 13:15:27 -0600418 StrCpy $1 25
David Pinedo6ab257c2016-02-10 11:03:29 -0700419 Call CheckForError
Mark Youngf1bdefc2016-01-29 16:09:29 -0700420
Mark Young4b8b5482016-01-15 15:09:39 -0700421 # Set up version number for file names
422 ${StrRep} $0 ${VERSION_BUILDNO} "." "-"
423 StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0
424
David Pinedof2c7ed92016-03-29 16:29:00 -0600425 # Complete remove the Vulkan Start Menu. Prior version of the Vulkan RT
426 # created Start Menu items, we don't do that anymore.
David Pinedocf290632016-03-03 12:36:24 -0700427 SetShellVarContext all
David Pinedof2c7ed92016-03-29 16:29:00 -0600428 RmDir /R "$SMPROGRAMS\Vulkan"
David Pinedocf290632016-03-03 12:36:24 -0700429 ClearErrors
430
Mark Young4b8b5482016-01-15 15:09:39 -0700431 # If running on a 64-bit OS machine
432 ${If} ${RunningX64}
Mark Youngf1bdefc2016-01-29 16:09:29 -0700433
Mark Youngdd9eca72016-01-15 14:11:32 -0700434 # 32-bit DLLs/EXEs destined for SysWOW64
435 ##########################################
436 SetOutPath $WINDIR\SysWow64
Lenny Komowbd0d9382017-02-10 10:44:37 -0700437 File /oname=${APILOWER}-$FileVersion.dll ..\build32\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll
438 File /oname=${APILOWER}info-$FileVersion.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe
David Pinedo7f44f4f2016-03-18 13:15:27 -0600439 StrCpy $1 30
David Pinedo6ab257c2016-02-10 11:03:29 -0700440 Call CheckForError
Mark Youngf1bdefc2016-01-29 16:09:29 -0700441
Mark Youngdd9eca72016-01-15 14:11:32 -0700442 # 64-bit DLLs/EXEs
443 ##########################################
444 SetOutPath $WINDIR\System32
Lenny Komowbd0d9382017-02-10 10:44:37 -0700445 File /oname=${APILOWER}-$FileVersion.dll ..\build\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll
David Pinedo7f44f4f2016-03-18 13:15:27 -0600446 StrCpy $1 35
David Pinedo6ab257c2016-02-10 11:03:29 -0700447 Call CheckForError
Mark Youngdd9eca72016-01-15 14:11:32 -0700448
449 # vulkaninfo.exe
Lenny Komowbd0d9382017-02-10 10:44:37 -0700450 File /oname=${APILOWER}info-$FileVersion.exe ..\build\demos\RelWithDebInfo\${APILOWER}info.exe
Mark Youngdd9eca72016-01-15 14:11:32 -0700451 SetOutPath "$INSTDIR"
Lenny Komowbd0d9382017-02-10 10:44:37 -0700452 File /oname=${APILOWER}info.exe ..\build\demos\RelWithDebInfo\${APILOWER}info.exe
453 File /oname=${APILOWER}info32.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe
David Pinedo7f44f4f2016-03-18 13:15:27 -0600454 StrCpy $1 40
David Pinedo6ab257c2016-02-10 11:03:29 -0700455 Call CheckForError
Mark Youngdd9eca72016-01-15 14:11:32 -0700456
Mark Youngdd9eca72016-01-15 14:11:32 -0700457 # Else, running on a 32-bit OS machine
458 ${Else}
Mark Youngf1bdefc2016-01-29 16:09:29 -0700459
Mark Young4b8b5482016-01-15 15:09:39 -0700460 # 32-bit DLLs/EXEs destined for SysWOW64
461 ##########################################
462 SetOutPath $WINDIR\System32
Lenny Komowbd0d9382017-02-10 10:44:37 -0700463 File /oname=${APILOWER}-$FileVersion.dll ..\build32\loader\RelWithDebInfo\${APILOWER}-${VERSION_ABI_MAJOR}.dll
David Pinedo7f44f4f2016-03-18 13:15:27 -0600464 StrCpy $1 50
David Pinedo6ab257c2016-02-10 11:03:29 -0700465 Call CheckForError
Mark Young4b8b5482016-01-15 15:09:39 -0700466
467 # vulkaninfo.exe
Lenny Komowbd0d9382017-02-10 10:44:37 -0700468 File /oname=${APILOWER}info-$FileVersion.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe
Mark Young4b8b5482016-01-15 15:09:39 -0700469 SetOutPath "$INSTDIR"
Lenny Komow67e0ffc2017-04-04 15:35:28 -0600470 File /oname=${APILOWER}info.exe ..\build32\demos\RelWithDebInfo\${APILOWER}info.exe
David Pinedo7f44f4f2016-03-18 13:15:27 -0600471 StrCpy $1 55
David Pinedo6ab257c2016-02-10 11:03:29 -0700472 Call CheckForError
Mark Young4b8b5482016-01-15 15:09:39 -0700473
Mark Youngdd9eca72016-01-15 14:11:32 -0700474 ${Endif}
David Pinedoc21fdb92016-01-04 16:31:57 -0700475
Lenny Komow769b9df2016-08-12 13:26:20 -0600476 # Run the ConfigureRT program to copy the most recent version of
David Pinedo19fc3962016-06-07 09:35:56 -0600477 # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry
478 # entries to use layers from the corresponding SDK
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600479 SetOutPath "$INSTDIR"
David Pinedo19fc3962016-06-07 09:35:56 -0600480 Call ConfigLayersAndVulkanDLL
481 ${If} $0 != 0
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600482 SetOutPath "$INSTDIR"
David Pinedo19fc3962016-06-07 09:35:56 -0600483 Call DiagConfigLayersAndVulkanDLL
David Pinedo1d1d5772016-06-09 16:12:44 -0600484
Lenny Komow769b9df2016-08-12 13:26:20 -0600485 # The program failed, and we don't know why.
David Pinedo1d1d5772016-06-09 16:12:44 -0600486 # Simply configure system to use our loader and vulkaninfo.
Lenny Komowd8b4f6b2016-08-31 09:45:46 -0600487 MessageBox MB_OK "Warning!$\n$\nConfigureRT program called by VulkanRT Installer failed with error $0. This may result in an incomplete installation.$\n$\nWill configure system with Vulkan $FileVersion." /SD IDOK
David Pinedo1d1d5772016-06-09 16:12:44 -0600488 ${If} ${RunningX64}
Lenny Komow307f0e52016-11-07 15:20:54 -0700489 Delete $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll
490 Delete $WINDIR\SysWow64\${APILOWER}info.exe
491 CopyFiles /SILENT $WINDIR\SysWow64\${APILOWER}-$FileVersion.dll $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll
492 CopyFiles /SILENT $WINDIR\SysWow64\${APILOWER}info-$FileVersion.exe $WINDIR\SysWow64\${APILOWER}info.exe
David Pinedo1d1d5772016-06-09 16:12:44 -0600493 ${Endif}
Lenny Komow307f0e52016-11-07 15:20:54 -0700494 Delete $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll
495 Delete $WINDIR\System32\${APILOWER}info.exe
496 CopyFiles /SILENT $WINDIR\System32\${APILOWER}-$FileVersion.dll $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll
497 CopyFiles /SILENT $WINDIR\System32\${APILOWER}info-$FileVersion.exe $WINDIR\System32\${APILOWER}info.exe
David Pinedo1d1d5772016-06-09 16:12:44 -0600498 ClearErrors
David Pinedo19fc3962016-06-07 09:35:56 -0600499 ${Endif}
David Pinedo1d1d5772016-06-09 16:12:44 -0600500 StrCpy $1 60
David Pinedo19fc3962016-06-07 09:35:56 -0600501 Call CheckForError
502
Lenny Komow769b9df2016-08-12 13:26:20 -0600503 # We are done using ConfigureRT.exe, delete it. It will be re-installed
Mark Youngf1bdefc2016-01-29 16:09:29 -0700504 # by the uninstaller when it needs to be run again during uninstall.
Lenny Komow769b9df2016-08-12 13:26:20 -0600505 Delete ConfigureRT.exe
Mark Young4b8b5482016-01-15 15:09:39 -0700506
David Pinedoef68bbe2016-03-29 13:46:12 -0600507 # Finish logging and move log file to TEMP dir
508 LogSet off
David Pinedo19fc3962016-06-07 09:35:56 -0600509 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\installer.log"
David Pinedoef68bbe2016-03-29 13:46:12 -0600510
David Pinedoc21fdb92016-01-04 16:31:57 -0700511SectionEnd
512
513# Uninstaller section start
David Pinedo5925ba02016-03-03 21:25:45 -0700514!ifdef UNINSTALLER
David Pinedoc21fdb92016-01-04 16:31:57 -0700515Section "uninstall"
David Pinedo3fc22bf2016-04-05 16:40:08 -0600516 # Turn on logging
David Pinedo19fc3962016-06-07 09:35:56 -0600517 SetOutPath "$TEMP\VulkanRT"
518 StrCpy $INSTDIR "$TEMP\VulkanRT"
David Pinedo3fc22bf2016-04-05 16:40:08 -0600519 LogSet on
520
Mark Younga8557b82016-01-15 16:01:46 -0700521 # If running on a 64-bit OS machine, disable registry re-direct since we're running as a 32-bit executable.
Mark Youngdd9eca72016-01-15 14:11:32 -0700522 ${If} ${RunningX64}
David Pinedoc21fdb92016-01-04 16:31:57 -0700523
Mark Youngdd9eca72016-01-15 14:11:32 -0700524 ${DisableX64FSRedirection}
525 SetRegView 64
Mark Youngf1bdefc2016-01-29 16:09:29 -0700526
Mark Young4b8b5482016-01-15 15:09:39 -0700527 ${Endif}
David Pinedoc21fdb92016-01-04 16:31:57 -0700528
David Pinedo32eb2ec2016-02-09 09:15:34 -0700529 # Look up the install dir and remove files from that directory.
David Pinedo32eb2ec2016-02-09 09:15:34 -0700530 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallDir"
David Pinedo9d092772016-02-09 14:44:05 -0700531 StrCpy $IDir $0
David Pinedo32eb2ec2016-02-09 09:15:34 -0700532
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600533 StrCpy $1 65
David Pinedo6ab257c2016-02-10 11:03:29 -0700534 Call un.CheckForError
535
David Pinedo32eb2ec2016-02-09 09:15:34 -0700536 SetOutPath "$IDir"
David Pinedoc21fdb92016-01-04 16:31:57 -0700537
Mark Young4b8b5482016-01-15 15:09:39 -0700538 # Set up version number for file names
539 ${StrRep} $0 ${VERSION_BUILDNO} "." "-"
540 StrCpy $FileVersion ${VERSION_ABI_MAJOR}-${VERSION_API_MAJOR}-${VERSION_MINOR}-${VERSION_PATCH}-$0
David Pinedoc21fdb92016-01-04 16:31:57 -0700541
Mark Young4b8b5482016-01-15 15:09:39 -0700542 # Decrement the number of times we have been installed.
David Pinedo9d092772016-02-09 14:44:05 -0700543 ReadRegDword $IC HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount"
544 IntOp $1 $IC - 1
David Pinedob4d7f6a2016-01-27 14:15:25 -0700545 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "InstallCount" $1
David Pinedoc21fdb92016-01-04 16:31:57 -0700546
David Pinedo9d092772016-02-09 14:44:05 -0700547 # Rename the install dir for this instance if is not the last uninstall
548 ${If} $IC > 2
549 IntOp $1 $IC - 1
550 Rename "$IDir\Instance_$IC" "$IDir\Instance_$1"
551 ${ElseIf} $IC = 2
David Pinedo5925ba02016-03-03 21:25:45 -0700552 Delete /REBOOTOK "$IDir\Instance_$IC\Uninstall${PRODUCTNAME}.exe"
David Pinedo9d092772016-02-09 14:44:05 -0700553 Rmdir /REBOOTOK "$IDir\Instance_$IC"
554 ${Endif}
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600555 StrCpy $1 70
556 Call un.CheckForError
David Pinedo9d092772016-02-09 14:44:05 -0700557
558 # Modify registry for Programs and Features
David Pinedocf290632016-03-03 12:36:24 -0700559
560 ${If} $IC > 1
561 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC"
562 ${EndIf}
David Pinedo9d092772016-02-09 14:44:05 -0700563 ${If} $IC > 2
564 IntOp $IC $IC - 1
Lenny Komowe0231d92017-07-18 11:20:05 -0600565 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}-$IC" "SystemComponent" 1
David Pinedo9d092772016-02-09 14:44:05 -0700566 ${ElseIf} $IC = 2
Lenny Komowe0231d92017-07-18 11:20:05 -0600567 WriteRegDword HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}" "SystemComponent" 1
David Pinedo9d092772016-02-09 14:44:05 -0700568 ${Else}
569 # Last uninstall
570 IntOp $IC $IC - 1
571 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}${PRODUCTVERSION}"
572 ${EndIf}
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600573 StrCpy $1 75
574 Call un.CheckForError
David Pinedo9d092772016-02-09 14:44:05 -0700575
David Pinedod133b782016-03-16 14:41:56 -0600576
Lenny Komow769b9df2016-08-12 13:26:20 -0600577 # Install ConfigureRT.exe so we can run it.
David Pinedod133b782016-03-16 14:41:56 -0600578 # It will be deleted later when we remove the install directory.
Lenny Komow769b9df2016-08-12 13:26:20 -0600579 File Release\ConfigureRT.exe
David Pinedod133b782016-03-16 14:41:56 -0600580
581 # If running on a 64-bit OS machine
582 ${If} ${RunningX64}
583
584 # Delete vulkaninfo.exe in C:\Windows\System32 and C:\Windows\SysWOW64
Lenny Komow307f0e52016-11-07 15:20:54 -0700585 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}info.exe
586 Delete /REBOOTOK $WINDIR\System32\${APILOWER}info.exe
David Pinedod133b782016-03-16 14:41:56 -0600587
Mark Young013dd062016-06-22 16:55:31 -0600588 # Delete vulkan-<majorabi>.dll in C:\Windows\System32 and C:\Windows\SysWOW64
Lenny Komow307f0e52016-11-07 15:20:54 -0700589 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll
590 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll
David Pinedod133b782016-03-16 14:41:56 -0600591
David Pinedod133b782016-03-16 14:41:56 -0600592 # Else, running on a 32-bit OS machine
593 ${Else}
594
595 # Delete vulkaninfo.exe in C:\Windows\System32
Lenny Komow307f0e52016-11-07 15:20:54 -0700596 Delete /REBOOTOK $WINDIR\System32\${APILOWER}info.exe
David Pinedod133b782016-03-16 14:41:56 -0600597
Mark Young013dd062016-06-22 16:55:31 -0600598 # Delete vulkan-<majorabi>.dll in C:\Windows\System32
Lenny Komow307f0e52016-11-07 15:20:54 -0700599 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll
David Pinedod133b782016-03-16 14:41:56 -0600600
David Pinedod133b782016-03-16 14:41:56 -0600601 ${EndIf}
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600602 StrCpy $1 80
603 Call un.CheckForError
David Pinedod133b782016-03-16 14:41:56 -0600604
Mark Young013dd062016-06-22 16:55:31 -0600605 # If Ref Count is zero, remove files in C:\Windows\System32 and C:\Windows\SysWow64
606 ${If} $IC <= 0
607
608 ${If} ${RunningX64}
609 # Delete vulkaninfo.exe in C:\Windows\System32 and C:\Windows\SysWOW64
Lenny Komow307f0e52016-11-07 15:20:54 -0700610 Delete /REBOOTOK "$WINDIR\SysWow64\${APILOWER}info-$FileVersion.exe"
611 Delete /REBOOTOK "$WINDIR\System32\${APILOWER}info-$FileVersion.exe"
Mark Young013dd062016-06-22 16:55:31 -0600612 # Delete vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll from sys dirs
Lenny Komow307f0e52016-11-07 15:20:54 -0700613 Delete /REBOOTOK $WINDIR\SysWow64\${APILOWER}-$FileVersion.dll
614 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-$FileVersion.dll
Mark Young013dd062016-06-22 16:55:31 -0600615 ${Else}
616 # Delete vulkaninfo.exe in C:\Windows\System32
Lenny Komow307f0e52016-11-07 15:20:54 -0700617 Delete /REBOOTOK "$WINDIR\System32\${APILOWER}info-$FileVersion.exe"
Mark Young013dd062016-06-22 16:55:31 -0600618 # Delete vulkan-<majorabi>-<major>-<minor>-<patch>-<buildno>.dll from sys dir
Lenny Komow307f0e52016-11-07 15:20:54 -0700619 Delete /REBOOTOK $WINDIR\System32\${APILOWER}-$FileVersion.dll
Mark Young013dd062016-06-22 16:55:31 -0600620 ${EndIf}
621
622 ${Endif}
623
Lenny Komow769b9df2016-08-12 13:26:20 -0600624 # Run the ConfigureRT.exe program to copy the most recent version of
David Pinedo19fc3962016-06-07 09:35:56 -0600625 # vulkan-<abimajor>-*.dll to vulkan-<abimajor>.dll, and to set up layer registry
626 # entries to use layers from the corresponding SDK
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600627 SetOutPath "$IDir"
David Pinedo19fc3962016-06-07 09:35:56 -0600628 Call un.ConfigLayersAndVulkanDLL
629 ${If} $0 != 0
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600630 SetOutPath "$IDir"
David Pinedo19fc3962016-06-07 09:35:56 -0600631 Call un.DiagConfigLayersAndVulkanDLL
Lenny Komow307f0e52016-11-07 15:20:54 -0700632 MessageBox MB_OK "Warning!$\n$\nConfigureRT program called by ${APILOWER} Runtime Installer failed with error $0. This may result in an incomplete uninstall.$\n$\nVulkan $FileVersion has been uninstalled from your system." /SD IDOK
David Pinedo1d1d5772016-06-09 16:12:44 -0600633 ${If} ${RunningX64}
Lenny Komow307f0e52016-11-07 15:20:54 -0700634 Delete $WINDIR\SysWow64\${APILOWER}-${VERSION_ABI_MAJOR}.dll
635 Delete $WINDIR\SysWow64\${APILOWER}info.exe
David Pinedo1d1d5772016-06-09 16:12:44 -0600636 ${Endif}
Lenny Komow307f0e52016-11-07 15:20:54 -0700637 Delete $WINDIR\System32\${APILOWER}-${VERSION_ABI_MAJOR}.dll
638 Delete $WINDIR\System32\${APILOWER}info.exe
David Pinedo1d1d5772016-06-09 16:12:44 -0600639 ClearErrors
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600640 ${Else}
641 StrCpy $1 85
David Pinedo19fc3962016-06-07 09:35:56 -0600642 ${Endif}
David Pinedo19fc3962016-06-07 09:35:56 -0600643 Call un.CheckForError
Lenny Komow992fbc72016-09-09 09:43:17 -0600644
645 # Remove ConfigureRT regardless of the ref count
646 Delete /REBOOTOK "$IDir\ConfigureRT.exe"
David Pinedo19fc3962016-06-07 09:35:56 -0600647
Mark Young013dd062016-06-22 16:55:31 -0600648 # If Ref Count is zero, remove install dir
David Pinedo9d092772016-02-09 14:44:05 -0700649 ${If} $IC <= 0
David Pinedoc21fdb92016-01-04 16:31:57 -0700650
Mark Young4b8b5482016-01-15 15:09:39 -0700651 # Remove files in install dir
David Pinedo32eb2ec2016-02-09 09:15:34 -0700652 Delete /REBOOTOK "$IDir\VULKANRT_LICENSE.rtf"
653 Delete /REBOOTOK "$IDir\LICENSE.txt"
David Pinedo5925ba02016-03-03 21:25:45 -0700654 Delete /REBOOTOK "$IDir\Uninstall${PRODUCTNAME}.exe"
David Pinedo32eb2ec2016-02-09 09:15:34 -0700655 Delete /REBOOTOK "$IDir\V.ico"
Lenny Komow307f0e52016-11-07 15:20:54 -0700656 Delete /REBOOTOK "$IDir\${APILOWER}info.exe"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700657
Mark Youngf7c705b2016-01-26 13:36:28 -0700658 # If running on a 64-bit OS machine
659 ${If} ${RunningX64}
Lenny Komow307f0e52016-11-07 15:20:54 -0700660 Delete /REBOOTOK "$IDir\${APILOWER}info32.exe"
Mark Youngf7c705b2016-01-26 13:36:28 -0700661 ${EndIf}
Mark Young4b8b5482016-01-15 15:09:39 -0700662
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600663 StrCpy $1 90
David Pinedo6ab257c2016-02-10 11:03:29 -0700664 Call un.CheckForError
665
David Pinedo32eb2ec2016-02-09 09:15:34 -0700666 # Need to do a SetOutPath to something outside of install dir,
667 # or the uninstall will think install dir is busy
Mark Young4b8b5482016-01-15 15:09:39 -0700668 SetOutPath "$TEMP"
669
670 # Remove install directories
David Pinedo7f44f4f2016-03-18 13:15:27 -0600671 StrCpy $0 "$IDir"
672 Call un.DeleteDirIfEmpty
Mark Young4b8b5482016-01-15 15:09:39 -0700673 StrCpy $0 "$PROGRAMFILES\${PRODUCTNAME}"
674 Call un.DeleteDirIfEmpty
David Pinedocf290632016-03-03 12:36:24 -0700675 ClearErrors
Mark Young4b8b5482016-01-15 15:09:39 -0700676
677 # If any of the remove commands failed, request a reboot
Mark Young0368c7d2016-02-02 10:56:42 -0700678 IfRebootFlag 0 noreboot
679 MessageBox MB_YESNO "A reboot is required to finish the uninstall. Do you wish to reboot now?" /SD IDNO IDNO returnerror
680 Reboot
David Pinedo1e368f72016-02-04 17:04:44 -0700681
Mark Young0368c7d2016-02-02 10:56:42 -0700682 returnerror:
David Pinedo1e368f72016-02-04 17:04:44 -0700683
Mark Young0368c7d2016-02-02 10:56:42 -0700684 # Set an error message to output because we should reboot but didn't (whether because silent uninstall or user choice)
685 SetErrorLevel 3 # ERROR_TOO_MANY_OPEN_FILES
686
Mark Young4b8b5482016-01-15 15:09:39 -0700687 noreboot:
Mark Youngf1bdefc2016-01-29 16:09:29 -0700688
Mark Youngdd9eca72016-01-15 14:11:32 -0700689 ${Endif}
David Pinedoc21fdb92016-01-04 16:31:57 -0700690
David Pinedo1d6bb4e2016-06-08 16:30:06 -0600691 StrCpy $1 95
David Pinedo6ab257c2016-02-10 11:03:29 -0700692 Call un.CheckForError
693
David Pinedo8671af52016-06-03 12:08:12 -0600694 # Finish logging
David Pinedoef68bbe2016-03-29 13:46:12 -0600695 LogSet off
David Pinedo19fc3962016-06-07 09:35:56 -0600696 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\uninstaller.log"
David Pinedo7f44f4f2016-03-18 13:15:27 -0600697
David Pinedoc21fdb92016-01-04 16:31:57 -0700698SectionEnd
David Pinedo5925ba02016-03-03 21:25:45 -0700699!endif
David Pinedoc21fdb92016-01-04 16:31:57 -0700700
701Function brandimage
702 SetOutPath "$TEMP"
David Pinedof79938f2016-02-02 16:10:39 -0700703 SetFileAttributes V.bmp temporary
704 File V.bmp
705 SetBrandingImage "$TEMP/V.bmp"
David Pinedoc21fdb92016-01-04 16:31:57 -0700706Functionend
707
708
709Function un.brandimage
710 SetOutPath "$TEMP"
David Pinedof79938f2016-02-02 16:10:39 -0700711 SetFileAttributes V.bmp temporary
712 File V.bmp
713 SetBrandingImage "$TEMP/V.bmp"
David Pinedoc21fdb92016-01-04 16:31:57 -0700714Functionend
715
716Function un.DeleteDirIfEmpty
717 FindFirst $R0 $R1 "$0\*.*"
718 strcmp $R1 "." 0 NoDelete
719 FindNext $R0 $R1
720 strcmp $R1 ".." 0 NoDelete
721 ClearErrors
722 FindNext $R0 $R1
723 IfErrors 0 NoDelete
724 FindClose $R0
725 Sleep 1000
726 RMDir "$0"
727 NoDelete:
728 FindClose $R0
729FunctionEnd
Mark Youngf1bdefc2016-01-29 16:09:29 -0700730
David Pinedo6ab257c2016-02-10 11:03:29 -0700731# Check for errors during install. If we hit an error, stop, uninstall what we've put in so far, and quit.
Mark Youngf1bdefc2016-01-29 16:09:29 -0700732# NOTE: We return a non-zero error code as well.
David Pinedo6ab257c2016-02-10 11:03:29 -0700733Function CheckForError
Mark Youngf1bdefc2016-01-29 16:09:29 -0700734 ${If} ${Errors}
735 # IHV's using this install may want no message box.
David Pinedoa6d46a82016-02-12 12:23:57 -0700736 MessageBox MB_OK|MB_ICONSTOP "${errorMessage1}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK
Mark Youngf1bdefc2016-01-29 16:09:29 -0700737
David Pinedoef68bbe2016-03-29 13:46:12 -0600738 # Finish logging and move log file to TEMP dir
739 LogSet off
David Pinedo19fc3962016-06-07 09:35:56 -0600740 Rename "$INSTDIR\install.log" "$TEMP\VulkanRT\installer.log"
David Pinedoef68bbe2016-03-29 13:46:12 -0600741
Mark Youngf1bdefc2016-01-29 16:09:29 -0700742 # Copy the uninstaller to a temp folder of our own creation so we can completely
743 # delete the old contents.
David Pinedo19fc3962016-06-07 09:35:56 -0600744 SetOutPath "$TEMP\VulkanRT"
745 CopyFiles "$INSTDIR\Uninstall${PRODUCTNAME}.exe" "$TEMP\VulkanRT"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700746
David Pinedo8671af52016-06-03 12:08:12 -0600747 # Do uninstall using the version in the temporary folder.
David Pinedo19fc3962016-06-07 09:35:56 -0600748 ExecWait '"$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe" /S _?=$INSTDIR'
Mark Youngf1bdefc2016-01-29 16:09:29 -0700749
750 # Delete the copy of the uninstaller we ran
David Pinedo19fc3962016-06-07 09:35:56 -0600751 Delete /REBOOTOK "$TEMP\VulkanRT\Uninstall${PRODUCTNAME}.exe"
Mark Youngf1bdefc2016-01-29 16:09:29 -0700752
753 # Set an error message to output
David Pinedoa6d46a82016-02-12 12:23:57 -0700754 SetErrorLevel $1
Mark Youngf1bdefc2016-01-29 16:09:29 -0700755
756 Quit
757 ${EndIf}
758FunctionEnd
David Pinedo6ab257c2016-02-10 11:03:29 -0700759
760# Check for errors during uninstall. If we hit an error, don't attempt
David Pinedo19fc3962016-06-07 09:35:56 -0600761# to do anything. Just set a non-zero return code and continue.
David Pinedo6ab257c2016-02-10 11:03:29 -0700762Function un.CheckForError
763 ${If} ${Errors}
764 # IHV's using this install may want no message box.
David Pinedoe80978b2016-02-13 14:06:55 -0700765 MessageBox MB_OK|MB_ICONSTOP "${errorMessage1un}${errorMessage2}Errorcode: $1$\r$\n" /SD IDOK
David Pinedo6ab257c2016-02-10 11:03:29 -0700766
767 # Set an error message to output
David Pinedoa6d46a82016-02-12 12:23:57 -0700768 SetErrorLevel $1
David Pinedo6ab257c2016-02-10 11:03:29 -0700769
David Pinedo6ab257c2016-02-10 11:03:29 -0700770 ${EndIf}
771FunctionEnd