From befe4a61d6c6987e40e1664448e925bdce9fb411 Mon Sep 17 00:00:00 2001 From: Pavel Dubsky Date: Wed, 13 Mar 2024 20:55:46 +0100 Subject: [PATCH] Update provisioning script to build FFmpeg for Windows ARM64 Fixes: QTBUG-122745 Pick-to: 6.7 6.5 Change-Id: Ib03484ac89f07d7ad6433b0035769f4a9363495b Reviewed-by: Artem Dyomin --- coin/platform_configs/cmake_platforms.yaml | 4 +-- coin/provisioning/common/windows/helpers.ps1 | 12 ++++----- .../common/windows/install-ffmpeg.ps1 | 27 ++++++++++++++++--- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/coin/platform_configs/cmake_platforms.yaml b/coin/platform_configs/cmake_platforms.yaml index 1ed9d620..181c83fd 100644 --- a/coin/platform_configs/cmake_platforms.yaml +++ b/coin/platform_configs/cmake_platforms.yaml @@ -129,7 +129,7 @@ Configurations: Environment variables: [ 'TARGET_CONFIGURE_ARGS=-debug-and-release -force-debug-info -platform win32-arm64-msvc', 'TARGET_CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_ROOT_DIR_x64_arm64}}', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFEATURE_native_grpc=OFF', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFEATURE_native_grpc=OFF -DFFMPEG_DIR={{.Env.FFMPEG_DIR_MSVC_ARM64}} -DQT_DEPLOY_FFMPEG=TRUE', 'OPENSSL_CONF_x64={{.Env.OPENSSL_CONF_x64_arm64}}', 'OPENSSL_INCLUDE_x64={{.Env.OPENSSL_INCLUDE_x64_arm64}}', 'OPENSSL_LIB_x64={{.Env.OPENSSL_LIB_x64_arm64}}', @@ -157,7 +157,7 @@ Configurations: Environment variables: [ 'TARGET_CONFIGURE_ARGS=-debug-and-release -force-debug-info -platform win32-arm64-msvc', 'TARGET_CMAKE_ARGS=-DFEATURE_msvc_obj_debug_info=ON', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFEATURE_native_grpc=OFF', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFEATURE_native_grpc=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/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1 index d6ed9bbf..9fbf27aa 100644 --- a/coin/provisioning/common/windows/helpers.ps1 +++ b/coin/provisioning/common/windows/helpers.ps1 @@ -307,10 +307,10 @@ function GetVSPath { } function EnterVSDevShell { - # Add cl to path if it is not already there. - if (Get-Command cl.exe -ErrorAction SilentlyContinue) { - return $true - } + Param ( + [string]$HostArch = "amd64", + [string]$Arch = "amd64" + ) $vsWere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" $vcComponent = "Microsoft.VisualStudio.Component.VC.CoreIde" @@ -318,10 +318,10 @@ function EnterVSDevShell { # If MSVC has an ABI break this will stop working, and yet another build must be added. $VSPath = (& $vsWere -nologo -products * -requires $vcComponent -sort -format value -property installationPath | Select-Object -Last 1) - Write-Host "Enter VisualStudio developer shell" + Write-Host "Enter VisualStudio developer shell (-host_arch=$HostArch -arch=$Arch)" try { Import-Module "$VSPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath $VSPath -DevCmdArguments "-arch=x64 -no_logo" + Enter-VsDevShell -VsInstallPath $VSPath -DevCmdArguments "-host_arch=$HostArch -arch=$Arch -no_logo" } catch { Write-Host "Failed to enter VisualStudio DevShell" return $false diff --git a/coin/provisioning/common/windows/install-ffmpeg.ps1 b/coin/provisioning/common/windows/install-ffmpeg.ps1 index 2ac93e7d..b806f58d 100644 --- a/coin/provisioning/common/windows/install-ffmpeg.ps1 +++ b/coin/provisioning/common/windows/install-ffmpeg.ps1 @@ -73,12 +73,29 @@ function InstallMingwFfmpeg { function InstallMsvcFfmpeg { - $result = EnterVSDevShell + Param ( + [bool]$isArm64 + ) + + $arch = "amd64" + $buildSystem = "msvc" + $ffmpegDirEnvVar = "FFMPEG_DIR_MSVC" + + $config = Get-Content "$PSScriptRoot\..\shared\ffmpeg_config_options.txt" + + if ($isArm64) { + $arch = "arm64" + $buildSystem += "-arm64" + $ffmpegDirEnvVar += "_ARM64" + $config += " --enable-cross-compile --arch=arm64 --disable-asm" + } + + $result = EnterVSDevShell -Arch $arch if (-Not $result) { return $false } - $result = InstallFfmpeg -buildSystem "msvc" -msystem "MSYS" -toolchain "msvc" -ffmpegDirEnvVar "FFMPEG_DIR_MSVC" -shared $true + $result = InstallFfmpeg -buildSystem $buildSystem -msystem "MSYS" -toolchain "msvc" -ffmpegDirEnvVar $ffmpegDirEnvVar -shared $true if ($result) { # As ffmpeg build system creates lib*.a file we have to rename them to *.lib files to be recognized by WIN32 @@ -138,14 +155,16 @@ function InstallAndroidArmv7 { } $mingwRes = InstallMingwFfmpeg -$msvcRes = InstallMsvcFfmpeg $llvmMingwRes = InstallLlvmMingwFfmpeg $androidArmV7Res = InstallAndroidArmv7 +$msvcRes = InstallMsvcFfmpeg -isArm64 $false +$msvcArm64Res = InstallMsvcFfmpeg -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" }) -exit $(if ($mingwRes -and $msvcRes -and $llvmMingwRes -and $androidArmV7Res) { 0 } else { 1 }) +exit $(if ($mingwRes -and $msvcRes -and $msvcArm64Res -and $llvmMingwRes -and $androidArmV7Res) { 0 } else { 1 })