mirror of
git://code.qt.io/qt/qt5.git
synced 2026-10-12 18:16:06 +08:00
install-ffmpeg.ps1: Remove duplicate path resolution code
At present, this script has two functions that resolve the exact same path. One does it for a regular path, and one does it for a MSYS-style path. This patch adds a new helper function that converts regular paths to MSYS-style paths to helpers.ps1 and uses it in install-ffmpeg.ps1. As a drive-by, we fix some incorrect paths for Android OpenSSL. Pick-to: 6.12 Change-Id: Ia0c7b4be21ed58d4b4fb633b8aeb16de1664694c Reviewed-by: Dimitrios Apostolou <[email protected]>
This commit is contained in:
@@ -259,6 +259,20 @@ function Is64BitWinHost
|
||||
return [environment]::Is64BitOperatingSystem
|
||||
}
|
||||
|
||||
# Translates a native Windows path into an MSYS compatible one,
|
||||
# e.g. "C:\foo\bar" -> "/c/foo/bar".
|
||||
function ConvertTo-MsysPath
|
||||
{
|
||||
Param (
|
||||
[string]$Path = $(BadParam("a path"))
|
||||
)
|
||||
$result = $Path -replace '\\', '/'
|
||||
if ($result -match '^([A-Za-z]):(.*)$') {
|
||||
$result = "/$($Matches[1].ToLower())$($Matches[2])"
|
||||
}
|
||||
return $result
|
||||
}
|
||||
|
||||
enum CpuArch {
|
||||
x64
|
||||
x86
|
||||
|
||||
@@ -69,30 +69,6 @@ function ResolveFFmpegInstallDir {
|
||||
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,
|
||||
@@ -117,11 +93,10 @@ function InstallFfmpeg {
|
||||
|
||||
if ($ndk_ver) {
|
||||
$installDir = ResolveFFmpegInstallDir -buildSystem $buildSystem -ndkVer $ndk_ver
|
||||
$installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem -ndkVer $ndk_ver
|
||||
} else {
|
||||
$installDir = ResolveFFmpegInstallDir -buildSystem $buildSystem
|
||||
$installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem
|
||||
}
|
||||
$installDirForMsys = ConvertTo-MsysPath $installDir
|
||||
|
||||
$cmd = "cd /c/$ffmpeg_name"
|
||||
$cmd += " && mkdir -p build/$buildSystem && cd build/$buildSystem"
|
||||
@@ -179,7 +154,7 @@ function InstallMsvcFfmpeg {
|
||||
}
|
||||
|
||||
$zlibPath = GetZlibPathByString -TargetArchitecture $arch
|
||||
$zlibPath = $zlibPath -replace '\\', '/'
|
||||
$zlibPath = ConvertTo-MsysPath $zlibPath
|
||||
|
||||
$config += " --enable-zlib"
|
||||
$config += " --extra-cflags=`"-I$zlibPath`""
|
||||
@@ -243,7 +218,7 @@ function InstallAndroidArmv7 {
|
||||
$target_cpu="armv7-a"
|
||||
$api_version="24"
|
||||
|
||||
$ndk_dir = $ndk_root -replace '\\', '/' -replace '^C:', '/c'
|
||||
$ndk_dir = ConvertTo-MsysPath $ndk_root
|
||||
|
||||
$toolchain="${ndk_dir}/toolchains/llvm/prebuilt/windows-x86_64"
|
||||
$toolchain_bin="${toolchain}/bin"
|
||||
@@ -255,19 +230,18 @@ function InstallAndroidArmv7 {
|
||||
$ranlib="${toolchain_bin}/llvm-ranlib.exe"
|
||||
$nm="${toolchain_bin}/llvm-nm.exe"
|
||||
$strip="${toolchain_bin}/llvm-strip.exe"
|
||||
$openssl_path = $android_openssl_path.Replace("\", "/")
|
||||
|
||||
Write-Host "Copying _3.so's to .so's"
|
||||
Copy-Item -Path ${openssl_path}/armeabi-v7a/libcrypto_3.so -Destination ${openssl_path}/armeabi-v7a/libcrypto.so
|
||||
Copy-Item -Path ${openssl_path}/armeabi-v7a/libssl_3.so -Destination ${openssl_path}/armeabi-v7a/libssl.so
|
||||
Copy-Item -Path ${android_openssl_path}/armeabi-v7a/libcrypto_3.so -Destination ${android_openssl_path}/armeabi-v7a/libcrypto.so
|
||||
Copy-Item -Path ${android_openssl_path}/armeabi-v7a/libssl_3.so -Destination ${android_openssl_path}/armeabi-v7a/libssl.so
|
||||
|
||||
$android_openssl_path_msys = ConvertTo-MsysPath $android_openssl_path
|
||||
|
||||
$config = GetFfmpegDefaultConfiguration
|
||||
$config += " --enable-cross-compile --target-os=android --enable-jni --enable-mediacodec --enable-openssl --enable-pthreads --enable-neon --disable-asm --disable-indev=android_camera"
|
||||
$config += " --arch=$target_arch --cpu=${target_cpu} --sysroot=${sysroot} --sysinclude=${sysroot}/usr/include/"
|
||||
$config += " --cc=${cc} --cxx=${cxx} --ar=${ar} --ranlib=${ranlib}"
|
||||
$config += " --extra-cflags=-I${android_openssl_path}/include --extra-ldflags=-L${android_openssl_path}/armeabi-v7a"
|
||||
$config += " --extra-cflags=-I${openssl_path}/include --extra-ldflags=-L${openssl_path}/armeabi-v7a"
|
||||
$config += " --extra-cflags=-I${android_openssl_path_msys}/include --extra-ldflags=-L${android_openssl_path_msys}/armeabi-v7a"
|
||||
if ($android_page_size -eq "use_16kb_page_size"){
|
||||
$config += " --extra-ldflags=-Wl,-z,max-page-size=16384"
|
||||
Write-Host "FFmpeg Android using 16KB page sizes"
|
||||
@@ -283,8 +257,8 @@ function InstallAndroidArmv7 {
|
||||
$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
|
||||
Remove-Item -Path ${android_openssl_path}/armeabi-v7a/libcrypto.so
|
||||
Remove-Item -Path ${android_openssl_path}/armeabi-v7a/libssl.so
|
||||
|
||||
if (-not $shared) {
|
||||
return $result
|
||||
@@ -313,7 +287,8 @@ function InstallAndroidArmv7 {
|
||||
|
||||
Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath $msys -ArgumentList ("-lc", "`"cd C:/patchelf-0.17.2 && ./bootstrap.sh && ./configure && make install`"")
|
||||
|
||||
$installDirForMsys = ResolveFFmpegInstallDirMsys -buildSystem $buildSystem -ndkVer $ndk_version
|
||||
$installDir = ResolveFFmpegInstallDir -buildSystem $buildSystem -ndkVer $ndk_version
|
||||
$installDirForMsys = ConvertTo-MsysPath $installDir
|
||||
$command = "${PSScriptRoot}/../shared/fix_ffmpeg_dependencies.sh ${installDirForMsys} _armeabi-v7a no"
|
||||
$command = $command.Replace("\", "/")
|
||||
$patchResult = Start-Process -NoNewWindow -Wait -PassThru -ErrorAction Stop -FilePath $msys -ArgumentList ("-lc", "`"$command`"")
|
||||
|
||||
Reference in New Issue
Block a user