Skip to content

Commit

Permalink
Provisioning: Build FFmpeg for Windows ARM64 in ARM64 host
Browse files Browse the repository at this point in the history
Install msys2 and FFmpeg for QtMultimedia plugin

Task-number: QTBUG-124399
Pick-to: 6.8 6.7
Change-Id: Ied2bc1039d9571611666530850c525c35c170c69
Reviewed-by: Artem Dyomin <[email protected]>
Reviewed-by: Tero Heikkinen <[email protected]>
  • Loading branch information
Tero Heikkinen committed Sep 3, 2024
1 parent bce8658 commit 88ce036
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion coin/platform_configs/cmake_platforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}',
]
-
Expand Down
62 changes: 47 additions & 15 deletions coin/provisioning/common/windows/install-ffmpeg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function InstallMingwFfmpeg {

function InstallMsvcFfmpeg {
Param (
[string]$hostArch,
[bool]$isArm64
)

Expand All @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\install-msys2.ps1"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
. "$PSScriptRoot\..\common\windows\install-ffmpeg.ps1"

0 comments on commit 88ce036

Please sign in to comment.