libsrt.nsi 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; SRT - Secure, Reliable, Transport
  4. ; Copyright (c) 2021, Thierry Lelegard
  5. ;
  6. ; This Source Code Form is subject to the terms of the Mozilla Public
  7. ; License, v. 2.0. If a copy of the MPL was not distributed with this
  8. ; file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. ;
  10. ;-----------------------------------------------------------------------------
  11. ;
  12. ; NSIS script to build the SRT binary installer for Windows.
  13. ; Do not invoke NSIS directly, use PowerShell script build-win-installer.ps1
  14. ; to ensure that all parameters are properly passed.
  15. ;
  16. ;-----------------------------------------------------------------------------
  17. Name "SRT"
  18. Caption "SRT Libraries Installer"
  19. !verbose push
  20. !verbose 0
  21. !include "MUI2.nsh"
  22. !include "Sections.nsh"
  23. !include "TextFunc.nsh"
  24. !include "FileFunc.nsh"
  25. !include "WinMessages.nsh"
  26. !include "x64.nsh"
  27. !verbose pop
  28. !define ProductName "libsrt"
  29. !define Build32Dir "${BuildRoot}\build.Win32"
  30. !define Build64Dir "${BuildRoot}\build.x64"
  31. !define SSL32Dir "C:\Program Files (x86)\OpenSSL-Win32"
  32. !define SSL64Dir "C:\Program Files\OpenSSL-Win64"
  33. ; Installer file information.
  34. VIProductVersion ${VersionInfo}
  35. VIAddVersionKey ProductName "${ProductName}"
  36. VIAddVersionKey ProductVersion "${Version}"
  37. VIAddVersionKey Comments "The SRT static libraries for Visual C++ on Windows"
  38. VIAddVersionKey CompanyName "Haivision"
  39. VIAddVersionKey LegalCopyright "Copyright (c) 2021 Haivision Systems Inc."
  40. VIAddVersionKey FileVersion "${VersionInfo}"
  41. VIAddVersionKey FileDescription "SRT Installer"
  42. ; Name of binary installer file.
  43. OutFile "${OutDir}\${ProductName}-${Version}.exe"
  44. ; Generate a Unicode installer (default is ANSI).
  45. Unicode true
  46. ; Registry key for environment variables
  47. !define EnvironmentKey '"SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
  48. ; Registry entry for product info and uninstallation info.
  49. !define ProductKey "Software\${ProductName}"
  50. !define UninstallKey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProductName}"
  51. ; Use XP manifest.
  52. XPStyle on
  53. ; Request administrator privileges for Windows Vista and higher.
  54. RequestExecutionLevel admin
  55. ; "Modern User Interface" (MUI) settings.
  56. !define MUI_ABORTWARNING
  57. ; Default installation folder.
  58. InstallDir "$PROGRAMFILES\${ProductName}"
  59. ; Get installation folder from registry if available from a previous installation.
  60. InstallDirRegKey HKLM "${ProductKey}" "InstallDir"
  61. ; Installer pages.
  62. !insertmacro MUI_PAGE_DIRECTORY
  63. !insertmacro MUI_PAGE_INSTFILES
  64. ; Uninstaller pages.
  65. !insertmacro MUI_UNPAGE_CONFIRM
  66. !insertmacro MUI_UNPAGE_INSTFILES
  67. ; Languages.
  68. !insertmacro MUI_LANGUAGE "English"
  69. ; Installation initialization.
  70. function .onInit
  71. ; In 64-bit installers, don't use registry redirection.
  72. ${If} ${RunningX64}
  73. SetRegView 64
  74. ${EndIf}
  75. functionEnd
  76. ; Uninstallation initialization.
  77. function un.onInit
  78. ; In 64-bit installers, don't use registry redirection.
  79. ${If} ${RunningX64}
  80. SetRegView 64
  81. ${EndIf}
  82. functionEnd
  83. ; Installation section
  84. Section "Install"
  85. ; Work on "all users" context, not current user.
  86. SetShellVarContext all
  87. ; Delete obsolete files from previous versions.
  88. Delete "$INSTDIR\LICENSE.pthread.txt"
  89. Delete "$INSTDIR\include\srt\srt4udt.h"
  90. Delete "$INSTDIR\include\srt\udt.h"
  91. Delete "$INSTDIR\lib\Release-x64\pthread.lib"
  92. Delete "$INSTDIR\lib\Release-Win32\pthread.lib"
  93. Delete "$INSTDIR\lib\Debug-x64\srt.pdb"
  94. Delete "$INSTDIR\lib\Debug-x64\pthread.pdb"
  95. Delete "$INSTDIR\lib\Debug-x64\pthread.lib"
  96. Delete "$INSTDIR\lib\Debug-Win32\srt.pdb"
  97. Delete "$INSTDIR\lib\Debug-Win32\pthread.pdb"
  98. Delete "$INSTDIR\lib\Debug-Win32\pthread.lib"
  99. SetOutPath "$INSTDIR"
  100. File /oname=LICENSE.txt "${RepoDir}\LICENSE"
  101. File "libsrt.props"
  102. ; Header files.
  103. CreateDirectory "$INSTDIR\include\srt"
  104. SetOutPath "$INSTDIR\include\srt"
  105. File "${RepoDir}\srtcore\access_control.h"
  106. File "${RepoDir}\srtcore\logging_api.h"
  107. File "${RepoDir}\srtcore\platform_sys.h"
  108. File "${RepoDir}\srtcore\srt.h"
  109. File "${RepoDir}\srtcore\udt.h"
  110. File "${Build64Dir}\version.h"
  111. CreateDirectory "$INSTDIR\include\win"
  112. SetOutPath "$INSTDIR\include\win"
  113. File "${RepoDir}\common\win\syslog_defs.h"
  114. ; Libraries.
  115. CreateDirectory "$INSTDIR\lib"
  116. CreateDirectory "$INSTDIR\lib\Release-x64"
  117. SetOutPath "$INSTDIR\lib\Release-x64"
  118. File /oname=srt.lib "${Build64Dir}\Release\srt_static.lib"
  119. File /oname=libcrypto.lib "${SSL64Dir}\lib\VC\static\libcrypto64MD.lib"
  120. File /oname=libssl.lib "${SSL64Dir}\lib\VC\static\libssl64MD.lib"
  121. CreateDirectory "$INSTDIR\lib\Debug-x64"
  122. SetOutPath "$INSTDIR\lib\Debug-x64"
  123. File /oname=srt.lib "${Build64Dir}\Debug\srt_static.lib"
  124. File /oname=libcrypto.lib "${SSL64Dir}\lib\VC\static\libcrypto64MDd.lib"
  125. File /oname=libssl.lib "${SSL64Dir}\lib\VC\static\libssl64MDd.lib"
  126. CreateDirectory "$INSTDIR\lib\Release-Win32"
  127. SetOutPath "$INSTDIR\lib\Release-Win32"
  128. File /oname=srt.lib "${Build32Dir}\Release\srt_static.lib"
  129. File /oname=libcrypto.lib "${SSL32Dir}\lib\VC\static\libcrypto32MD.lib"
  130. File /oname=libssl.lib "${SSL32Dir}\lib\VC\static\libssl32MD.lib"
  131. CreateDirectory "$INSTDIR\lib\Debug-Win32"
  132. SetOutPath "$INSTDIR\lib\Debug-Win32"
  133. File /oname=srt.lib "${Build32Dir}\Debug\srt_static.lib"
  134. File /oname=libcrypto.lib "${SSL32Dir}\lib\VC\static\libcrypto32MDd.lib"
  135. File /oname=libssl.lib "${SSL32Dir}\lib\VC\static\libssl32MDd.lib"
  136. ; Add an environment variable to installation root.
  137. WriteRegStr HKLM ${EnvironmentKey} "LIBSRT" "$INSTDIR"
  138. ; Store installation folder in registry.
  139. WriteRegStr HKLM "${ProductKey}" "InstallDir" $INSTDIR
  140. ; Create uninstaller
  141. WriteUninstaller "$INSTDIR\Uninstall.exe"
  142. ; Declare uninstaller in "Add/Remove Software" control panel
  143. WriteRegStr HKLM "${UninstallKey}" "DisplayName" "${ProductName}"
  144. WriteRegStr HKLM "${UninstallKey}" "Publisher" "Haivision"
  145. WriteRegStr HKLM "${UninstallKey}" "URLInfoAbout" "https://github.com/Haivision/srt"
  146. WriteRegStr HKLM "${UninstallKey}" "DisplayVersion" "${Version}"
  147. WriteRegStr HKLM "${UninstallKey}" "DisplayIcon" "$INSTDIR\Uninstall.exe"
  148. WriteRegStr HKLM "${UninstallKey}" "UninstallString" "$INSTDIR\Uninstall.exe"
  149. ; Get estimated size of installed files
  150. ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
  151. IntFmt $0 "0x%08X" $0
  152. WriteRegDWORD HKLM "${UninstallKey}" "EstimatedSize" "$0"
  153. ; Notify applications of environment modifications
  154. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  155. SectionEnd
  156. ; Uninstallation section
  157. Section "Uninstall"
  158. ; Work on "all users" context, not current user.
  159. SetShellVarContext all
  160. ; Get installation folder from registry
  161. ReadRegStr $0 HKLM "${ProductKey}" "InstallDir"
  162. ; Delete product registry entries
  163. DeleteRegKey HKCU "${ProductKey}"
  164. DeleteRegKey HKLM "${ProductKey}"
  165. DeleteRegKey HKLM "${UninstallKey}"
  166. DeleteRegValue HKLM ${EnvironmentKey} "LIBSRT"
  167. ; Delete product files.
  168. RMDir /r "$0\include"
  169. RMDir /r "$0\lib"
  170. Delete "$0\libsrt.props"
  171. Delete "$0\LICENSE*"
  172. Delete "$0\Uninstall.exe"
  173. RMDir "$0"
  174. ; Notify applications of environment modifications
  175. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  176. SectionEnd