From 99afe7199ecc09e56cb5d779db31bf65ba98fa3d Mon Sep 17 00:00:00 2001 From: Samuel Mira Date: Mon, 17 Apr 2023 10:56:30 +0300 Subject: Fix FFmpeg provisioning for Android in arm64, x86 and x86_64 Added install-ffmpeg-android script for the android cross-compile Removed android stuff from install-ffmpeg Changed the yaml variables to include the target arch Added the arm64 target arch Task-number: QTQAINFRA-5476 Pick-to: 6.5 Change-Id: Id9609ed0427f2fc42f7f27e7787a81ad145f59be Reviewed-by: Ville Voutilainen Reviewed-by: Rami Potinkara Reviewed-by: Lars Knoll --- .../cmake_platforms_target_android.yaml | 6 +- .../cmake_platforms_target_android_12.yaml | 2 +- .../common/unix/install-ffmpeg-android.sh | 139 +++++++++++++++++++++ coin/provisioning/common/unix/install-ffmpeg.sh | 84 +------------ .../90-install-ffmpeg.sh | 3 +- .../qtci-macos-12-x86_64/90-install-ffmpeg.sh | 1 + 6 files changed, 147 insertions(+), 88 deletions(-) create mode 100755 coin/provisioning/common/unix/install-ffmpeg-android.sh diff --git a/coin/platform_configs/cmake_platforms_target_android.yaml b/coin/platform_configs/cmake_platforms_target_android.yaml index 45923c3b..612f22d1 100644 --- a/coin/platform_configs/cmake_platforms_target_android.yaml +++ b/coin/platform_configs/cmake_platforms_target_android.yaml @@ -14,7 +14,7 @@ Configurations: 'TARGET_CMAKE_ARGS=-DCMAKE_C_COMPILER_FRONTEND_VARIANT=GNU -DCMAKE_CXX_COMPILER_FRONTEND_VARIANT=GNU -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_ANDROID_HOME_DEFAULT}} -DQT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS=ON', 'CONAN_HOST_PROFILE=coin/conan/profiles/ci-macos-universal-clang', 'CONAN_PROFILE=coin/conan/profiles/ci-unix-android-arm64-clang', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DQT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH=/usr/local', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DQT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH=/usr/local -DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID_ARM64}}', 'ANDROID_NDK_ROOT={{.Env.ANDROID_NDK_ROOT_DEFAULT}}' ] - @@ -47,7 +47,7 @@ Configurations: Environment variables: [ 'TARGET_CONFIGURE_ARGS=-nomake examples -release -force-debug-info -android-ndk {{.Env.ANDROID_NDK_ROOT_DEFAULT}} -android-sdk {{.Env.ANDROID_SDK_ROOT}} -android-abis x86', 'TARGET_CMAKE_ARGS=-DCMAKE_C_COMPILER_FRONTEND_VARIANT=GNU -DCMAKE_CXX_COMPILER_FRONTEND_VARIANT=GNU -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_ANDROID_HOME_DEFAULT}} -DQT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS=ON', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID}}', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID_X86}}', 'CONAN_HOST_PROFILE=coin/conan/profiles/ci-linux-x86_64-gcc', 'CONAN_PROFILE=coin/conan/profiles/ci-unix-android-x86-clang', 'ANDROID_EMULATOR=@emulator_x86_api_23', @@ -65,7 +65,7 @@ Configurations: Environment variables: [ 'TARGET_CONFIGURE_ARGS=-nomake examples -release -force-debug-info -android-ndk {{.Env.ANDROID_NDK_ROOT_DEFAULT}} -android-sdk {{.Env.ANDROID_SDK_ROOT}} -android-abis x86_64', 'TARGET_CMAKE_ARGS=-DCMAKE_C_COMPILER_FRONTEND_VARIANT=GNU -DCMAKE_CXX_COMPILER_FRONTEND_VARIANT=GNU -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_ANDROID_HOME_DEFAULT}} -DQT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS=ON', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID}}', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID_X86_64}}', 'CONAN_HOST_PROFILE=coin/conan/profiles/ci-linux-x86_64-gcc', 'CONAN_PROFILE=coin/conan/profiles/ci-unix-android-x86_64-clang', 'ANDROID_NDK_ROOT={{.Env.ANDROID_NDK_ROOT_DEFAULT}}' diff --git a/coin/platform_configs/cmake_platforms_target_android_12.yaml b/coin/platform_configs/cmake_platforms_target_android_12.yaml index 4117b500..287f46e4 100644 --- a/coin/platform_configs/cmake_platforms_target_android_12.yaml +++ b/coin/platform_configs/cmake_platforms_target_android_12.yaml @@ -12,7 +12,7 @@ Configurations: Environment variables: [ 'TARGET_CONFIGURE_ARGS=-nomake examples -release -force-debug-info -android-ndk {{.Env.ANDROID_NDK_ROOT_DEFAULT}} -android-sdk {{.Env.ANDROID_SDK_ROOT}} -android-abis x86_64', 'TARGET_CMAKE_ARGS=-DCMAKE_C_COMPILER_FRONTEND_VARIANT=GNU -DCMAKE_CXX_COMPILER_FRONTEND_VARIANT=GNU -DOPENSSL_ROOT_DIR={{.Env.OPENSSL_ANDROID_HOME_DEFAULT}} -DQT_GENERATE_WRAPPER_SCRIPTS_FOR_ALL_HOSTS=ON', - 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID}}', + 'NON_QTBASE_TARGET_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR_ANDROID_X86_64}}', 'CONAN_HOST_PROFILE=coin/conan/profiles/ci-linux-x86_64-gcc', 'CONAN_PROFILE=coin/conan/profiles/ci-unix-android-x86_64-clang', 'ANDROID_NDK_ROOT={{.Env.ANDROID_NDK_ROOT_DEFAULT}}', diff --git a/coin/provisioning/common/unix/install-ffmpeg-android.sh b/coin/provisioning/common/unix/install-ffmpeg-android.sh new file mode 100755 index 00000000..75efc384 --- /dev/null +++ b/coin/provisioning/common/unix/install-ffmpeg-android.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash + +############################################################################ +## +## Copyright (C) 2022 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the provisioning scripts of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +# This script will build and install FFmpeg static libs +set -ex +os="$1" + +# shellcheck source=../unix/InstallFromCompressedFileFromURL.sh +source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh" +# shellcheck source=../unix/SetEnvVar.sh +source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh" + +version="n6.0" +url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz" +sha1="78435ec71cc2227017a99c030e858719b8c7c74d" +url_cached="http://ci-files01-hki.intra.qt.io/input/ffmpeg/$version.tar.gz" +ffmpeg_name="FFmpeg-$version" + +target_dir="$HOME" +app_prefix="" +ffmpeg_source_dir="$target_dir/$ffmpeg_name" + +if [ ! -d "$ffmpeg_source_dir" ]; +then + InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix" +fi + +build_ffmpeg_android() { + + target_arch=$1 + target_dir=$2 + + sudo mkdir -p "$target_dir" + + if [ "$target_arch" == "x86_64" ]; then + target_toolchain_arch="x86_64-linux-android" + target_arch=x86_64 + target_cpu=x86_64 + elif [ "$target_arch" == "x86" ]; then + target_toolchain_arch="i686-linux-android" + target_arch=x86 + target_cpu=i686 + elif [ "$target_arch" == "arm64" ]; then + target_toolchain_arch="aarch64-linux-android" + target_arch=aarch64 + target_cpu=armv8-a + fi + + api_version=24 + + ndk_root=/opt/android/android-ndk-r25b + if uname -a |grep -q "Darwin"; then + ndk_host=darwin-x86_64 + else + ndk_host=linux-x86_64 + fi + + toolchain=${ndk_root}/toolchains/llvm/prebuilt/${ndk_host} + toolchain_bin=${toolchain}/bin + sysroot=${toolchain}/sysroot + cxx=${toolchain_bin}/${target_toolchain_arch}${api_version}-clang++ + cc=${toolchain_bin}/${target_toolchain_arch}${api_version}-clang + ld=${toolchain_bin}/ld + ar=${toolchain_bin}/llvm-ar + ranlib=${toolchain_bin}/llvm-ranlib + nm=${toolchain_bin}/llvm-nm + strip=${toolchain_bin}/llvm-strip + + ffmpeg_config_options=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt") + ffmpeg_config_options+=" --disable-vulkan --enable-cross-compile --target-os=android --enable-jni --enable-mediacodec --enable-pthreads --enable-neon --disable-asm --disable-indev=android_camera" + ffmpeg_config_options+=" --arch=$target_arch --cpu=${target_cpu} --sysroot=${sysroot} --sysinclude=${sysroot}/usr/include/" + ffmpeg_config_options+=" --cc=${cc} --cxx=${cxx} --ar=${ar} --ranlib=${ranlib}" + + local build_dir="$ffmpeg_source_dir/build/$target_arch" + sudo mkdir -p "$build_dir" + pushd "$build_dir" + + sudo $ffmpeg_source_dir/configure $ffmpeg_config_options --prefix="$target_dir" + + sudo make install -j4 + popd +} + +if [ "$os" == "android-x86" ]; then + target_arch=x86 + target_dir="/usr/local/android/ffmpeg-x86" + + SetEnvVar "FFMPEG_DIR_ANDROID_X86" "$target_dir" +elif [ "$os" == "android-x86_64" ]; then + target_arch=x86_64 + target_dir="/usr/local/android/ffmpeg-x86_64" + + SetEnvVar "FFMPEG_DIR_ANDROID_X86_64" "$target_dir" +elif [ "$os" == "android-arm64" ]; then + target_arch=arm64 + target_dir="/usr/local/android/ffmpeg-arm64" + + SetEnvVar "FFMPEG_DIR_ANDROID_ARM64" "$target_dir" +fi + +build_ffmpeg_android "$target_arch" "$target_dir" diff --git a/coin/provisioning/common/unix/install-ffmpeg.sh b/coin/provisioning/common/unix/install-ffmpeg.sh index bd3d0cc1..61bd6002 100755 --- a/coin/provisioning/common/unix/install-ffmpeg.sh +++ b/coin/provisioning/common/unix/install-ffmpeg.sh @@ -48,26 +48,9 @@ source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh" # shellcheck source=../unix/SetEnvVar.sh source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh" -function SourceEnvVar { - echo "Source environment variables file" - if [ uname -a | grep -q "Ubuntu" ]; - then - if [ lsb_release -a | grep "Ubuntu 22.04" ]; - then source ~/.bashrc - else source ~/.profile - fi - else - source ~/.bashrc - source ~/.zshrc - fi -} - - version="n6.0" url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz" sha1="78435ec71cc2227017a99c030e858719b8c7c74d" - - url_cached="http://ci-files01-hki.intra.qt.io/input/ffmpeg/$version.tar.gz" ffmpeg_name="FFmpeg-$version" @@ -94,8 +77,7 @@ build_ffmpeg() { then prefix="/usr/local/$ffmpeg_name" fi - # android configures its own toolchain, it does not use the system clang - if [ -n "$arch" ] && [ "$os" != "android" ] + if [ -n "$arch" ] then cc="clang -arch $arch" fi @@ -107,36 +89,6 @@ build_ffmpeg() { popd } -build_ffmpeg_android() { - SourceEnvVar - target_arch=$1 - target_dir=$2 - - if [ "$target_arch" == "x86_64" ]; - then - #emulador on CI is x86_64 - target_toolchain_arch="x86_64-linux-android" - target_arch=x86_64 - target_cpu=x86_64 - else - #emulador on CI is x86 - target_toolchain_arch="i686-linux-android" - target_arch=x86 - target_cpu=i686 - fi - - api_version=24 - - toolchain=${ANDROID_NDK_ROOT_DEFAULT}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST} - toolchain_bin=${toolchain}/bin - sysroot=${toolchain}/sysroot - cxx=${toolchain_bin}/${target_toolchain_arch}${api_version}-clang++ - cc=${toolchain_bin}/${target_toolchain_arch}${api_version}-clang - - ffmpeg_config_options+=" --disable-vulkan --target-os=android --enable-jni --enable-mediacodec --enable-pthreads --enable-neon --disable-asm --cpu=${target_cpu} --disable-indev=android_camera --sysroot=${sysroot} --sysinclude=${sysroot}/usr/include/ --cc=${cc} --cxx=${cxx}" - build_ffmpeg ${target_arch} ${target_dir} -} - if [ "$os" == "linux" ]; then ffmpeg_config_options="$ffmpeg_config_options --enable-openssl" build_ffmpeg @@ -159,39 +111,5 @@ elif [ "$os" == "macos-universal" ]; then sudo "${BASH_SOURCE%/*}/../macos/makeuniversal.sh" "$ffmpeg_source_dir/build/arm64/installed" "$ffmpeg_source_dir/build/x86_64/installed" SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name" -elif [ "$os" == "android" ]; then - - SourceEnvVar - - url_cached="" - url_public="" - sha1="" - - #get emulator target arch - if [ "$ANDROID_EMULATOR" == *"x86_64"* ]; - then - target_arch=x86_64 - sha1="0241fd483c16f4ce53206b911214b06854cdef9d" - url_cached="http://ci-files01-hki.intra.qt.io/input/ffmpeg/android-ffmpeg-x86_64.zip" - target_dir="/opt/android/$ffmpeg_name/ffmpeg-x86_64" - else - target_arch=x86 - url_cached="http://ci-files01-hki.intra.qt.io/input/ffmpeg/android-ffmpeg-x86.zip" - sha1="8b254e31411a350edb581bb30e31401866abbe7d" - target_dir="/opt/android/$ffmpeg_name/ffmpeg-x86" - fi - - app_prefix="" - - #try install a pre-build - InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix" - - #if could not install pre-build, build it - if [ ! -d "$target_dir" ]; - then build_ffmpeg_android "$target_arch" "$target_dir" - fi - - #set the var to use in yaml - SetEnvVar "FFMPEG_DIR_ANDROID" "$target_dir" fi diff --git a/coin/provisioning/qtci-linux-RHEL-8.4-x86_64/90-install-ffmpeg.sh b/coin/provisioning/qtci-linux-RHEL-8.4-x86_64/90-install-ffmpeg.sh index 280b2870..3662d655 100755 --- a/coin/provisioning/qtci-linux-RHEL-8.4-x86_64/90-install-ffmpeg.sh +++ b/coin/provisioning/qtci-linux-RHEL-8.4-x86_64/90-install-ffmpeg.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux" -source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "android" +source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg-android.sh" "android-x86" +source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg-android.sh" "android-x86_64" diff --git a/coin/provisioning/qtci-macos-12-x86_64/90-install-ffmpeg.sh b/coin/provisioning/qtci-macos-12-x86_64/90-install-ffmpeg.sh index a8333b36..a96a652a 100755 --- a/coin/provisioning/qtci-macos-12-x86_64/90-install-ffmpeg.sh +++ b/coin/provisioning/qtci-macos-12-x86_64/90-install-ffmpeg.sh @@ -3,3 +3,4 @@ set -ex source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "macos-universal" +source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg-android.sh" "android-arm64" -- cgit v1.2.1