Build shared FFmpeg on Linux and set dependencies to stubs

Task-number: QTBUG-120990
Change-Id: I8fccf8ef58cf6334e71287450ee30cc2256516d9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 83adc86c53)
This commit is contained in:
Volker Hilsheimer
2024-06-16 10:45:10 +02:00
parent 6eed0ab93a
commit ac2a19ab7e
9 changed files with 68 additions and 7 deletions

View File

@@ -8,5 +8,5 @@ Configurations:
Configure arguments: '-nomake examples -developer-build'
Environment variables: [
'CMAKE_ARGS=-DOPENSSL_ROOT_DIR={{.Env.OPENSSL_HOME}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}'
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE'
]

View File

@@ -14,7 +14,7 @@ Configurations:
Compiler: 'GCC'
Features: ['Sccache', 'Documentation', 'UseConfigure', 'DoNotRunTests']
Configure arguments: '-make examples -developer-build -c++std c++20 -linker gold -qtlibinfix TestInfix -qtnamespace TestNamespace'
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}']
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE']
-
Id: 'ubuntu-22.04'
Template: 'qtci-linux-Ubuntu-22.04-x86_64-51'
@@ -23,7 +23,7 @@ Configurations:
Configure arguments: '-nomake examples -release -force-debug-info -separate-debug-info -headersclean -qt-libjpeg -qt-libpng -qt-pcre -qt-harfbuzz -qt-doubleconversion -no-libudev -bundled-xcb-xinput'
Environment variables: [
'CMAKE_ARGS=-DOpenGL_GL_PREFERENCE=LEGACY',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DINPUT_headersclean=ON'
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DINPUT_headersclean=ON -DQT_DEPLOY_FFMPEG=TRUE'
]
# Test on Ubuntu 22.04 X11
-
@@ -65,7 +65,7 @@ Configurations:
Environment variables: [
'PATH={{.Env.CMAKE_MIN_SUPPORTED_BIN_PATH}}:{{.Env.PATH}}',
'CMAKE_ARGS=-DOPENSSL_ROOT_DIR={{.Env.OPENSSL_HOME}}',
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}'
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE'
]
-
Id: 'sles-15_sp5-static'

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
set -x
lib_dir="$1/lib"
ffmpeg_libs=("avcodec" "avdevice" "avfilter" "avformat" "avutil" "swresample" "swscale")
for lib_name in "${ffmpeg_libs[@]}"; do
lib_path="$lib_dir/lib$lib_name.so"
pkg_config_file_path="$lib_dir/pkgconfig/lib$lib_name.pc"
if [ ! -f "$lib_path" ]; then
echo "FFmpeg lib $lib_path hasn't been found"
exit 1
fi
if [ ! -f "$pkg_config_file_path" ]; then
echo "FFmpeg pc file $pkg_config_file_path hasn't been found"
exit 1
fi
while read -r line; do
if [[ $line =~ .*\[(lib((ssl|crypto|va|va-x11|va-drm)\.so(\.[0-9]+)*))\].* ]]; then
patchelf --replace-needed "${BASH_REMATCH[1]}" "libQt6FFmpegStub-${BASH_REMATCH[2]}" $lib_path
fi
done <<< "$(readelf -d $lib_path | grep '(NEEDED)' )"
sed -i -E "/^Libs.private:/s/ -l(va|va-x11|va-drm|ssl|crypto)/ -lQt6FFmpegStub-\\1/g;" $pkg_config_file_path
patchelf --set-rpath '$ORIGIN' $lib_path
done

View File

@@ -71,11 +71,31 @@ build_ffmpeg() {
}
if [ "$os" == "linux" ]; then
# TODO: install patchelf on RHEL and remove the force "static"
if [ -f "/etc/redhat-release" ]; then
build_type="static"
else
build_type="$2"
fi
install_ff_nvcodec_headers
ffmpeg_config_options+=" --enable-openssl"
if [ "$build_type" != "static" ]; then
ffmpeg_config_options+=" --enable-shared --disable-static"
fi
build_ffmpeg
sudo mv "$ffmpeg_source_dir/build/installed/usr/local/$ffmpeg_name" "/usr/local"
output_dir="$ffmpeg_source_dir/build/installed/usr/local/$ffmpeg_name"
if [ "$build_type" != "static" ]; then
fix_dependencies="${BASH_SOURCE%/*}/../linux/fix_ffmpeg_dependencies.sh"
"$fix_dependencies" "$output_dir"
fi
sudo mv "$output_dir" "/usr/local"
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
@@ -111,3 +131,5 @@ elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
fi

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux"
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux" "static"

View File

@@ -2,4 +2,4 @@
# Copyright (C) 2023 The Qt Company Ltd
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux"
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux" "static"

View File

@@ -168,6 +168,8 @@ installPackages+=(ruby)
installPackages+=(libxslt1-dev)
installPackages+=(libxml2-dev)
installPackages+=(libhyphen-dev)
# Fix dependencies in shared ffmpeg libs
installPackages+=(patchelf)
echo "Running update for apt"
waitLoop

View File

@@ -217,6 +217,8 @@ sudo dpkg --add-architecture i386
installPackages+=(nfs-kernel-server)
installPackages+=(net-tools)
installPackages+=(bridge-utils)
# Fix dependencies in shared ffmpeg libs
installPackages+=(patchelf)
echo "Running update for apt"
waitLoop

View File

@@ -235,6 +235,8 @@ installPackages+=(uml-utilities)
# used for reading vcpkg packages version, from vcpkg.json
installPackages+=(jq)
installPackages+=(patchelf)
echo "Running update for apt"
waitLoop
sudo apt-get update