From 88ce03607354b68ab1da7f0230d13a664cada5e1 Mon Sep 17 00:00:00 2001 From: Tero Heikkinen Date: Mon, 26 Aug 2024 15:23:10 +0300 Subject: [PATCH] Provisioning: Build FFmpeg for Windows ARM64 in ARM64 host Install msys2 and FFmpeg for QtMultimedia plugin Task-number: QTBUG-124399 Pick-to: 6.8 6.7 Change-Id: Ied2bc1039d9571611666530850c525c35c170c69 Reviewed-by: Artem Dyomin Reviewed-by: Tero Heikkinen --- coin/platform_configs/cmake_platforms.yaml | 2 +- .../common/windows/install-ffmpeg.ps1 | 62 ++++++++++++++----- .../10-install-msys2.ps1 | 1 + .../90-install-ffmpeg.ps1 | 1 + 4 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 coin/provisioning/qtci-windows-11_22H2-aarch64/10-install-msys2.ps1 create mode 100644 coin/provisioning/qtci-windows-11_22H2-aarch64/90-install-ffmpeg.ps1 diff --git a/coin/platform_configs/cmake_platforms.yaml b/coin/platform_configs/cmake_platforms.yaml index 31f35c37688..bf4704ce739 100644 --- a/coin/platform_configs/cmake_platforms.yaml +++ b/coin/platform_configs/cmake_platforms.yaml @@ -160,7 +160,7 @@ Configurations: Configure arguments: '-debug-and-release -force-debug-info -headersclean -nomake examples -qt-zlib -no-sql-psql -no-opengl' Environment variables: [ 'CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_INCLUDE_arm64}}\..', - 'NON_QTBASE_CMAKE_ARGS= -DFEATURE_clangcpp=OFF -DFEATURE_qdoc=OFF', + 'NON_QTBASE_CMAKE_ARGS= -DFEATURE_clangcpp=OFF -DFEATURE_qdoc=OFF -DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC_ARM64}} -DQT_DEPLOY_FFMPEG=TRUE', 'Protobuf_ROOT={{.Env.Protobuf_ROOT_msvc}}', ] - diff --git a/coin/provisioning/common/windows/install-ffmpeg.ps1 b/coin/provisioning/common/windows/install-ffmpeg.ps1 index 64b514559a5..77f642f3cb5 100644 --- a/coin/provisioning/common/windows/install-ffmpeg.ps1 +++ b/coin/provisioning/common/windows/install-ffmpeg.ps1 @@ -85,6 +85,7 @@ function InstallMingwFfmpeg { function InstallMsvcFfmpeg { Param ( + [string]$hostArch, [bool]$isArm64 ) @@ -98,10 +99,13 @@ function InstallMsvcFfmpeg { $arch = "arm64" $buildSystem += "-arm64" $ffmpegDirEnvVar += "_ARM64" - $config += " --enable-cross-compile --arch=arm64 --disable-asm" + $config += " --arch=arm64 --disable-asm" + if ($hostArch -eq "amd64") { + $config += " --enable-cross-compile" + } } - $result = EnterVSDevShell -Arch $arch + $result = EnterVSDevShell -HostArch $hostArch -Arch $arch if (-Not $result) { return $false } @@ -112,7 +116,7 @@ function InstallMsvcFfmpeg { # As ffmpeg build system creates lib*.a file we have to rename them to *.lib files to be recognized by WIN32 Write-Host "Rename libraries lib*.a -> *.lib" try { - $msvcDir = [System.Environment]::GetEnvironmentVariable("FFMPEG_DIR_MSVC", [System.EnvironmentVariableTarget]::Machine) + $msvcDir = [System.Environment]::GetEnvironmentVariable($ffmpegDirEnvVar, [System.EnvironmentVariableTarget]::Machine) Get-ChildItem "$msvcDir\lib\lib*.a" | ForEach-Object { $NewName = $_.Name -replace 'lib(\w+).a$', '$1.lib' $Destination = Join-Path -Path $_.Directory.FullName -ChildPath $NewName @@ -201,17 +205,45 @@ function InstallAndroidArmv7 { return $result } -$mingwRes = InstallMingwFfmpeg -$llvmMingwRes = InstallLlvmMingwFfmpeg -$androidArmV7Res = InstallAndroidArmv7 -$msvcRes = InstallMsvcFfmpeg -isArm64 $false -$msvcArm64Res = InstallMsvcFfmpeg -isArm64 $true +function InstallFfmpegsAMD64 { + $hostArch = "amd64" + $mingwRes = InstallMingwFfmpeg + $llvmMingwRes = InstallLlvmMingwFfmpeg + $androidArmV7Res = InstallAndroidArmv7 + $msvcRes = InstallMsvcFfmpeg -hostArch $hostArch -isArm64 $false + $msvcArm64Res = InstallMsvcFfmpeg -hostArch $hostArch -isArm64 $true + + Write-Host "Ffmpeg installation results:" + Write-Host " mingw:" $(if ($mingwRes) { "OK" } else { "FAIL" }) + Write-Host " llvm-mingw:" $(if ($llvmMingwRes) { "OK" } else { "FAIL" }) + Write-Host " android-armv7:" $(if ($androidArmV7Res) { "OK" } else { "FAIL" }) + Write-Host " msvc:" $(if ($msvcRes) { "OK" } else { "FAIL" }) + Write-Host " msvc-arm64:" $(if ($msvcArm64Res) { "OK" } else { "FAIL" }) + + exit $(if ($mingwRes -and $msvcRes -and $msvcArm64Res -and $llvmMingwRes -and $androidArmV7Res) { 0 } else { 1 }) +} + +function InstallFfmpegsARM64 { + $hostArch = "arm64" + $msvcArm64Res = InstallMsvcFfmpeg -hostArch $hostArch -isArm64 $true -Write-Host "Ffmpeg installation results:" -Write-Host " mingw:" $(if ($mingwRes) { "OK" } else { "FAIL" }) -Write-Host " msvc:" $(if ($msvcRes) { "OK" } else { "FAIL" }) -Write-Host " msvc-arm64:" $(if ($msvcArm64Res) { "OK" } else { "FAIL" }) -Write-Host " llvm-mingw:" $(if ($llvmMingwRes) { "OK" } else { "FAIL" }) -Write-Host " android-armv7:" $(if ($androidArmV7Res) { "OK" } else { "FAIL" }) + Write-Host "Ffmpeg installation results:" + Write-Host " msvc-arm64:" $(if ($msvcArm64Res) { "OK" } else { "FAIL" }) + + exit $(if ($msvcArm64Res) { 0 } else { 1 }) +} -exit $(if ($mingwRes -and $msvcRes -and $msvcArm64Res -and $llvmMingwRes -and $androidArmV7Res) { 0 } else { 1 }) +$cpu_arch = Get-CpuArchitecture +switch ($cpu_arch) { + arm64 { + InstallFfmpegsARM64 + Break + } + x64 { + InstallFfmpegsAMD64 + Break + } + default { + throw "Unknown architecture $cpu_arch" + } +} diff --git a/coin/provisioning/qtci-windows-11_22H2-aarch64/10-install-msys2.ps1 b/coin/provisioning/qtci-windows-11_22H2-aarch64/10-install-msys2.ps1 new file mode 100644 index 00000000000..be9a36349c8 --- /dev/null +++ b/coin/provisioning/qtci-windows-11_22H2-aarch64/10-install-msys2.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install-msys2.ps1" diff --git a/coin/provisioning/qtci-windows-11_22H2-aarch64/90-install-ffmpeg.ps1 b/coin/provisioning/qtci-windows-11_22H2-aarch64/90-install-ffmpeg.ps1 new file mode 100644 index 00000000000..cd8df72f926 --- /dev/null +++ b/coin/provisioning/qtci-windows-11_22H2-aarch64/90-install-ffmpeg.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install-ffmpeg.ps1"