From c3c0ccd171479f2ef7f4278b4c91417401fad191 Mon Sep 17 00:00:00 2001 From: hanbowen Date: Mon, 20 Jun 2022 16:02:37 +0800 Subject: [PATCH 1/5] add mbedtls support --- scripts/ffmpeg/build.sh | 4 ++++ scripts/mbedtls/android.cmake | 9 +++++++++ scripts/mbedtls/build.sh | 19 +++++++++++++++++++ scripts/mbedtls/download.sh | 9 +++++++++ scripts/parse-arguments.sh | 6 ++++++ 5 files changed, 47 insertions(+) create mode 100644 scripts/mbedtls/android.cmake create mode 100755 scripts/mbedtls/build.sh create mode 100755 scripts/mbedtls/download.sh diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 18f7b29..49b66d0 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -14,6 +14,10 @@ if [ "$FFMPEG_GPL_ENABLED" = true ] ; then EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-gpl" fi +if [ "$FFMPEG_MBEDTLS_ENABLED" = true ] ; then +EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-protocol=https --enable-version3" +fi + # Preparing flags for enabling requested libraries ADDITIONAL_COMPONENTS= for LIBARY_NAME in ${FFMPEG_EXTERNAL_LIBRARIES[@]} diff --git a/scripts/mbedtls/android.cmake b/scripts/mbedtls/android.cmake new file mode 100644 index 0000000..6e46fc4 --- /dev/null +++ b/scripts/mbedtls/android.cmake @@ -0,0 +1,9 @@ +# Enable NEON for all ARM processors +set(ANDROID_ARM_NEON TRUE) + +# By including this file all necessary variables that point to compiler, linker, etc. +# will be setup. Well, almost all. +# Two variables have to be set before this line though: +# ANDROID_PLATOFORM - the API level to compile against (number) +# ANDROID_ABI - the ABI of the target platform +include("$ENV{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake") \ No newline at end of file diff --git a/scripts/mbedtls/build.sh b/scripts/mbedtls/build.sh new file mode 100755 index 0000000..5f5be57 --- /dev/null +++ b/scripts/mbedtls/build.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +CMAKE_BUILD_DIR=mbedtls_build_${ANDROID_ABI} +# mbedtls authors park their source in a directory named mbedtls-${MBEDTLS_VERSION} +# instead of root directory +cd mbedtls-${MBEDTLS_VERSION} +rm -rf ${CMAKE_BUILD_DIR} +mkdir ${CMAKE_BUILD_DIR} +cd ${CMAKE_BUILD_DIR} + +${CMAKE_EXECUTABLE} .. \ + -DANDROID_PLATFORM=${ANDROID_PLATFORM} \ + -DANDROID_ABI=${ANDROID_ABI} \ + -DCMAKE_TOOLCHAIN_FILE=${SCRIPTS_DIR}/mbedtls/android.cmake \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ + -DENABLE_TESTING=0 + +${MAKE_EXECUTABLE} -j${HOST_NPROC} +${MAKE_EXECUTABLE} install diff --git a/scripts/mbedtls/download.sh b/scripts/mbedtls/download.sh new file mode 100755 index 0000000..f2ca614 --- /dev/null +++ b/scripts/mbedtls/download.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +source ${SCRIPTS_DIR}/common-functions.sh + +export MBEDTLS_VERSION=2.28.0 +downloadTarArchive \ + "mbedtls" \ + "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${MBEDTLS_VERSION}.tar.gz" \ + true \ No newline at end of file diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index 3d21a47..79be0ee 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -12,6 +12,7 @@ SOURCE_TYPE=TAR SOURCE_VALUE=5.0.1 EXTERNAL_LIBRARIES=() FFMPEG_GPL_ENABLED=false +FFMPEG_MBEDTLS_ENABLED=false # All FREE libraries that are supported SUPPORTED_LIBRARIES_FREE=( @@ -25,6 +26,7 @@ SUPPORTED_LIBRARIES_FREE=( "libwebp" "libfreetype" "libfribidi" + "mbedtls" ) # All GPL libraries that are supported @@ -111,6 +113,10 @@ for argument in "$@"; do EXTERNAL_LIBRARIES+=("libx264") FFMPEG_GPL_ENABLED=true ;; + --enable-mbedtls | -mbedtls) + EXTERNAL_LIBRARIES+=("mbedtls") + FFMPEG_MBEDTLS_ENABLED=true + ;; --enable-all-free | -all-free) EXTERNAL_LIBRARIES+=" ${SUPPORTED_LIBRARIES_FREE[@]}" ;; From a0a411e5de8179ad57e4a48376e2a6668655885d Mon Sep 17 00:00:00 2001 From: hanbowen Date: Mon, 20 Jun 2022 17:49:45 +0800 Subject: [PATCH 2/5] fix prase-arguments.sh grammer error --- scripts/parse-arguments.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index ad3d11a..131ea2b 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -117,6 +117,7 @@ for argument in "$@"; do --enable-mbedtls | -mbedtls) EXTERNAL_LIBRARIES+=("mbedtls") FFMPEG_MBEDTLS_ENABLED=true + ;; --enable-libbluray | -bluray) EXTERNAL_LIBRARIES+=("libbluray") ;; From 9a23b15a1ecdb7c41628a672d7110e499e44c47d Mon Sep 17 00:00:00 2001 From: hanbowen Date: Mon, 20 Jun 2022 18:01:38 +0800 Subject: [PATCH 3/5] fix ci --- scripts/mbedtls/build.sh | 2 ++ scripts/parse-arguments.sh | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mbedtls/build.sh b/scripts/mbedtls/build.sh index 5f5be57..a0ac614 100755 --- a/scripts/mbedtls/build.sh +++ b/scripts/mbedtls/build.sh @@ -17,3 +17,5 @@ ${CMAKE_EXECUTABLE} .. \ ${MAKE_EXECUTABLE} -j${HOST_NPROC} ${MAKE_EXECUTABLE} install + +export FFMPEG_MBEDTLS_ENABLED=true \ No newline at end of file diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index 131ea2b..af8953d 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -116,7 +116,6 @@ for argument in "$@"; do ;; --enable-mbedtls | -mbedtls) EXTERNAL_LIBRARIES+=("mbedtls") - FFMPEG_MBEDTLS_ENABLED=true ;; --enable-libbluray | -bluray) EXTERNAL_LIBRARIES+=("libbluray") From 425643763836aa0c951ff529fec6c26ae3637097 Mon Sep 17 00:00:00 2001 From: hanbowen Date: Mon, 11 Jul 2022 22:09:07 +0800 Subject: [PATCH 4/5] drop nessary custom android.cmake --- scripts/mbedtls/android.cmake | 9 --------- scripts/mbedtls/build.sh | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 scripts/mbedtls/android.cmake diff --git a/scripts/mbedtls/android.cmake b/scripts/mbedtls/android.cmake deleted file mode 100644 index 6e46fc4..0000000 --- a/scripts/mbedtls/android.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# Enable NEON for all ARM processors -set(ANDROID_ARM_NEON TRUE) - -# By including this file all necessary variables that point to compiler, linker, etc. -# will be setup. Well, almost all. -# Two variables have to be set before this line though: -# ANDROID_PLATOFORM - the API level to compile against (number) -# ANDROID_ABI - the ABI of the target platform -include("$ENV{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake") \ No newline at end of file diff --git a/scripts/mbedtls/build.sh b/scripts/mbedtls/build.sh index a0ac614..d634ac1 100755 --- a/scripts/mbedtls/build.sh +++ b/scripts/mbedtls/build.sh @@ -11,7 +11,7 @@ cd ${CMAKE_BUILD_DIR} ${CMAKE_EXECUTABLE} .. \ -DANDROID_PLATFORM=${ANDROID_PLATFORM} \ -DANDROID_ABI=${ANDROID_ABI} \ - -DCMAKE_TOOLCHAIN_FILE=${SCRIPTS_DIR}/mbedtls/android.cmake \ + -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake \ -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ -DENABLE_TESTING=0 From f2197adbcab4e592374cc2d74ebf2ac93ae177c8 Mon Sep 17 00:00:00 2001 From: hanbowen Date: Mon, 11 Jul 2022 22:25:19 +0800 Subject: [PATCH 5/5] Remove FFMPEG_MBEDTLS_ENABLED Refactor EXTRA_BUILD_CONFIGURATION_FLAGS variable to be available for all libraries for a given ABI(just as FFMPEG_EXTRA_LD_FLAGS Append the EXTRA_BUILD_CONFIGURATION_FLAGS with --enable-protocol=https --enable-version in mbedtls/build.sh --- scripts/export-build-variables.sh | 3 +++ scripts/ffmpeg/build.sh | 8 ++------ scripts/mbedtls/build.sh | 2 +- scripts/parse-arguments.sh | 1 - 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/export-build-variables.sh b/scripts/export-build-variables.sh index d913f85..beca8d6 100755 --- a/scripts/export-build-variables.sh +++ b/scripts/export-build-variables.sh @@ -81,6 +81,9 @@ export FAM_YASM=${TOOLCHAIN_PATH}/bin/yasm # A variable to which certain dependencies can add -l arguments during build.sh export FFMPEG_EXTRA_LD_FLAGS= +# A variable to which certain dependencies can add addtional arguments during ffmpeg build.sh +export EXTRA_BUILD_CONFIGURATION_FLAGS= + export INSTALL_DIR=${BUILD_DIR_EXTERNAL}/${ANDROID_ABI} # Forcing FFmpeg and its dependencies to look for dependencies diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 49b66d0..d0078ca 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -3,10 +3,10 @@ case $ANDROID_ABI in x86) # Disabling assembler optimizations, because they have text relocations - EXTRA_BUILD_CONFIGURATION_FLAGS=--disable-asm + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --disable-asm" ;; x86_64) - EXTRA_BUILD_CONFIGURATION_FLAGS=--x86asmexe=${FAM_YASM} + EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --x86asmexe=${FAM_YASM}" ;; esac @@ -14,10 +14,6 @@ if [ "$FFMPEG_GPL_ENABLED" = true ] ; then EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-gpl" fi -if [ "$FFMPEG_MBEDTLS_ENABLED" = true ] ; then -EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-protocol=https --enable-version3" -fi - # Preparing flags for enabling requested libraries ADDITIONAL_COMPONENTS= for LIBARY_NAME in ${FFMPEG_EXTERNAL_LIBRARIES[@]} diff --git a/scripts/mbedtls/build.sh b/scripts/mbedtls/build.sh index d634ac1..91b0c19 100755 --- a/scripts/mbedtls/build.sh +++ b/scripts/mbedtls/build.sh @@ -18,4 +18,4 @@ ${CMAKE_EXECUTABLE} .. \ ${MAKE_EXECUTABLE} -j${HOST_NPROC} ${MAKE_EXECUTABLE} install -export FFMPEG_MBEDTLS_ENABLED=true \ No newline at end of file +export EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-protocol=https --enable-version3" \ No newline at end of file diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index af8953d..6ab9942 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -12,7 +12,6 @@ SOURCE_TYPE=TAR SOURCE_VALUE=5.0.1 EXTERNAL_LIBRARIES=() FFMPEG_GPL_ENABLED=false -FFMPEG_MBEDTLS_ENABLED=false # All FREE libraries that are supported SUPPORTED_LIBRARIES_FREE=(