winrt: Update `VulkanRT-License.txt` text
[platform/upstream/Vulkan-Tools.git] / windows-runtime-installer / InstallerRT.nsi
1 # The Vulkan runtime installer NSIS script
2
3 !include LogicLib.nsh
4
5 # Input file locations
6 !define RES "."
7
8 # Input parameters
9 !ifndef MAJOR
10     !define MAJOR "1"
11     !define MINOR "1"
12     !define PATCH "73"
13     !define BUILD "0.dev"
14 !endif
15 !define VERSION "${MAJOR}.${MINOR}.${PATCH}.${BUILD}"
16 !ifndef PUBLISHER
17     !define PUBLISHER "YourCompany, Inc."
18 !endif
19 !ifndef COPYRIGHT
20     !define COPYRIGHT ""
21 !endif
22
23 # Installer information
24 Icon ${RES}\V.ico
25 OutFile "VulkanRT-${VERSION}-Installer.exe"
26 InstallDir "$PROGRAMFILES\VulkanRT"
27
28 RequestExecutionLevel admin
29 AddBrandingImage left 150
30 Caption "Vulkan Runtime ${VERSION} Setup"
31 Name "Vulkan Runtime ${VERSION}"
32 LicenseData "${RES}\VulkanRT-License.txt"
33 Page custom brandimage "" ": Brand Image"
34 Page license
35 Page instfiles
36
37 VIProductVersion "${VERSION}"
38 VIAddVersionKey  "ProductName" "Vulkan Runtime"
39 VIAddVersionKey  "FileVersion" "${VERSION}"
40 VIAddVersionKey  "ProductVersion" "${VERSION}"
41 VIAddVersionKey  "LegalCopyright" "${COPYRIGHT}"
42 VIAddVersionKey  "FileDescription" "Vulkan Runtime Installer"
43
44 Function brandimage
45   SetOutPath "$TEMP"
46   SetFileAttributes V.bmp temporary
47   File "${RES}\V.bmp"
48   SetBrandingImage "$TEMP/V.bmp"
49 Functionend
50
51 # Utilties to check if a file is older than this installer or not
52 Function NeedsReplacing
53     Pop $0
54
55     # Extract the version of the existing file
56     GetDllVersion "$0" $R0 $R1
57     IntOp $R2 $R0 >> 16
58     IntOp $R2 $R2 & 0xffff
59     IntOp $R3 $R0 & 0xffff
60     IntOp $R4 $R1 >> 16
61     IntOp $R4 $R4 & 0xffff
62     IntOp $R5 $R1 & 0xffff
63
64     # Check major versions
65     ${IF} ${MAJOR} > $R2
66         Push True
67     ${ELSEIF} ${MAJOR} < $R2
68         Push False
69
70     # Check minor versions
71     ${ELSEIF} ${MINOR} > $R3
72         Push True
73     ${ELSEIF} ${MINOR} < $R3
74         Push False
75
76     # Check patch versions
77     ${ELSEIF} ${PATCH} > $R4
78         Push True
79     ${ELSEIF} ${PATCH} < $R4
80         Push False
81
82     # Check build versions
83     ${ELSEIF} ${BUILD} > $R5
84         Push True
85     ${ELSEIF} ${BUILD} < $R5
86         Push False
87
88     # If they match exactly, then we update
89     ${ELSE}
90         Push True
91     ${ENDIF}
92 FunctionEnd
93
94 !macro InstallIfNewer SrcPath OutName
95     Push "$OUTDIR\${OutName}"
96     Call NeedsReplacing
97     Pop $0
98
99     ${IF} $0 == True
100         DetailPrint "File $OUTDIR\${OutName} (version $R2.$R3.$R4.$R5) will be upgraded to ${VERSION}"
101         File /oname=${OutName} "${SrcPath}"
102     ${ELSE}
103         DetailPrint "File $OUTDIR\${OutName} (version $R2.$R3.$R4.$R5) will not be replaced with ${VERSION}"
104     ${ENDIF}
105 !macroend
106
107 # Utilities to check if this is a 64-bit OS or not
108 !define IsWow64 `"" IsWow64 ""`
109 !macro _IsWow64 _a _b _t _f
110   !insertmacro _LOGICLIB_TEMP
111   System::Call kernel32::GetCurrentProcess()p.s
112   System::Call kernel32::IsWow64Process(ps,*i0s)
113   Pop $_LOGICLIB_TEMP
114   !insertmacro _!= $_LOGICLIB_TEMP 0 `${_t}` `${_f}`
115 !macroend
116
117 !define RunningX64 `"" RunningX64 ""`
118 !macro _RunningX64 _a _b _t _f
119   !if ${NSIS_PTR_SIZE} > 4
120     !insertmacro LogicLib_JumpToBranch `${_t}` `${_f}`
121   !else
122     !insertmacro _IsWow64 `${_a}` `${_b}` `${_t}` `${_f}`
123   !endif
124 !macroend
125
126 # Installer
127 Section
128     Delete "$INSTDIR\install.log"
129     Delete "$INSTDIR\VULKANRT_LICENSE.rtf"
130     LogSet on
131
132     # Disable filesystem redirection
133     System::Call kernel32::Wow64EnableWow64FsRedirection(i0)
134
135     ${IF} ${RunningX64}
136         SetOutPath $WINDIR\System32
137         !insertmacro InstallIfNewer "${LOADER64}" "vulkan-1.dll"
138         !insertmacro InstallIfNewer "${LOADER64}" "vulkan-1-999-0-0-0.dll"
139         !insertmacro InstallIfNewer "${VULKANINFO64}" "vulkaninfo.exe"
140         !insertmacro InstallIfNewer "${VULKANINFO64}" "vulkaninfo-1-999-0-0-0.exe"
141         SetOutPath $WINDIR\SysWOW64
142     ${ELSE}
143         SetOutPath $WINDIR\System32
144     ${ENDIF}
145
146     # Install 32-bit contents
147     !insertmacro InstallIfNewer "${LOADER32}" "vulkan-1.dll"
148     !insertmacro InstallIfNewer "${LOADER32}" "vulkan-1-999-0-0-0.dll"
149     !insertmacro InstallIfNewer "${VULKANINFO32}" "vulkaninfo.exe"
150     !insertmacro InstallIfNewer "${VULKANINFO32}" "vulkaninfo-1-999-0-0-0.exe"
151
152     # Dump licenses into a the installation directory
153     SetOutPath "$INSTDIR"
154     AccessControl::DisableFileInheritance $INSTDIR
155     AccessControl::SetFileOwner $INSTDIR "Administrators"
156     AccessControl::ClearOnFile  $INSTDIR "Administrators" "FullAccess"
157     AccessControl::SetOnFile    $INSTDIR "SYSTEM" "FullAccess"
158     AccessControl::GrantOnFile  $INSTDIR "Everyone" "ListDirectory"
159     AccessControl::GrantOnFile  $INSTDIR "Everyone" "GenericExecute"
160     AccessControl::GrantOnFile  $INSTDIR "Everyone" "GenericRead"
161     AccessControl::GrantOnFile  $INSTDIR "Everyone" "ReadAttributes"
162     File "${RES}\VulkanRT-License.txt"
163
164     LogSet off
165 SectionEnd