|
21 | 21 | the defaut version is a detailed version number (most recent version, number |
22 | 22 | of commits since then, short commit SHA). |
23 | 23 |
|
| 24 | + .PARAMETER NoBuild |
| 25 | +
|
| 26 | + Do not rebuild the SRT libraries. Assume that they are already built. |
| 27 | + Only build the installer. |
| 28 | +
|
24 | 29 | .PARAMETER NoPause |
25 | 30 |
|
26 | 31 | Do not wait for the user to press <enter> at end of execution. By default, |
|
31 | 36 | [CmdletBinding()] |
32 | 37 | param( |
33 | 38 | [string]$Version = "", |
| 39 | + [switch]$NoBuild = $false, |
34 | 40 | [switch]$NoPause = $false |
35 | 41 | ) |
36 | 42 | Write-Output "Building the SRT static libraries installer for Windows" |
@@ -89,54 +95,33 @@ Write-Output "Windows version info: $VersionInfo" |
89 | 95 | #----------------------------------------------------------------------------- |
90 | 96 |
|
91 | 97 | # Locate OpenSSL root from local installation. |
92 | | -# After version 3.something, OpenSSL has changed its installation layout. |
93 | | -# We have to look for OpenSSL libraries in various locations. |
94 | | -$SSL = @{ |
95 | | - "x64" = @{ |
96 | | - "alt" = "Win64"; |
97 | | - "bits" = 64; |
98 | | - "root" = "C:\Program Files\OpenSSL-Win64" |
99 | | - }; |
100 | | - "Win32" = @{ |
101 | | - "alt" = "x86"; |
102 | | - "bits" = 32; |
103 | | - "root" = "C:\Program Files (x86)\OpenSSL-Win32" |
104 | | - } |
105 | | - "ARM64" = @{ |
106 | | - "alt" = "arm64"; |
107 | | - "bits" = 64; |
108 | | - "root" = "C:\Program Files\OpenSSL-Win64-ARM" |
109 | | - }; |
110 | | -} |
| 98 | +# We now requires the "universal" OpenSSL installer (see README.md). |
| 99 | +# The universal OpenSSL installer is installed in $SSL. |
| 100 | +# $ARCH translates between VC "platform" names to subdirectory names inside $SSL. |
| 101 | +# $LIBDIR translates between VC "configuration" names to library subdirectory names. |
| 102 | + |
| 103 | +$SSL = "C:\Program Files (x86)\OpenSSL-WinUniversal" |
| 104 | +$ARCH = @{x64 = "x64"; Win32 = "x86"; ARM64 = "arm64"} |
| 105 | +$LIBDIR = @{Release = "MD"; Debug = "MDd"} |
| 106 | +$LIBFILE = @{crypto = "libcrypto_static.lib"; ssl = "libssl_static.lib"} |
| 107 | + |
| 108 | +function ssl-include($pf) { return "$SSL\include\$($ARCH.$pf)" } |
| 109 | +function ssl-libdir($pf, $conf) { return "$SSL\lib\VC\$($ARCH.$pf)\$($LIBDIR.$conf)" } |
| 110 | +function ssl-lib($pf, $conf, $lib) { return "$(ssl-libdir $pf $conf)\$($LIBFILE.$lib)" } |
111 | 111 |
|
112 | 112 | # Verify OpenSSL directories and static libraries. |
113 | 113 | Write-Output "Searching OpenSSL libraries ..." |
114 | 114 | $Missing = 0 |
115 | | -foreach ($arch in $SSL.Keys) { |
116 | | - $root = $SSL[$arch]["root"] |
117 | | - $bits = $SSL[$arch]["bits"] |
118 | | - $alt = $SSL[$arch]["alt"] |
119 | | - if (-not (Test-Path $root)) { |
120 | | - Write-Output "**** Missing $root" |
| 115 | +foreach ($Platform in $SSL.Keys) { |
| 116 | + if (-not (Test-Path -PathType Container $(ssl-include $Platform))) { |
| 117 | + Write-Output "**** Missing $(ssl-include $Platform)" |
121 | 118 | $Missing = $Missing + 1 |
122 | 119 | } |
123 | | - else { |
124 | | - foreach ($lib in @("ssl", "crypto")) { |
125 | | - foreach ($conf in @("MD", "MDd")) { |
126 | | - $name = "lib${lib}${conf}" |
127 | | - $SSL[$arch][$name] = "" |
128 | | - foreach ($try in @("$root\lib\VC\static\lib${lib}${bits}${conf}.lib", |
129 | | - "$root\lib\VC\${arch}\${conf}\lib${lib}_static.lib", |
130 | | - "$root\lib\VC\${alt}\${conf}\lib${lib}_static.lib")) { |
131 | | - if (Test-Path $try) { |
132 | | - $SSL[$arch][$name] = $try |
133 | | - break |
134 | | - } |
135 | | - } |
136 | | - if (-not $SSL[$arch][$name]) { |
137 | | - Write-Output "**** OpenSSL static library for $name not found" |
138 | | - $Missing = $Missing + 1 |
139 | | - } |
| 120 | + foreach ($lib in $LIBFILE.Keys) { |
| 121 | + foreach ($conf in $LIBDIR.Keys) { |
| 122 | + if (-not (Test-Path $(ssl-lib $Platform $conf $lib))) { |
| 123 | + Write-Output "**** Missing $(ssl-lib $Platform $conf $lib)" |
| 124 | + $Missing = $Missing + 1 |
140 | 125 | } |
141 | 126 | } |
142 | 127 | } |
@@ -187,46 +172,40 @@ Write-Output "NSIS: $NSIS" |
187 | 172 | # Configure and build SRT library using CMake on all architectures. |
188 | 173 | #----------------------------------------------------------------------------- |
189 | 174 |
|
190 | | -foreach ($Platform in $SSL.Keys) { |
191 | | - |
192 | | - # Build directory. Cleanup to force a fresh cmake config. |
193 | | - $BuildDir = "$TmpDir\build.$Platform" |
194 | | - Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $BuildDir |
195 | | - [void](New-Item -Path $BuildDir -ItemType Directory -Force) |
196 | | - |
197 | | - # Run CMake. |
198 | | - # Note: In previous versions of CMake, it was necessary to specify where |
199 | | - # OpenSSL was located using OPENSSL_ROOT_DIR, OPENSSL_LIBRARIES, and |
200 | | - # OPENSSL_INCLUDE_DIR. Starting with CMake 3.29.0, this is no longer |
201 | | - # necessary because CMake knows where to find the OpenSSL binaries from |
202 | | - # slproweb. Additionally, for some unkown reason, defining the OPENSSL_xxx |
203 | | - # variables no longer works with Arm64 libraries, even though the path to |
204 | | - # that version is correct. So, it's better to let CMake find OpenSSL by itself. |
205 | | - Write-Output "Configuring build for platform $Platform ..." |
206 | | - $SRoot = $SSL[$Platform]["root"] |
207 | | - $LibSSL = $SSL[$Platform]["libsslMD"] |
208 | | - $LibCrypto = $SSL[$Platform]["libcryptoMD"] |
209 | | - & $CMake -S $RepoDir -B $BuildDir -A $Platform -DENABLE_STDCXX_SYNC=ON |
210 | | - |
211 | | - # Patch version string in version.h |
212 | | - Get-Content "$BuildDir\version.h" | |
213 | | - ForEach-Object { |
214 | | - $_ -replace "#define *SRT_VERSION_STRING .*","#define SRT_VERSION_STRING `"$Version`"" |
215 | | - } | |
216 | | - Out-File "$BuildDir\version.new" -Encoding ascii |
217 | | - Move-Item "$BuildDir\version.new" "$BuildDir\version.h" -Force |
218 | | - |
219 | | - # Compile SRT. |
220 | | - Write-Output "Building for platform $Platform ..." |
221 | | - foreach ($Conf in @("Release", "Debug")) { |
222 | | - & $MSBuild "$BuildDir\SRT.sln" /nologo /maxcpucount /property:Configuration=$Conf /property:Platform=$Platform /target:srt_static |
| 175 | +if (-not $NoBuild) { |
| 176 | + foreach ($Platform in $ARCH.Keys) { |
| 177 | + # Build directory. Cleanup to force a fresh cmake config. |
| 178 | + $BuildDir = "$TmpDir\build.$Platform" |
| 179 | + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $BuildDir |
| 180 | + [void](New-Item -Path $BuildDir -ItemType Directory -Force) |
| 181 | + |
| 182 | + # Run CMake. |
| 183 | + Write-Output "Configuring build for platform $Platform ..." |
| 184 | + & $CMake -S $RepoDir -B $BuildDir -A $Platform ` |
| 185 | + -DENABLE_STDCXX_SYNC=ON ` |
| 186 | + -DOPENSSL_INCLUDE_DIR="$(ssl-include $Platform)" ` |
| 187 | + -DOPENSSL_ROOT_DIR="$(ssl-libdir $Platform Release)" |
| 188 | + |
| 189 | + # Patch version string in version.h |
| 190 | + Get-Content "$BuildDir\version.h" | |
| 191 | + ForEach-Object { |
| 192 | + $_ -replace "#define *SRT_VERSION_STRING .*","#define SRT_VERSION_STRING `"$Version`"" |
| 193 | + } | |
| 194 | + Out-File "$BuildDir\version.new" -Encoding ascii |
| 195 | + Move-Item "$BuildDir\version.new" "$BuildDir\version.h" -Force |
| 196 | + |
| 197 | + # Compile SRT. |
| 198 | + Write-Output "Building for platform $Platform ..." |
| 199 | + foreach ($Conf in $LIBDIR.Keys) { |
| 200 | + & $MSBuild "$BuildDir\SRT.sln" /nologo /maxcpucount /property:Configuration=$Conf /property:Platform=$Platform /target:srt_static |
| 201 | + } |
223 | 202 | } |
224 | 203 | } |
225 | 204 |
|
226 | 205 | # Verify the presence of compiled libraries. |
227 | 206 | Write-Output "Checking compiled libraries ..." |
228 | 207 | $Missing = 0 |
229 | | -foreach ($Conf in @("Release", "Debug")) { |
| 208 | +foreach ($Conf in $LIBDIR.Keys) { |
230 | 209 | foreach ($Platform in $SSL.Keys) { |
231 | 210 | $Path = "$TmpDir\build.$Platform\$Conf\srt_static.lib" |
232 | 211 | if (-not (Test-Path $Path)) { |
@@ -254,18 +233,18 @@ Write-Output "Building installer ..." |
254 | 233 | /DOutDir="$OutDir" ` |
255 | 234 | /DBuildRoot="$TmpDir" ` |
256 | 235 | /DRepoDir="$RepoDir" ` |
257 | | - /DlibsslWin32MD="$($SSL.Win32.libsslMD)" ` |
258 | | - /DlibsslWin32MDd="$($SSL.Win32.libsslMDd)" ` |
259 | | - /DlibcryptoWin32MD="$($SSL.Win32.libcryptoMD)" ` |
260 | | - /DlibcryptoWin32MDd="$($SSL.Win32.libcryptoMDd)" ` |
261 | | - /DlibsslWin64MD="$($SSL.x64.libsslMD)" ` |
262 | | - /DlibsslWin64MDd="$($SSL.x64.libsslMDd)" ` |
263 | | - /DlibcryptoWin64MD="$($SSL.x64.libcryptoMD)" ` |
264 | | - /DlibcryptoWin64MDd="$($SSL.x64.libcryptoMDd)" ` |
265 | | - /DlibsslArm64MD="$($SSL.ARM64.libsslMD)" ` |
266 | | - /DlibsslArm64MDd="$($SSL.ARM64.libsslMDd)" ` |
267 | | - /DlibcryptoArm64MD="$($SSL.ARM64.libcryptoMD)" ` |
268 | | - /DlibcryptoArm64MDd="$($SSL.ARM64.libcryptoMDd)" ` |
| 236 | + /DlibsslWin32Release="$(ssl-lib Win32 Release ssl)" ` |
| 237 | + /DlibsslWin32Debug="$(ssl-lib Win32 Debug ssl)" ` |
| 238 | + /DlibcryptoWin32Release="$(ssl-lib Win32 Release crypto)" ` |
| 239 | + /DlibcryptoWin32Debug="$(ssl-lib Win32 Debug crypto)" ` |
| 240 | + /DlibsslWin64Release="$(ssl-lib x64 Release ssl)" ` |
| 241 | + /DlibsslWin64Debug="$(ssl-lib x64 Debug ssl)" ` |
| 242 | + /DlibcryptoWin64Release="$(ssl-lib x64 Release crypto)" ` |
| 243 | + /DlibcryptoWin64Debug="$(ssl-lib x64 Debug crypto)" ` |
| 244 | + /DlibsslArm64Release="$(ssl-lib Arm64 Release ssl)" ` |
| 245 | + /DlibsslArm64Debug="$(ssl-lib Arm64 Debug ssl)" ` |
| 246 | + /DlibcryptoArm64Release="$(ssl-lib Arm64 Release crypto)" ` |
| 247 | + /DlibcryptoArm64Debug="$(ssl-lib Arm64 Debug crypto)" ` |
269 | 248 | "$ScriptDir\libsrt.nsi" |
270 | 249 |
|
271 | 250 | if (-not (Test-Path $InstallExe)) { |
|
0 commit comments