From b26f55b2b8841e8b0914ac5c72c3e2f248fb5cb3 Mon Sep 17 00:00:00 2001 From: Javernaut Date: Wed, 27 Nov 2019 15:25:35 +0200 Subject: [PATCH] Integration of libmp3lame --- .travis.yml | 2 +- scripts/export-build-variables.sh | 6 +++++- scripts/ffmpeg/build.sh | 7 ++++++- scripts/ffmpeg/download.sh | 4 ++-- scripts/libmp3lame/build.sh | 22 ++++++++++++++++++++++ scripts/libmp3lame/download.sh | 17 +++++++++++++++++ scripts/parse-arguments.sh | 30 +++++++++++++++--------------- 7 files changed, 68 insertions(+), 20 deletions(-) create mode 100755 scripts/libmp3lame/build.sh create mode 100755 scripts/libmp3lame/download.sh diff --git a/.travis.yml b/.travis.yml index 6c363b6..e87acb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ before_install: # Keeping track of the NDK version that was used - cat $ANDROID_NDK_HOME/source.properties script: - - bash -e ffmpeg-android-maker.sh + - bash -e ffmpeg-android-maker.sh --enable-libmp3lame diff --git a/scripts/export-build-variables.sh b/scripts/export-build-variables.sh index 2d0efb3..95d79a8 100755 --- a/scripts/export-build-variables.sh +++ b/scripts/export-build-variables.sh @@ -67,8 +67,9 @@ export SIZE=${CROSS_PREFIX_WITH_PATH}size export STRINGS=${CROSS_PREFIX_WITH_PATH}strings export STRIP=${CROSS_PREFIX_WITH_PATH}strip +export TARGET=${TARGET_TRIPLE_MACHINE_CC}-linux-${TARGET_TRIPLE_OS}${ANDROID_PLATFORM} # The name for compiler is slightly different, so it is defined separatly. -export CC=${TOOLCHAIN_PATH}/bin/${TARGET_TRIPLE_MACHINE_CC}-linux-${TARGET_TRIPLE_OS}${ANDROID_PLATFORM}-clang +export CC=${TOOLCHAIN_PATH}/bin/${TARGET}-clang export CXX=${CC}++ # TODO consider abondaning this strategy of defining the name of the clang wrapper # in favour of just passing -mstackrealign and -fno-addrsig depending on @@ -76,3 +77,6 @@ export CXX=${CC}++ # Special variable for the yasm assembler export YASM=${TOOLCHAIN_PATH}/bin/yasm + +# A variable to which certain dependencies can add -l arguments during build.sh +export FFMPEG_EXTRA_LD_FLAGS= diff --git a/scripts/ffmpeg/build.sh b/scripts/ffmpeg/build.sh index 90f558e..077ed8f 100755 --- a/scripts/ffmpeg/build.sh +++ b/scripts/ffmpeg/build.sh @@ -18,6 +18,10 @@ do ADDITIONAL_COMPONENTS+=" --enable-$LIBARY_NAME" done +# Referencing dependencies without pkgconfig +DEP_CFLAGS="-I${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/include" +DEP_LD_FLAGS="-L${BUILD_DIR_EXTERNAL}/${ANDROID_ABI}/lib $FFMPEG_EXTRA_LD_FLAGS" + # Everything that goes below ${EXTRA_BUILD_CONFIGURATION_FLAGS} is my project-specific. # You are free to enable/disable whatever you actually need. @@ -29,7 +33,8 @@ done --sysroot=${SYSROOT_PATH} \ --cross-prefix=${CROSS_PREFIX_WITH_PATH} \ --cc=${CC} \ - --extra-cflags="-O3 -fPIC" \ + --extra-cflags="-O3 -fPIC $DEP_CFLAGS" \ + --extra-ldflags="$DEP_LD_FLAGS" \ --enable-shared \ --disable-static \ --pkg-config=$(which pkg-config) \ diff --git a/scripts/ffmpeg/download.sh b/scripts/ffmpeg/download.sh index c0d59d6..185d4a7 100755 --- a/scripts/ffmpeg/download.sh +++ b/scripts/ffmpeg/download.sh @@ -14,7 +14,7 @@ function ensureSourcesTar() { TARGET_FILE_NAME=ffmpeg-${FFMPEG_SOURCE_VALUE}.tar.bz2 curl https://www.ffmpeg.org/releases/${TARGET_FILE_NAME} --output ${TARGET_FILE_NAME} - tar xzf ${TARGET_FILE_NAME} -C . + tar xf ${TARGET_FILE_NAME} -C . rm ${TARGET_FILE_NAME} fi @@ -60,7 +60,7 @@ case ${FFMPEG_SOURCE_TYPE} in # ensureSourcesBranch ${SECOND_ARGUMENT} # ;; TAR) - echo "Using FFmpeg source archive ${FFMPEG_FALLBACK_VERSION}" + echo "Using FFmpeg source archive ${FFMPEG_SOURCE_VALUE}" ensureSourcesTar ;; esac diff --git a/scripts/libmp3lame/build.sh b/scripts/libmp3lame/build.sh new file mode 100755 index 0000000..95c3a72 --- /dev/null +++ b/scripts/libmp3lame/build.sh @@ -0,0 +1,22 @@ +./configure \ + --prefix=${BUILD_DIR_EXTERNAL}/${ANDROID_ABI} \ + --target=${TARGET} \ + --host=${TARGET} \ + --with-sysroot=${SYSROOT_PATH} \ + --disable-shared \ + --enable-static \ + --with-pic \ + --disable-analyzer-hooks \ + --disable-decoder \ + --disable-gtktest \ + --disable-frontend \ + CC=${CC} \ + LD=${LD} \ + AR=${AR} \ + RANLIB=${RANLIB} + +export FFMPEG_EXTRA_LD_FLAGS="${FFMPEG_EXTRA_LD_FLAGS} -lmp3lame" + +make clean +make -j${HOST_NPROC} +make install diff --git a/scripts/libmp3lame/download.sh b/scripts/libmp3lame/download.sh new file mode 100755 index 0000000..cff983c --- /dev/null +++ b/scripts/libmp3lame/download.sh @@ -0,0 +1,17 @@ +# Script to download Lame's source code + +# Exports SOURCES_DIR_libmp3lame - path where actual sources are stored + +LAME_VERSION=3.100 +echo "Using libmp3lame $LAME_VERSION" +LAME_SOURCES=lame-${LAME_VERSION} + +if [[ ! -d "$LAME_SOURCES" ]]; then + TARGET_FILE_NAME=lame-${LAME_VERSION}.tar.gz + + curl http://downloads.videolan.org/pub/contrib/lame/${TARGET_FILE_NAME} --output ${TARGET_FILE_NAME} + tar xf ${TARGET_FILE_NAME} -C . + rm ${TARGET_FILE_NAME} +fi + +export SOURCES_DIR_libmp3lame=$(pwd)/${LAME_SOURCES} diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index 5fa1fd1..6c109bc 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -5,7 +5,7 @@ # See the end of this file for more description EXTERNAL_LIBRARIES=() SOURCE_TYPE=TAR -SOURCE_VALUE="4.2.1" +SOURCE_VALUE=4.2.1 API_LEVEL=16 for artument in "$@" @@ -17,17 +17,17 @@ do shift ;; # Checkout the particular tag in the FFmpeg's git repository - --source-git-tag=*) - SOURCE_TYPE=GIT_TAG - SOURCE_VALUE="${artument#*=}" - shift - ;; + # --source-git-tag=*) + # SOURCE_TYPE=GIT_TAG + # SOURCE_VALUE="${artument#*=}" + # shift + # ;; # Checkout the particular branch in the FFmpeg's git repository - --source-git-branch=*) - SOURCE_TYPE=GIT_BRANCH - SOURCE_VALUE="${artument#*=}" - shift - ;; + # --source-git-branch=*) + # SOURCE_TYPE=GIT_BRANCH + # SOURCE_VALUE="${artument#*=}" + # shift + # ;; # Download the particular tar archive by its version --source-tar=*) SOURCE_TYPE=TAR @@ -43,10 +43,10 @@ do # EXTERNAL_LIBRARIES+=( "libdav1d" ) # shift # ;; - # --enable-libmp3lame) - # EXTERNAL_LIBRARIES+=( "libmp3lame" ) - # shift - # ;; + --enable-libmp3lame) + EXTERNAL_LIBRARIES+=( "libmp3lame" ) + shift + ;; *) echo "Unknown argument $artument" ;;