From 18a08f7eb6c74df9757a010cda2fe5dfb9ac8f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Petter=20Ska=CC=8Alerud?= Date: Fri, 22 Aug 2025 08:53:41 +0200 Subject: [PATCH] FFmpeg, Android ARMv7: Use correct build folder when fixing deps This patch amends 133de012af95507ac485845d8de8f58da005df64. The previous patch introduced a regression where the newer build paths were not being passed correctly into 'fix_ffmpeg_dependencies.sh' during FFmpeg Android builds. This patch introduces a common function to resolve the installation directory, which is then used both during compilation and during FFmpeg patching. Additionally, it introduces some basic error-handling when running 'fix_ffmpeg_dependencies.sh' so that we can catch this issue in integration, in the future. Fixes: QTBUG-138615 Change-Id: I195ebd3034a3184bad32e75916a41a20838b2db1 Reviewed-by: Artem Dyomin Reviewed-by: Assam Boudjelthia (cherry picked from commit 7f416abf32448504719ed205e20a6b371fc19c75) Reviewed-by: Qt Cherry-pick Bot --- .../common/windows/install-ffmpeg.ps1 | 68 ++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/coin/provisioning/common/windows/install-ffmpeg.ps1 b/coin/provisioning/common/windows/install-ffmpeg.ps1 index fa011a54..7f0ee7cb 100644 --- a/coin/provisioning/common/windows/install-ffmpeg.ps1 +++ b/coin/provisioning/common/windows/install-ffmpeg.ps1 @@ -30,6 +30,52 @@ function GetFfmpegDefaultConfiguration { return $defaultConfiguration } +# Returns the absolute installation path of FFmpeg for this build +# variant. +function ResolveFFmpegInstallDir { + param( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$buildSystem, + + [Parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [string]$ndkVer + ) + + if ($ndkVer) { + $prefix = "installed-ndk-$ndkVer" + } else { + $prefix = "installed" + } + + return "C:\$ffmpeg_name\build\$buildSystem\$prefix" +} + +# Returns the absolute installation path of FFmpeg for this build +# variant. Returns a path that is compatible with MSYS. +# +# TODO: There is some code duplications here. Make a helper function +# that translates native Windows paths into MSYS compatible paths. +function ResolveFFmpegInstallDirMsys { + param( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string]$buildSystem, + + [Parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [string]$ndkVer + ) + if ($ndkVer) { + $prefix = "installed-ndk-$ndkVer" + } else { + $prefix = "installed" + } + + return "/c/$ffmpeg_name/build/$buildSystem/$prefix" +} + function InstallFfmpeg { Param ( [string]$config, @@ -53,15 +99,16 @@ function InstallFfmpeg { $env:MSYSTEM = $msystem if ($ndk_ver) { - $prefix = "installed-ndk-$ndk_ver" + $installDir = ResolveFFmpegInstallDir -buildSystem $buildSystem -ndkVer $ndk_ver + $installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem -ndkVer $ndk_ver } else { - $prefix = "installed" + $installDir = ResolveFFmpegInstallDir -buildSystem $buildSystem + $installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem } - $installDir = "C:\$ffmpeg_name\build\$buildSystem\$prefix" $cmd = "cd /c/$ffmpeg_name" $cmd += " && mkdir -p build/$buildSystem && cd build/$buildSystem" - $cmd += " && ../../configure --prefix=$prefix $config" + $cmd += " && ../../configure --prefix=$installDirForMsys $config" if ($toolchain) { $cmd += " --toolchain=$toolchain" } @@ -191,8 +238,8 @@ function InstallAndroidArmv7 { $config += " --extra-cflags=-I${openssl_path}/include --extra-ldflags=-L${openssl_path}/armeabi-v7a" $config += " --strip=$strip" - - $result= InstallFfmpeg -config $config -buildSystem "android-arm" -msystem "ANDROID_CLANG" -ffmpegDirEnvVar $ffmpeg_dir_android_envvar_name -shared $shared -ndk_ver $ndk_version + $buildSystem = "android-arm" + $result= InstallFfmpeg -config $config -buildSystem $buildSystem -msystem "ANDROID_CLANG" -ffmpegDirEnvVar $ffmpeg_dir_android_envvar_name -shared $shared -ndk_ver $ndk_version Remove-Item -Path ${openssl_path}/armeabi-v7a/libcrypto.so Remove-Item -Path ${openssl_path}/armeabi-v7a/libssl.so @@ -218,9 +265,14 @@ function InstallAndroidArmv7 { Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath $msys -ArgumentList ("-lc", "`"cd C:/patchelf-0.17.2 && ./bootstrap.sh && ./configure && make install`"") - $command = "${PSScriptRoot}/../shared/fix_ffmpeg_dependencies.sh C:/${ffmpeg_name}/build/android-arm/installed/ _armeabi-v7a no" + $installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem -ndkVer $ndk_version + $command = "${PSScriptRoot}/../shared/fix_ffmpeg_dependencies.sh ${installDirForMsys} _armeabi-v7a no" $command = $command.Replace("\", "/") - Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath $msys -ArgumentList ("-lc", "`"$command`"") + $patchResult = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath $msys -ArgumentList ("-lc", "`"$command`"") + if ($patchResult.ExitCode) { + Write-Host "fix_ffmpeg_dependencies.sh did not finish successfully" + return $false + } return $result }