Skip to content

Commit

Permalink
Merge pull request #858 from MediaArea/windows
Browse files Browse the repository at this point in the history
Rework Windows Build Script
  • Loading branch information
JeromeMartinez authored Jan 13, 2025
2 parents 9826192 + 21608be commit 29f01e7
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 214 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/qctools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
compiler: ['clang-9']
include:
- compiler: clang-9
packages: llvm@13
packages: llvm@15
env: { 'CC': 'clang', 'CXX': 'clang++' }

runs-on: macos-latest
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
compiler: ['clang-9']
include:
- compiler: clang-9
packages: llvm@13
packages: llvm@15
env: { 'CC': 'clang', 'CXX': 'clang++', 'HOMEBREW_NO_INSTALL_CLEANUP': '1', 'HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK': '1' }

runs-on: macos-latest
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
compiler: ['clang-9']
include:
- compiler: clang-9
packages: llvm@13
packages: llvm@15
env: { 'CC': 'clang', 'CXX': 'clang++' }
- qt_version: "5.15.*"

Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
compiler: ['clang-9']
include:
- compiler: clang-9
packages: llvm@13
packages: llvm@15
env: { 'CC': 'clang', 'CXX': 'clang++', 'HOMEBREW_NO_INSTALL_CLEANUP': '1', 'HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK': '1' }
- qt_version: "6.5.*"
qt_modules: "qtmultimedia"
Expand Down
132 changes: 0 additions & 132 deletions Project/BuildAllFromSource/build.bat

This file was deleted.

108 changes: 108 additions & 0 deletions Project/BuildAllFromSource/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
###################################################################################################
# build.ps1 - Batch script for building the Windows version of QCTools #
# #
# Script requirements: #
# - qctools_AllInclusive source #
# - Microsoft Visual Studio environment #
# - Qt bin directory in the PATH #
# - Python3 binary in the PATH #
# - pkg-config binary in the PATH #
# - Meson binary in the PATH #
# - Ninja binary in the PATH #
# - Configured WSL2 Linux environment with pkgconf, make and nasm packages installed #
###################################################################################################

# helpers
function Cmd-Result {
if (-Not $?) {
Exit(1)
}
}

# setup environment
$ErrorActionPreference="Stop"
$Env:SUBDIR= # Prevent ffmpeg build error
$Env:PKG_CONFIG_PATH="$Pwd\output\lib\pkgconfig"
$FFmpeg_CmdLine=@(
'--toolchain=msvc',
'--prefix=.',
'--enable-shared',
'--disable-static',
'--disable-doc',
'--disable-debug',
'--disable-programs',
'--disable-autodetect',
'--enable-gpl',
'--enable-version3',
'--enable-libfreetype',
'--enable-libharfbuzz',
'--extra-libs=msvcrt.lib'
)

# freetype
Write-Output "Build FreeType"
if (Test-Path -Path freetype\build) {
Remove-Item -Recurse -Force -Path freetype\build
}
New-Item -ItemType directory -Name freetype\build
Push-Location -Path freetype\build
meson setup --prefix $Pwd\..\..\output --buildtype=release -Db_vscrt=md -Dbrotli=disabled -Dbzip2=disabled -Dharfbuzz=disabled -Dpng=disabled -Dzlib=internal .. ; Cmd-Result
ninja install ; Cmd-Result
Pop-Location

# harfbuzz
Write-Output "Build HarfBuzz"
if (Test-Path -Path harfbuzz\build) {
Remove-Item -Recurse -Force -Path harfbuzz\build
}
New-Item -ItemType directory -Name harfbuzz\build
Push-Location -Path harfbuzz\build
meson setup --prefix $Pwd\..\..\output --buildtype=release -Db_vscrt=md -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dicu=disabled -Dgraphite=disabled -Dgraphite2=disabled -Dgdi=disabled -Ddirectwrite=disabled -Dcoretext=disabled -Dwasm=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Ddoc_tests=false -Dutilities=disabled .. ; Cmd-Result
ninja install ; Cmd-Result
Pop-Location

# remove windows-style line endings from the pkgconf files generated by meson (not well supported by the ffmpeg's configure script)
Write-Output "Fixes .pc files"
Push-Location -Path output\lib\pkgconfig
Get-ChildItem -Path *.pc | ForEach-Object {
(Get-Content -Raw -Path $_.Name) -Replace "`r`n", "`n" | Set-Content -Path $_.Name
}
Pop-Location

# ffmpeg
Write-Output "Build FFmpeg"
Push-Location ffmpeg
if (Test-Path -Path Makefile) {
wsl --shell-type standard -- make clean
}
wsl --shell-type standard -- PKG_CONFIG_PATH=`$PWD/../output/lib/pkgconfig ./configure @FFmpeg_CmdLine ; Cmd-Result
wsl --shell-type standard -- make install ; Cmd-Result
Pop-Location


# qwt
Write-Output "Build Qwt"
Push-Location -Path qwt
$Env:QWT_STATIC=1
$Env:QWT_NO_SVG=1
$Env:QWT_NO_OPENGL=1
$Env:QWT_NO_DESIGNER=1
if (Test-Path -Path Makefile) {
nmake distclean
}
qmake -recursive ; Cmd-Result
nmake Release ; Cmd-Result
Pop-Location

# qctools
Write-Output "Build QCTools"
if (Test-Path -Path qctools\Project\QtCreator\build) {
Remove-Item -Recurse -Force -Path qctools\Project\QtCreator\build
}
New-Item -ItemType directory -Name qctools\Project\QtCreator\build
Push-Location -Path qctools\Project\QtCreator\build
qmake QMAKE_CXXFLAGS+=/Zi QMAKE_LFLAGS+=/INCREMENTAL:NO QMAKE_LFLAGS+=/Debug DEFINES+=QT_AVPLAYER_MULTIMEDIA .. ; Cmd-Result
nmake Release ; Cmd-Result
windeployqt qctools-gui/release/QCTools.exe ; Cmd-Result
windeployqt qctools-cli/release/qcli.exe ; Cmd-Result
Pop-Location
90 changes: 90 additions & 0 deletions Release/Release_CLI_Windows_x64.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
###################################################################################################
# Release_CLI_Windows_x64.ps1 - PowerShell script for creating Windows QCli packages (x64) #
# #
# Script requirements: #
# - Built qctools_AllInclusive sources #
# - Microsoft Visual Studio environment #
###################################################################################################

# setup environment
$ErrorActionPreference="Stop"
$build_path=$Pwd
$version=Get-Content -Path $build_path\qctools\Project\version.txt

# binary archive
Write-Output "Create CLI archive"
if (Test-Path -Path QCli_${version}_Windows_x64) {
Remove-Item -Force -Recurse -Path QCli_${version}_Windows_x64
}
New-Item -ItemType directory -Name QCli_${version}_Windows_x64
Push-Location -Path QCli_${version}_Windows_x64
Copy-Item -Path $build_path\qctools\History.txt
Copy-Item -Path $build_path\qctools\License.html
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\qcli.exe
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\Qt6Core.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\Qt6Gui.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\Qt6Multimedia.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\Qt6Network.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\Qt6Svg.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\d3dcompiler_47.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\opengl32sw.dll
New-Item -ItemType directory -Name iconengines
Push-Location -Path iconengines
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\iconengines\qsvgicon.dll
Pop-Location
New-Item -ItemType directory -Name imageformats
Push-Location -Path imageformats
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\imageformats\qjpeg.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\imageformats\qsvg.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\imageformats\qico.dll
Pop-Location
New-Item -ItemType directory -Name multimedia
Push-Location -Path multimedia
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\multimedia\windowsmediaplugin.dll
Pop-Location
New-Item -ItemType directory -Name networkinformation
Push-Location -Path networkinformation
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\networkinformation\qnetworklistmanager.dll
Pop-Location
New-Item -ItemType directory -Name platforms
Push-Location -Path platforms
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\platforms\qwindows.dll
Pop-Location
New-Item -ItemType directory -Name tls
Push-Location -Path tls
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\tls\qcertonlybackend.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\tls\qopensslbackend.dll
Copy-Item -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\tls\qschannelbackend.dll
Pop-Location
Copy-Item -Path $build_path\ffmpeg\bin\avdevice-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\avcodec-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\avfilter-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\avformat-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\avutil-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\postproc-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\swresample-*.dll
Copy-Item -Path $build_path\ffmpeg\bin\swscale-*.dll
Copy-Item -Path $build_path\output\bin\freetype-*.dll
Copy-Item -Path $build_path\output\bin\harfbuzz.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\concrt140.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\msvcp140.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\msvcp140_1.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\msvcp140_2.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\msvcp140_atomic_wait.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\msvcp140_codecvt_ids.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\vccorlib140.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\vcruntime140.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\vcruntime140_1.dll
Copy-Item -Path $Env:VCToolsRedistDir\x64\Microsoft.VC143.CRT\vcruntime140_threads.dll
Pop-Location
if (Test-Path -Path QCli_${version}_Windows_x64.zip) {
Remove-Item -Force -Path QCli_${version}_Windows_x64.zip
}
Compress-Archive -Path QCli_${version}_Windows_x64\* -DestinationPath QCli_${version}_Windows_x64.zip

# debug symbols archive
Write-Output "Create CLI debug symbols archive"
if (Test-Path -Path QCli_${version}_Windows_x64_DebugInfo.zip) {
Remove-Item -Force -Path QCli_${version}_Windows_x64_DebugInfo.zip
}
Compress-Archive -Path $build_path\qctools\Project\QtCreator\build\qctools-cli\release\QCli.pdb -DestinationPath QCli_${version}_Windows_x64_DebugInfo.zip
Loading

0 comments on commit 29f01e7

Please sign in to comment.