diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index bc26d99b9..265c4874f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -297,6 +297,96 @@ jobs: name: binaries-${{ github.job }} path: pfx/**/* + windows: + needs: [ what-to-make ] + runs-on: windows-2022 + if: ${{ needs.what-to-make.outputs.make-cli == 'true' || needs.what-to-make.outputs.make-daemon == 'true' || needs.what-to-make.outputs.make-qt == 'true' || needs.what-to-make.outputs.make-tests == 'true' || needs.what-to-make.outputs.make-utils == 'true' }} + strategy: + fail-fast: false + matrix: + arch: [x64, x86] + steps: + - name: Show Configuration + run: | + echo '${{ toJSON(needs) }}' + echo '${{ toJSON(runner) }}' + - name: Get Build Tools + run: | + $DepsPrefix = (Join-Path (Get-Item .).Root.Name "${{ matrix.arch }}-prefix") + "DEPS_PREFIX=${DepsPrefix}" | Out-File $Env:GITHUB_ENV -Append + (Join-Path $DepsPrefix bin) | Out-File $Env:GITHUB_PATH -Append + + choco install ` + jom ` + nasm + choco uninstall ` + openssl.light + (Join-Path $Env:ProgramFiles NASM) | Out-File $Env:GITHUB_PATH -Append + + Install-Module -Name Pscx -RequiredVersion 4.0.0-beta4 -AllowPrerelease -Force + - name: Get Source + uses: actions/checkout@v3 + with: + path: src + submodules: recursive + - name: Get Cache Key + id: cache-key + run: | + try { + $DepsHash = & (Join-Path . src release windows main.ps1) -Mode DepsHash -BuildArch ${{ matrix.arch }} + "hash=${DepsHash}" | Out-File $Env:GITHUB_OUTPUT -Append + } catch { + Write-Error ("{1}{0}{2}{0}{3}" -f [Environment]::NewLine, $_.ToString(), $_.InvocationInfo.PositionMessage, $_.ScriptStackTrace) -ErrorAction Continue + exit 1 + } + - name: Get Cache + uses: actions/cache@v3 + id: cache + with: + path: ${{ env.DEPS_PREFIX }} + key: ${{ github.job }}-${{ matrix.arch }}-${{ steps.cache-key.outputs.hash }} + - name: Build Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + try { + & (Join-Path . src release windows main.ps1) -Mode Build -BuildArch ${{ matrix.arch }} -BuildPart Deps + } catch { + Write-Error ("{1}{0}{2}{0}{3}" -f [Environment]::NewLine, $_.ToString(), $_.InvocationInfo.PositionMessage, $_.ScriptStackTrace) -ErrorAction Continue + exit 1 + } + - name: Configure + run: | + Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture ${{ matrix.arch }} + cmake ` + -S src ` + -B obj ` + -G Ninja ` + -DCMAKE_BUILD_TYPE=RelWithDebInfo ` + -DCMAKE_INSTALL_PREFIX=pfx ` + -DCMAKE_PREFIX_PATH="${Env:DepsPrefix}" ` + -DENABLE_CLI=${{ (needs.what-to-make.outputs.make-cli == 'true') && 'ON' || 'OFF' }} ` + -DENABLE_DAEMON=${{ (needs.what-to-make.outputs.make-daemon == 'true') && 'ON' || 'OFF' }} ` + -DENABLE_GTK=OFF ` + -DENABLE_MAC=OFF ` + -DENABLE_QT=${{ (needs.what-to-make.outputs.make-qt == 'true') && 'ON' || 'OFF' }} ` + -DENABLE_TESTS=ON ` + -DENABLE_UTILS=${{ (needs.what-to-make.outputs.make-utils == 'true') && 'ON' || 'OFF' }} ` + -DENABLE_WEB=OFF ` + -DRUN_CLANG_TIDY=OFF + - name: Make + run: | + Import-VisualStudioVars -VisualStudioVersion 2022 -Architecture ${{ matrix.arch }} + cmake --build obj --config RelWithDebInfo + - name: Test + if: ${{ needs.what-to-make.outputs.make-tests == 'true' }} + run: cmake -E chdir obj ctest --build-config RelWithDebInfo --output-on-failure --timeout 600 + - name: Install + run: cmake --build obj --config RelWithDebInfo --target install + - uses: actions/upload-artifact@v3 + with: + name: binaries-${{ github.job }}-${{ matrix.arch }} + path: pfx/**/* + make-source-tarball: runs-on: ubuntu-22.04 needs: [ what-to-make ] diff --git a/CMakeLists.txt b/CMakeLists.txt index eb26ffa7d..d6cba54c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,11 @@ if(TARGET CURL::libcurl) set(CURL_INCLUDE_DIRS) endif() -find_package(ICONV) +if(NOT WIN32) + find_package(ICONV) +else() + set(ICONV_FOUND OFF) +endif() set(CRYPTO_PKG "") if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "ccrypto") diff --git a/release/windows/build-curl.ps1 b/release/windows/build-curl.ps1 index 11a0c1dd4..8be5f1799 100644 --- a/release/windows/build-curl.ps1 +++ b/release/windows/build-curl.ps1 @@ -18,20 +18,25 @@ function global:Build-Curl([string] $PrefixDir, [string] $Arch, [string] $DepsPr '-DCMAKE_BUILD_TYPE=RelWithDebInfo' "-DCMAKE_INSTALL_PREFIX=${PrefixDir}" "-DCMAKE_PREFIX_PATH=${DepsPrefixDir}" - '-DCURL_USE_OPENSSL=ON' - '-DCURL_WINDOWS_SSPI=OFF' '-DBUILD_CURL_EXE=OFF' '-DBUILD_TESTING=OFF' '-DCURL_DISABLE_DICT=ON' + '-DCURL_DISABLE_FTP=ON' '-DCURL_DISABLE_GOPHER=ON' '-DCURL_DISABLE_IMAP=ON' - '-DCURL_DISABLE_SMTP=ON' - '-DCURL_DISABLE_POP3=ON' - '-DCURL_DISABLE_RTSP=ON' - '-DCURL_DISABLE_TFTP=ON' - '-DCURL_DISABLE_TELNET=ON' '-DCURL_DISABLE_LDAP=ON' '-DCURL_DISABLE_LDAPS=ON' + '-DCURL_DISABLE_MQTT=ON' + '-DCURL_DISABLE_POP3=ON' + '-DCURL_DISABLE_RTSP=ON' + '-DCURL_DISABLE_SMB=ON' + '-DCURL_DISABLE_SMTP=ON' + '-DCURL_DISABLE_TELNET=ON' + '-DCURL_DISABLE_TFTP=ON' + '-DCURL_USE_LIBSSH=OFF' + '-DCURL_USE_LIBSSH2=OFF' + '-DCURL_USE_OPENSSL=ON' + '-DCURL_WINDOWS_SSPI=OFF' '-DENABLE_MANUAL=OFF' ) diff --git a/release/windows/main.ps1 b/release/windows/main.ps1 index c4440c194..d598caa4d 100644 --- a/release/windows/main.ps1 +++ b/release/windows/main.ps1 @@ -2,13 +2,17 @@ Param( [Parameter(Mandatory=$true)] - [ValidateSet('Build', 'Test')] + [ValidateSet('DepsHash', 'Build', 'Test')] [string] $Mode, [Parameter(Mandatory=$true)] [ValidateSet('x86', 'x64')] [string] $BuildArch, + [Parameter()] + [ValidateSet('All', 'Deps', 'App')] + [string] $BuildPart = 'All', + [Parameter()] [string] $SourceDir, @@ -153,10 +157,10 @@ function Import-Script([string] $Name) { Set-Variable -Name "$($Name -replace '\W+', '')ScriptFileHash" -Value (Get-StringHash (Get-Content -Path $ScriptFile)) -Scope Global } -function Invoke-Build([string] $Name, [switch] $NoCache = $false, [string[]] $MoreArguments = @()) { +function Invoke-Build([string] $Name, [switch] $NoCache = $false, [switch] $CacheArchiveNameOnly = $false, [string[]] $MoreArguments = @()) { Import-Script "Build-${Name}" - if (-not $NoCache) { + if (-not $NoCache -or $CacheArchiveNameOnly) { $BuildScriptFileHash = Get-Variable -Name "Build${Name}ScriptFileHash" -ValueOnly $BuildVersion = Get-Variable -Name "${Name}Version" -ValueOnly $BuildDeps = Get-Variable -Name "${Name}Deps" -ValueOnly @@ -179,6 +183,10 @@ function Invoke-Build([string] $Name, [switch] $NoCache = $false, [string[]] $Mo $CacheArchive = $null } + if ($CacheArchiveNameOnly) { + return $CacheArchiveName + } + while (-not $CacheArchive -or -not (Test-Path $CacheArchive)) { if ($CacheArchive -and $env:AWS_S3_BUCKET_NAME) { try { @@ -236,6 +244,21 @@ if (-not $SourceDir) { $SourceDir = (Get-Item $ScriptDir).Parent.Parent.FullName } +if ($Mode -eq 'DepsHash') { + Import-Script Toolchain + + $Names = @( + Invoke-Build Expat -CacheArchiveNameOnly + Invoke-Build DBus -CacheArchiveNameOnly + Invoke-Build Zlib -CacheArchiveNameOnly + Invoke-Build OpenSsl -CacheArchiveNameOnly + Invoke-Build Curl -CacheArchiveNameOnly + Invoke-Build Qt -CacheArchiveNameOnly + ) + + Write-Output (Get-StringHash ($Names -join ':')) +} + if ($Mode -eq 'Build') { Import-Script Toolchain @@ -243,14 +266,18 @@ if ($Mode -eq 'Build') { $env:CXXFLAGS = $CompilerFlags -join ' ' $env:LDFLAGS = $LinkerFlags -join ' ' - Invoke-Build Expat - Invoke-Build DBus - Invoke-Build Zlib - Invoke-Build OpenSsl - Invoke-Build Curl - Invoke-Build Qt + if (@('All', 'Deps') -contains $BuildPart) { + Invoke-Build Expat + Invoke-Build DBus + Invoke-Build Zlib + Invoke-Build OpenSsl + Invoke-Build Curl + Invoke-Build Qt + } - Invoke-Build Transmission -NoCache -MoreArguments @($SourceDir, $SourceDir, $PackDebugSyms.IsPresent) + if (@('All', 'App') -contains $BuildPart) { + Invoke-Build Transmission -NoCache -MoreArguments @($SourceDir, $SourceDir, $PackDebugSyms.IsPresent) + } } if ($Mode -eq 'Test') { diff --git a/release/windows/toolchain.ps1 b/release/windows/toolchain.ps1 index c49c68818..10c20383a 100644 --- a/release/windows/toolchain.ps1 +++ b/release/windows/toolchain.ps1 @@ -12,12 +12,15 @@ $global:LinkerFlags = @( '/PDBALTPATH:%_PDB%' ) -$global:VsInstallPrefix = "$env:VSINSTALLDIR" -if (-not (Test-Path $global:VsInstallPrefix)) { - $global:VsInstallPrefix = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio' 2022 Community -} -if (-not (Test-Path $global:VsInstallPrefix)) { - $global:VsInstallPrefix = Join-Path ${env:ProgramFiles} 'Microsoft Visual Studio' 2022 Community +foreach ($VsType in @('Enterprise', 'Professional', 'Community', 'BuildTools')) { + $global:VsInstallPrefix = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio' 2022 $VsType + if (Test-Path $global:VsInstallPrefix) { + break + } + $global:VsInstallPrefix = Join-Path ${env:ProgramFiles} 'Microsoft Visual Studio' 2022 $VsType + if (Test-Path $global:VsInstallPrefix) { + break + } } $global:VsVersion = ((& (Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio' Installer vswhere) -Property catalog_productSemanticVersion -Path $VsInstallPrefix) -Split '[+]')[0] $global:VcVarsScript = Join-Path $VsInstallPrefix VC Auxiliary Build vcvarsall.bat