param([ValidateSet('Debug','Release')][string]$Configuration='Debug') $ErrorActionPreference='Stop' $root=$PSScriptRoot $packages=@( @('openssl','openssl-3.5.9','https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz','603F5602E2EEF00D77FBD429D34DCD5822BB301757A1BC9CDB24C670F1EB859A'), @('curl','curl-8.23.0','https://curl.se/download/curl-8.23.0.tar.gz','E3DE77CFA6367083C776A26647FC9F633B538C06C3BAA73D931A252AC8F72B49'), @('libtorrent','libtorrent-rasterbar-2.0.11','https://github.com/arvidn/libtorrent/releases/download/v2.0.11/libtorrent-rasterbar-2.0.11.tar.gz','F0DB58580F4F29ADE6CC40FA4BA80E2C9A70C90265CD77332D3CDEC37ECF1E6D'), @('boost','boost_1_86_0','https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.gz','2575E74FFC3EF1CD0BABAC2C1EE8BDB5782A0EE672B1912DA40E5B4B591CA01F') ) $curlName=if($Configuration -eq 'Debug'){'libcurl-d.lib'}else{'libcurl.lib'} $library=Join-Path $root ('build/lib/'+$Configuration+'/torrent-rasterbar.lib') $curlLibrary=Join-Path $root ('build/lib/'+$Configuration+'/'+$curlName) if((Test-Path -LiteralPath $library) -and (Test-Path -LiteralPath $curlLibrary) -and (Test-Path (Join-Path $root ('openssl/'+$Configuration+'/lib/libssl.lib'))) -and (Test-Path (Join-Path $root ('openssl/'+$Configuration+'/lib/libcrypto.lib'))) -and (Test-Path (Join-Path $root ('openssl/'+$Configuration+'/include/openssl/configuration.h')))) { if((Get-Item -LiteralPath $library).LastWriteTime -gt (Get-Item (Join-Path $root 'CMakeLists.txt')).LastWriteTime -and (Get-Item -LiteralPath $curlLibrary).LastWriteTime -gt (Get-Item (Join-Path $root 'CMakeLists.txt')).LastWriteTime) { exit 0 } } New-Item -ItemType Directory -Force (Join-Path $root 'sources') | Out-Null foreach($package in $packages) { $archive=Join-Path $root ('sources/'+$package[0]+'.tar.gz') if(!(Test-Path -LiteralPath $archive)) { Invoke-WebRequest -Uri $package[2] -OutFile $archive -UseBasicParsing } $hashAlgorithm=[System.Security.Cryptography.SHA256]::Create() $archiveStream=[System.IO.File]::OpenRead($archive) try { $sourceHash=[BitConverter]::ToString($hashAlgorithm.ComputeHash($archiveStream)).Replace('-','') } finally { $archiveStream.Dispose(); $hashAlgorithm.Dispose() } if($sourceHash -ne $package[3]) { throw "Source checksum mismatch: $archive" } if(!(Test-Path -LiteralPath (Join-Path $root $package[1]))) { if($package[0] -eq 'boost') { & tar -xzf $archive -C $root boost_1_86_0/boost boost_1_86_0/LICENSE_1_0.txt } else { & tar -xzf $archive -C $root } if($LASTEXITCODE) { throw 'Source extraction failed' } } } & (Join-Path $root 'build-openssl.ps1') -Configuration Release if($Configuration -eq 'Debug') { & (Join-Path $root 'build-openssl.ps1') -Configuration Debug } & cmake -S $root -B (Join-Path $root 'build') -A x64 if($LASTEXITCODE) { throw 'Dependency configure failed' } & cmake --build (Join-Path $root 'build') --config $Configuration --target torrent-rasterbar libcurl_static --parallel 4 if($LASTEXITCODE) { throw 'Dependency build failed' }