| 1 |
$os = $args[0] |
| 2 |
$use_webengine = $args[1] |
| 3 |
$use_qt5 = $args[2] |
| 4 |
|
| 5 |
echo "We are building for MS Windows." |
| 6 |
echo "OS: $os; Not lite: $use_webengine; Qt5: $use_qt5" |
| 7 |
|
| 8 |
$git_revlist = git rev-list --tags --max-count=1 |
| 9 |
$git_tag = git describe --tags $git_revlist |
| 10 |
$git_revision = git rev-parse --short HEAD |
| 11 |
$old_pwd = $pwd.Path |
| 12 |
|
| 13 |
# Functions. |
| 14 |
function Fetch-Latest-Release([string]$OrgRepo, [string]$NameRegex) { |
| 15 |
$releases_url = "https://api.github.com/repos/" + $OrgRepo +"/releases" |
| 16 |
$releases_req = Invoke-WebRequest -Uri "$releases_url" -Headers @{ "Authorization" = "Bearer $env:GITHUB_TOKEN" } |
| 17 |
$releases_json = $releases_req.Content | ConvertFrom-Json |
| 18 |
$releases_release = $releases_json[0] |
| 19 |
$asset = $releases_release.assets | Where-Object {$_.name -match $NameRegex} | Select-Object |
| 20 |
|
| 21 |
Add-Member -InputObject $asset -NotePropertyName "tag_name" -NotePropertyValue $releases_release.tag_name.Substring(1) |
| 22 |
|
| 23 |
Write-Host $asset |
| 24 |
|
| 25 |
return $asset |
| 26 |
} |
| 27 |
|
| 28 |
# Prepare environment. |
| 29 |
Install-Module Pscx -Scope CurrentUser -AllowClobber -Force |
| 30 |
Install-Module VSSetup -Scope CurrentUser -AllowClobber -Force |
| 31 |
Import-VisualStudioVars -Architecture x64 |
| 32 |
|
| 33 |
$AllProtocols = [System.Net.SecurityProtocolType]'Tls11,Tls12' |
| 34 |
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols |
| 35 |
$ProgressPreference = 'SilentlyContinue' |
| 36 |
|
| 37 |
# Get and prepare needed dependencies. |
| 38 |
if ($use_qt5 -eq "ON") { |
| 39 |
$qt_version = "5.15.2" |
| 40 |
$qt_arch_base = "msvc2019_64" |
| 41 |
|
| 42 |
$use_libmpv = "OFF" |
| 43 |
$use_qtmultimedia = "ON" |
| 44 |
} |
| 45 |
else { |
| 46 |
$qt_version = "6.8.3" |
| 47 |
$qt_arch_base = "msvc2022_64" |
| 48 |
|
| 49 |
if ($use_webengine -eq "ON") { |
| 50 |
$use_libmpv = "ON" |
| 51 |
$use_qtmultimedia = "OFF" |
| 52 |
} |
| 53 |
else { |
| 54 |
$use_libmpv = "OFF" |
| 55 |
$use_qtmultimedia = "ON" |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
$is_qt_6 = $qt_version.StartsWith("6") |
| 60 |
$qt_arch = "win64_" + $qt_arch_base |
| 61 |
|
| 62 |
$maria_version = "11.4.5" |
| 63 |
$maria_link = "https://archive.mariadb.org/mariadb-$maria_version/winx64-packages/mariadb-$maria_version-winx64.zip" |
| 64 |
$maria_output = "maria.zip" |
| 65 |
|
| 66 |
$cmake_asset = Fetch-Latest-Release -OrgRepo "Kitware/CMake" -NameRegex "cmake-.+-windows-x86_64\.zip" |
| 67 |
$cmake_version = $cmake_asset.tag_name |
| 68 |
$cmake_link = $cmake_asset.browser_download_url |
| 69 |
$cmake_output = "cmake.zip" |
| 70 |
|
| 71 |
$zlib_asset = Fetch-Latest-Release -OrgRepo "madler/zlib" -NameRegex "zlib.+\.zip$" |
| 72 |
$zlib_version = $zlib_asset.tag_name |
| 73 |
$zlib_link = $zlib_asset.browser_download_url |
| 74 |
$zlib_output = "zlib.zip" |
| 75 |
|
| 76 |
$libmpv_link = Fetch-Latest-Release -OrgRepo "zhongfly/mpv-winbuild" -NameRegex "mpv-dev-x86_64-2.+7z" | Select-Object -ExpandProperty browser_download_url |
| 77 |
$libmpv_output = "mpv.zip" |
| 78 |
|
| 79 |
$ytdlp_link = Fetch-Latest-Release -OrgRepo "yt-dlp/yt-dlp" -NameRegex "yt-dlp.exe" | Select-Object -ExpandProperty browser_download_url |
| 80 |
$ytdlp_output = "yt-dlp.exe" |
| 81 |
|
| 82 |
Invoke-WebRequest -Uri "$maria_link" -OutFile "$maria_output" |
| 83 |
& ".\resources\scripts\7za\7za.exe" x "$maria_output" |
| 84 |
|
| 85 |
Invoke-WebRequest -Uri "$cmake_link" -OutFile "$cmake_output" |
| 86 |
& ".\resources\scripts\7za\7za.exe" x "$cmake_output" |
| 87 |
|
| 88 |
Invoke-WebRequest -Uri "$zlib_link" -OutFile "$zlib_output" |
| 89 |
& ".\resources\scripts\7za\7za.exe" x "$zlib_output" |
| 90 |
|
| 91 |
Invoke-WebRequest -Uri "$libmpv_link" -OutFile "$libmpv_output" |
| 92 |
& ".\resources\scripts\7za\7za.exe" x "$libmpv_output" -ompv |
| 93 |
|
| 94 |
Invoke-WebRequest -Uri "$ytdlp_link" -OutFile "$ytdlp_output" |
| 95 |
|
| 96 |
$cmake_path = "$old_pwd\cmake-$cmake_version-windows-x86_64\bin\cmake.exe" |
| 97 |
$zlib_path = "$old_pwd\zlib-$zlib_version" |
| 98 |
$libmpv_path = "$old_pwd\mpv" |
| 99 |
$ytdlp_path = "$old_pwd\$ytdlp_output" |
| 100 |
|
| 101 |
# Download Qt itself. |
| 102 |
$qt_path = "$old_pwd\qt" |
| 103 |
|
| 104 |
# Install "aqtinstall" from its master branch to have latest code. |
| 105 |
pip3 install -U pip |
| 106 |
pip3 install -I git+https://github.com/miurahr/aqtinstall |
| 107 |
|
| 108 |
if ($is_qt_6) { |
| 109 |
aqt install-qt -O "$qt_path" windows desktop $qt_version $qt_arch -m qtwebengine qtimageformats qtmultimedia qt5compat qtwebchannel qtpositioning |
| 110 |
} |
| 111 |
else { |
| 112 |
aqt install-qt -O "$qt_path" windows desktop $qt_version $qt_arch -m qtwebengine |
| 113 |
} |
| 114 |
|
| 115 |
aqt install-src -O "$qt_path" windows desktop $qt_version --archives qtbase |
| 116 |
|
| 117 |
$qt_qmake = "$qt_path\$qt_version\$qt_arch_base\bin\qmake.exe" |
| 118 |
$env:PATH = "$qt_path\$qt_version\$qt_arch_base\bin\;" + $env:PATH |
| 119 |
|
| 120 |
if ($is_qt_6) { |
| 121 |
# Download openssl 3.x. |
| 122 |
aqt install-tool -O "$qt_path" windows desktop tools_opensslv3_x64 qt.tools.opensslv3.win_x64 |
| 123 |
$openssl_base_path = "$qt_path\Tools\OpenSSLv3\Win_x64" |
| 124 |
} |
| 125 |
else { |
| 126 |
# Download openssl 1.x from external source. |
| 127 |
$openssl_link = "https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-1.1.1w.zip"; |
| 128 |
$openssl_output = "openssl.zip" |
| 129 |
Invoke-WebRequest -Uri "$openssl_link" -OutFile "$openssl_output" |
| 130 |
& ".\resources\scripts\7za\7za.exe" x $openssl_output |
| 131 |
$openssl_base_path = "$pwd\openssl-1.1\x64" |
| 132 |
} |
| 133 |
|
| 134 |
# Build dependencies. |
| 135 |
|
| 136 |
# MariaDB. |
| 137 |
$maria_path = "$old_pwd\mariadb-$maria_version-winx64" |
| 138 |
$qt_sqldrivers_path = "$qt_path\$qt_version\Src\qtbase\src\plugins\sqldrivers" |
| 139 |
|
| 140 |
cd "$qt_sqldrivers_path" |
| 141 |
|
| 142 |
if ($is_qt_6) { |
| 143 |
& $cmake_path -G Ninja -DCMAKE_BUILD_TYPE="Release" -DMySQL_INCLUDE_DIR="$maria_path\include\mysql" -DMySQL_LIBRARY="$maria_path\lib\libmariadb.lib" |
| 144 |
& $cmake_path --build . |
| 145 |
|
| 146 |
$with_qt6 = "ON" |
| 147 |
} |
| 148 |
else { |
| 149 |
& $qt_qmake -- MYSQL_INCDIR="$maria_path\include\mysql" MYSQL_LIBDIR="$maria_path\lib" |
| 150 |
nmake.exe sub-mysql |
| 151 |
|
| 152 |
$with_qt6 = "OFF" |
| 153 |
} |
| 154 |
|
| 155 |
# zlib |
| 156 |
cd "$zlib_path" |
| 157 |
nmake.exe -f "win32\Makefile.msc" |
| 158 |
|
| 159 |
cd "$old_pwd" |
| 160 |
|
| 161 |
# Build application. |
| 162 |
mkdir "rssguard-build" |
| 163 |
cd "rssguard-build" |
| 164 |
|
| 165 |
& "$cmake_path" ".." -G Ninja -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_VERBOSE_MAKEFILE="ON" -DBUILD_WITH_QT6="$with_qt6" -DREVISION_FROM_GIT="ON" -DUSE_SYSTEM_SQLITE="OFF" -DZLIB_ROOT="$zlib_path" -DENABLE_COMPRESSED_SITEMAP="ON" -DENABLE_MEDIAPLAYER_LIBMPV="$use_libmpv" -DENABLE_MEDIAPLAYER_QTMULTIMEDIA="$use_qtmultimedia" -DLibMPV_ROOT="$libmpv_path" -DNO_LITE="$use_webengine" -DFEEDLY_CLIENT_ID="$env:FEEDLY_CLIENT_ID" -DFEEDLY_CLIENT_SECRET="$env:FEEDLY_CLIENT_SECRET" |
| 166 |
& "$cmake_path" --build . |
| 167 |
& "$cmake_path" --install . --prefix app |
| 168 |
|
| 169 |
cd "app" |
| 170 |
windeployqt.exe --verbose 1 --no-compiler-runtime --no-translations --release rssguard.exe rssguard.dll |
| 171 |
cd ".." |
| 172 |
|
| 173 |
# Copy OpenSSL. |
| 174 |
if ($is_qt_6) { |
| 175 |
Copy-Item -Path "$qt_path\$qt_version\$qt_arch_base\plugins\tls\qopensslbackend.dll" -Destination ".\app\tls\" |
| 176 |
} |
| 177 |
|
| 178 |
Copy-Item -Path "$openssl_base_path\bin\libcrypto*.dll" -Destination ".\app\" |
| 179 |
Copy-Item -Path "$openssl_base_path\bin\libssl*.dll" -Destination ".\app\" |
| 180 |
|
| 181 |
# Copy MySQL. |
| 182 |
Copy-Item -Path "$maria_path\lib\libmariadb.dll" -Destination ".\app\" |
| 183 |
Copy-Item -Path "$qt_sqldrivers_path\plugins\sqldrivers\qsqlmysql.dll" -Destination ".\app\sqldrivers\" -Force |
| 184 |
|
| 185 |
# Copy zlib. |
| 186 |
Copy-Item -Path "$zlib_path\zlib1.dll" -Destination ".\app\" |
| 187 |
|
| 188 |
# Copy debug symbols. |
| 189 |
Copy-Item -Path ".\src\librssguard\rssguard.pdb" -Destination ".\app\" |
| 190 |
|
| 191 |
if ($use_libmpv -eq "ON") { |
| 192 |
# Copy libmpv and yt-dlp. |
| 193 |
Copy-Item -Path "$libmpv_path\libmpv*.dll" -Destination ".\app\" |
| 194 |
Copy-Item -Path "$ytdlp_path" -Destination ".\app\" |
| 195 |
} |
| 196 |
|
| 197 |
if ($use_webengine -eq "ON") { |
| 198 |
$packagebase = "rssguard-${git_tag}-${git_revision}-win" |
| 199 |
} |
| 200 |
else { |
| 201 |
$packagebase = "rssguard-${git_tag}-${git_revision}-lite-win" |
| 202 |
} |
| 203 |
|
| 204 |
if ($use_qt5 -eq "ON") { |
| 205 |
$packagebase += "7" |
| 206 |
} |
| 207 |
else { |
| 208 |
$packagebase += "10" |
| 209 |
} |
| 210 |
|
| 211 |
# Create 7zip package. |
| 212 |
& "$old_pwd\resources\scripts\7za\7za.exe" a -t7z -mmt -mx9 "$packagebase.7z" ".\app\*" |
| 213 |
|
| 214 |
# Create NSIS installation package. |
| 215 |
& "$old_pwd\resources\scripts\nsis\makensis.exe" "/XOutFile $packagebase.exe" ".\NSIS.template.in" |
| 216 |
|
| 217 |
ls |