From dcd750121118035244529f7ad781f79087377a3b Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Mon, 13 Feb 2023 01:12:09 +0300 Subject: [PATCH] Build additional packages for Qt 5 on Appveyor (#4855) Bring back old configuration that was using Qt 5 and split Qt build in two to support both Qt 5 and Qt 6. Last Qt 5 builds were using 5.14.2, bump that to latest 5.15.8. Qt 6 only supports Windows 10+, so adjust the system version check accordingly. Not bumping Qt 6 version (although 6.4.2 is available) while we're still in patch release mode. Building a whole new package is not nice since Qt client is only one part of it, the rest doesn't require newer OS version. Nevertheless, it's a quick and easy fix. --- appveyor.yml | 9 ++ dist/msi/CMakeLists.txt | 3 + dist/msi/Transmission.wxs | 16 ++- release/windows/build-qt5.ps1 | 98 +++++++++++++++++++ .../windows/{build-qt.ps1 => build-qt6.ps1} | 12 +-- release/windows/build-transmission.ps1 | 33 +++++-- release/windows/main.ps1 | 17 +++- 7 files changed, 166 insertions(+), 22 deletions(-) create mode 100644 release/windows/build-qt5.ps1 rename release/windows/{build-qt.ps1 => build-qt6.ps1} (87%) diff --git a/appveyor.yml b/appveyor.yml index 239055878..52cf2397c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,8 +11,16 @@ environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 TR_ARCH: x86 + QT_VERSION: '5' + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + TR_ARCH: x86 + QT_VERSION: '6' - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 TR_ARCH: x64 + QT_VERSION: '5' + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + TR_ARCH: x64 + QT_VERSION: '6' branches: only: @@ -80,6 +88,7 @@ for: -Mode Build ` -BuildArch $env:TR_ARCH ` -CCachePart App ` + -UseQtVersion $Env:QT_VERSION ` -PackDebugSyms:$($Env:APPVEYOR_REPO_BRANCH -eq "main" -or $Env:APPVEYOR_REPO_TAG -eq "true") } catch { Write-Error ("{1}{0}{2}{0}{3}" -f [Environment]::NewLine, $_.ToString(), $_.InvocationInfo.PositionMessage, $_.ScriptStackTrace) -ErrorAction Continue diff --git a/dist/msi/CMakeLists.txt b/dist/msi/CMakeLists.txt index b87d1ae75..88651d87b 100644 --- a/dist/msi/CMakeLists.txt +++ b/dist/msi/CMakeLists.txt @@ -29,6 +29,9 @@ set(MSI_FILENAME_VERSION "${TR_SEMVER}") if(NOT TR_STABLE_RELEASE AND NOT "${TR_VCS_REVISION}" STREQUAL "") string(APPEND MSI_FILENAME_VERSION "+r${TR_VCS_REVISION}") endif() +if(NOT Qt_VERSION_MAJOR EQUAL 6) + string(APPEND MSI_FILENAME_VERSION "-qt${Qt_VERSION_MAJOR}") +endif() if(NOT TR_THIRD_PARTY_DIR) set(TR_THIRD_PARTY_DIR "$/..") diff --git a/dist/msi/Transmission.wxs b/dist/msi/Transmission.wxs index b889e74a4..b198fa53b 100644 --- a/dist/msi/Transmission.wxs +++ b/dist/msi/Transmission.wxs @@ -17,8 +17,20 @@ - - Installed OR (VersionNT >= 600) + + + = 600)" ?> + + + + + + + + + + + diff --git a/release/windows/build-qt5.ps1 b/release/windows/build-qt5.ps1 new file mode 100644 index 000000000..18e22cc08 --- /dev/null +++ b/release/windows/build-qt5.ps1 @@ -0,0 +1,98 @@ +#!/usr/bin/env pwsh + +$global:Qt5Version = '5.15.8' + +$global:Qt5Deps = @( + 'DBus' + 'OpenSsl' + 'Zlib' +) + +function global:Build-Qt5([string] $PrefixDir, [string] $Arch, [string] $DepsPrefixDir) { + $Filename = "qt-everywhere-opensource-src-${Qt5Version}.zip" # tar.xz has some names truncated (e.g. .../double-conversion.h -> .../double-conv) + $Url = "http://qt.mirror.constant.com/archive/qt/$($Qt5Version -replace '\.\d+$', '')/${Qt5Version}/single/${Filename}" + + $ArchiveBase = "qt-everywhere-src-${Qt5Version}" + $UnpackFlags = @( + (Join-Path $ArchiveBase qtactiveqt '*') + (Join-Path $ArchiveBase qtbase '*') + (Join-Path $ArchiveBase qtsvg '*') + (Join-Path $ArchiveBase qttools '*') + (Join-Path $ArchiveBase qttranslations '*') + (Join-Path $ArchiveBase qtwinextras '*') + (Join-Path $ArchiveBase .gitmodules) + (Join-Path $ArchiveBase configure.bat) + (Join-Path $ArchiveBase configure.json) + (Join-Path $ArchiveBase qt.pro) + ) + + $SourceDir = Invoke-DownloadAndUnpack $Url $Filename $UnpackFlags $ArchiveBase + $BuildDir = Join-Path $SourceDir .build + + $ConfigOptions = @( + '-platform'; 'win32-msvc' + '-mp' + # '-ltcg' # error C1002 on VS 2019 16.5.4 + '-opensource' + '-confirm-license' + '-prefix'; $PrefixDir + '-release' + '-force-debug-info' + '-dbus' + '-ssl' + '-openssl' + '-system-zlib' + '-qt-pcre' + '-qt-libpng' + '-qt-libjpeg' + '-no-opengl' + '-no-direct2d' + '-no-freetype' + '-no-harfbuzz' + '-no-sql-db2' + '-no-sql-ibase' + '-no-sql-mysql' + '-no-sql-oci' + '-no-sql-odbc' + '-no-sql-psql' + '-no-sql-sqlite' + '-no-sql-sqlite2' + '-no-sql-tds' + '-nomake'; 'examples' + '-nomake'; 'tests' + '-nomake'; 'tools' + '-I'; (Join-Path $DepsPrefixDir include) + '-L'; (Join-Path $DepsPrefixDir lib) + ) + + if ($env:LDFLAGS) { + # Patch to add our linker flags, mainly /PDBALTPATH + Edit-TextFile (Join-Path $SourceDir qtbase mkspecs win32-msvc qmake.conf) '(^QMAKE_CXXFLAGS\b.*)' "`$1`nQMAKE_LFLAGS += ${env:LDFLAGS}" + } + + # No need in GUI tools + Edit-TextFile (Join-Path $SourceDir qttools src src.pro) 'qtHaveModule[(]gui[)]' 'qtHaveModule(hughey)' + Edit-TextFile (Join-Path $SourceDir qttools src src.pro) 'qtHaveModule[(]widgets[)]' 'qtHaveModule(digits)' + Edit-TextFile (Join-Path $SourceDir qttools src linguist linguist.pro) 'qtHaveModule[(]widgets[)]' 'qtHaveModule(digits)' + + Invoke-NativeCommand cmake -E remove_directory $BuildDir + $env:PATH = @( + (Join-Path $PrefixDir bin) + (Join-Path $DepsPrefixDir bin) + (Join-Path $BuildDir qtbase lib) + $env:PATH + ) -join [System.IO.Path]::PathSeparator + + New-Item -Path $BuildDir -ItemType Directory -ErrorAction Ignore | Out-Null + Push-Location -Path $BuildDir + Invoke-VcEnvCommand (Join-Path $SourceDir configure) @ConfigOptions + Invoke-VcEnvCommand jom + Invoke-VcEnvCommand jom install + Pop-Location + + # install target doesn't copy PDBs for release DLLs + Get-Childitem -Path (Join-Path $BuildDir qtbase lib) | ` + ForEach-Object { if ($_ -is [System.IO.DirectoryInfo] -or $_.Name -like '*.pdb') { Copy-Item -Path $_.FullName -Destination (Join-Path $PrefixDir lib) -Filter '*.pdb' -Recurse -Force } } + Get-Childitem -Path (Join-Path $BuildDir qtbase plugins) | ` + ForEach-Object { if ($_ -is [System.IO.DirectoryInfo] -or $_.Name -like '*.pdb') { Copy-Item -Path $_.FullName -Destination (Join-Path $PrefixDir plugins) -Filter '*.pdb' -Recurse -Force } } +} diff --git a/release/windows/build-qt.ps1 b/release/windows/build-qt6.ps1 similarity index 87% rename from release/windows/build-qt.ps1 rename to release/windows/build-qt6.ps1 index 5db5de443..671f44cee 100644 --- a/release/windows/build-qt.ps1 +++ b/release/windows/build-qt6.ps1 @@ -1,18 +1,18 @@ #!/usr/bin/env pwsh -$global:QtVersion = '6.4.0' +$global:Qt6Version = '6.4.0' -$global:QtDeps = @( +$global:Qt6Deps = @( 'DBus' 'OpenSsl' 'Zlib' ) -function global:Build-Qt([string] $PrefixDir, [string] $Arch, [string] $DepsPrefixDir) { - $Filename = "qt-everywhere-src-${QtVersion}.zip" # tar.xz has some names truncated (e.g. .../double-conversion.h -> .../double-conv) - $Url = "http://qt.mirror.constant.com/archive/qt/$($QtVersion -replace '\.\d+$', '')/${QtVersion}/single/${Filename}" +function global:Build-Qt6([string] $PrefixDir, [string] $Arch, [string] $DepsPrefixDir) { + $Filename = "qt-everywhere-src-${Qt6Version}.zip" # tar.xz has some names truncated (e.g. .../double-conversion.h -> .../double-conv) + $Url = "http://qt.mirror.constant.com/archive/qt/$($Qt6Version -replace '\.\d+$', '')/${Qt6Version}/single/${Filename}" - $ArchiveBase = "qt-everywhere-src-${QtVersion}" + $ArchiveBase = "qt-everywhere-src-${Qt6Version}" $UnpackFlags = @( (Join-Path $ArchiveBase qtactiveqt '*') (Join-Path $ArchiveBase qtbase '*') diff --git a/release/windows/build-transmission.ps1 b/release/windows/build-transmission.ps1 index c94874aaf..74ad49ed2 100644 --- a/release/windows/build-transmission.ps1 +++ b/release/windows/build-transmission.ps1 @@ -1,6 +1,14 @@ #!/usr/bin/env pwsh -function global:Build-Transmission([string] $PrefixDir, [string] $Arch, [string] $DepsPrefixDir, [string] $SourceDir, [string] $ArtifactsDir, [boolean] $PackDebugSyms) { +function global:Build-Transmission( + [string] $PrefixDir, + [string] $Arch, + [string] $DepsPrefixDir, + [string] $SourceDir, + [string] $ArtifactsDir, + [string] $UseQtVersion, + [boolean] $PackDebugSyms +) { $BuildDir = Join-Path $SourceDir .build $env:PATH = @( @@ -37,11 +45,16 @@ function global:Build-Transmission([string] $PrefixDir, [string] $Arch, [string] Copy-Item -Path (Join-Path $DepsPrefixDir bin "${x}.pdb") -Destination $DebugSymbolsDir } - foreach ($x in @('Core', 'DBus', 'Gui', 'Network', 'Svg', 'Widgets')) { + $QtModules = @('Core', 'DBus', 'Gui', 'Network', 'Svg', 'Widgets') + if ($UseQtVersion -eq '5') { + $QtModules += @('WinExtras') + } + + foreach ($x in $QtModules) { if ($DepsPrefixDir -ne $PrefixDir) { - Copy-Item -Path (Join-Path $DepsPrefixDir bin "Qt6${x}.dll") -Destination (Join-Path $PrefixDir bin) + Copy-Item -Path (Join-Path $DepsPrefixDir bin "Qt${UseQtVersion}${x}.dll") -Destination (Join-Path $PrefixDir bin) } - Copy-Item -Path (Join-Path $DepsPrefixDir bin "Qt6${x}.pdb") -Destination $DebugSymbolsDir + Copy-Item -Path (Join-Path $DepsPrefixDir bin "Qt${UseQtVersion}${x}.pdb") -Destination $DebugSymbolsDir } foreach ($x in @('gif', 'ico', 'jpeg', 'svg')) { @@ -52,12 +65,14 @@ function global:Build-Transmission([string] $PrefixDir, [string] $Arch, [string] Copy-Item -Path (Join-Path $DepsPrefixDir plugins imageformats "q${x}.pdb") -Destination $DebugSymbolsDir } - foreach ($x in @('openssl')) { - if ($DepsPrefixDir -ne $PrefixDir) { - New-Item -Path (Join-Path $PrefixDir plugins tls) -ItemType Directory -ErrorAction Ignore | Out-Null - Copy-Item -Path (Join-Path $DepsPrefixDir plugins tls "q${x}backend.dll") -Destination (Join-Path $PrefixDir plugins tls) + if ($UseQtVersion -eq '6') { + foreach ($x in @('openssl')) { + if ($DepsPrefixDir -ne $PrefixDir) { + New-Item -Path (Join-Path $PrefixDir plugins tls) -ItemType Directory -ErrorAction Ignore | Out-Null + Copy-Item -Path (Join-Path $DepsPrefixDir plugins tls "q${x}backend.dll") -Destination (Join-Path $PrefixDir plugins tls) + } + Copy-Item -Path (Join-Path $DepsPrefixDir plugins tls "q${x}backend.pdb") -Destination $DebugSymbolsDir } - Copy-Item -Path (Join-Path $DepsPrefixDir plugins tls "q${x}backend.pdb") -Destination $DebugSymbolsDir } if ($DepsPrefixDir -ne $PrefixDir) { diff --git a/release/windows/main.ps1 b/release/windows/main.ps1 index 44aa8dd0f..8efb130f1 100644 --- a/release/windows/main.ps1 +++ b/release/windows/main.ps1 @@ -17,6 +17,10 @@ Param( [ValidateSet('None', 'All', 'Deps', 'App')] [string] $CCachePart = 'None', + [Parameter()] + [ValidateSet('5', '6')] + [string] $UseQtVersion = '6', + [Parameter()] [string] $SourceDir, @@ -71,7 +75,7 @@ function Invoke-Download([string] $Url, [string] $OutFile) { } } -function Invoke-DownloadAndUnpack([string] $Url, [string] $Filename, [string[]] $MoreFlags = @()) { +function Invoke-DownloadAndUnpack([string] $Url, [string] $Filename, [string[]] $MoreFlags = @(), [string] $ArchiveBase = '') { New-Item -Path $CacheDir -ItemType Directory -ErrorAction Ignore | Out-Null $ArchivePath = Join-Path $CacheDir $Filename Invoke-Download $Url $ArchivePath @@ -86,7 +90,10 @@ function Invoke-DownloadAndUnpack([string] $Url, [string] $Filename, [string[]] } if ($ArchivePath -match '^(.+)(\.(tar|zip))$') { - $FinalArchivePath = Join-Path $TempDir (Split-Path -Path $Matches[1] -Leaf) + if ($ArchiveBase -eq '') { + $ArchiveBase = Split-Path -Path $Matches[1] -Leaf + } + $FinalArchivePath = Join-Path $TempDir $ArchiveBase New-Item -Path $TempDir -ItemType Directory -ErrorAction Ignore | Out-Null Push-Location -Path $TempDir @@ -257,7 +264,7 @@ if ($Mode -eq 'DepsHash') { Invoke-Build Zlib -CacheArchiveNameOnly Invoke-Build OpenSsl -CacheArchiveNameOnly Invoke-Build Curl -CacheArchiveNameOnly - Invoke-Build Qt -CacheArchiveNameOnly + Invoke-Build Qt$UseQtVersion -CacheArchiveNameOnly ) Write-Output (Get-StringHash ($Names -join ':')) @@ -284,7 +291,7 @@ if ($Mode -eq 'Build') { Invoke-Build Zlib Invoke-Build OpenSsl Invoke-Build Curl - Invoke-Build Qt + Invoke-Build Qt$UseQtVersion } if (@('All', 'App') -contains $CCachePart) { @@ -296,7 +303,7 @@ if ($Mode -eq 'Build') { } if (@('All', 'App') -contains $BuildPart) { - Invoke-Build Transmission -NoCache -MoreArguments @($SourceDir, $SourceDir, $PackDebugSyms.IsPresent) + Invoke-Build Transmission -NoCache -MoreArguments @($SourceDir, $SourceDir, $UseQtVersion, $PackDebugSyms.IsPresent) } }