From 99a6f18f5f327b7060592f93260ab5e33877f96e Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Sun, 22 Mar 2020 20:52:26 +0000 Subject: [PATCH] add create xcframework bundles option to ios.sh, fixes #351 --- android.sh | 1130 ++++++----- build/ios-ffmpeg.sh | 1 + build/ios-kvazaar.sh | 2 +- build/ios-libass.sh | 2 +- build/ios-libvpx.sh | 2 +- build/ios-openh264.sh | 3 +- ios.sh | 2080 ++++++++++----------- ios/src/MobileFFmpegConfig.m | 4 + ios/test-app/manual-frameworks/.gitignore | 1 + ios/test-app/universal/.gitignore | 1 + tools/clean.sh | 5 + tools/release/ios.sh | 39 +- tvos.sh | 2016 ++++++++++---------- 13 files changed, 2601 insertions(+), 2685 deletions(-) diff --git a/android.sh b/android.sh index 0e21cf9b3..d372a3f4b 100755 --- a/android.sh +++ b/android.sh @@ -71,96 +71,96 @@ RECONF_LIBRARIES=() REBUILD_LIBRARIES=() get_mobile_ffmpeg_version() { - local MOBILE_FFMPEG_VERSION=$(grep '#define MOBILE_FFMPEG_VERSION' ${BASEDIR}/android/app/src/main/cpp/mobileffmpeg.h | grep -Eo '\".*\"' | sed -e 's/\"//g') + local MOBILE_FFMPEG_VERSION=$(grep '#define MOBILE_FFMPEG_VERSION' ${BASEDIR}/android/app/src/main/cpp/mobileffmpeg.h | grep -Eo '\".*\"' | sed -e 's/\"//g') - echo ${MOBILE_FFMPEG_VERSION} + echo ${MOBILE_FFMPEG_VERSION} } display_help() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` + COMMAND=$(echo $0 | sed -e 's/\.\///g') - echo -e "\n'"$COMMAND"' builds FFmpeg and MobileFFmpeg for Android platform. By default five Android ABIs (armeabi-v7a, armeabi-v7a-neon, arm64-v8a, x86 and x86_64) are built \ + echo -e "\n'"$COMMAND"' builds FFmpeg and MobileFFmpeg for Android platform. By default five Android ABIs (armeabi-v7a, armeabi-v7a-neon, arm64-v8a, x86 and x86_64) are built \ without any external libraries enabled. Options can be used to disable ABIs and/or enable external libraries. \ Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. \ When compilation ends an Android Archive (AAR) file is created with enabled platforms inside.\n" - echo -e "Usage: ./"$COMMAND" [OPTION]...\n" - - echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - - echo -e "Options:" - - echo -e " -h, --help\t\t\tdisplay this help and exit" - echo -e " -v, --version\t\t\tdisplay version information and exit" - echo -e " -d, --debug\t\t\tbuild with debug information" - echo -e " -s, --speed\t\t\toptimize for speed instead of size" - echo -e " -l, --lts\t\t\tbuild lts packages to support API 16+ devices" - echo -e " -f, --force\t\t\tignore warnings\n" - - echo -e "Licensing options:" - - echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" - - echo -e "Platforms:" - - echo -e " --disable-arm-v7a\t\tdo not build arm-v7a platform [yes]" - echo -e " --disable-arm-v7a-neon\tdo not build arm-v7a-neon platform [yes]" - echo -e " --disable-arm64-v8a\t\tdo not build arm64-v8a platform [yes]" - echo -e " --disable-x86\t\t\tdo not build x86 platform [yes]" - echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]\n" - - echo -e "Libraries:" - - echo -e " --full\t\t\tenables all external libraries" - echo -e " --enable-android-media-codec\tbuild with built-in Android MediaCodec support[no]" - echo -e " --enable-android-zlib\t\tbuild with built-in zlib support[no]" - echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" - echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" - echo -e " --enable-freetype\t\tbuild with freetype [no]" - echo -e " --enable-fribidi\t\tbuild with fribidi [no]" - echo -e " --enable-gmp\t\t\tbuild with gmp [no]" - echo -e " --enable-gnutls\t\tbuild with gnutls [no]" - echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" - echo -e " --enable-lame\t\t\tbuild with lame [no]" - echo -e " --enable-libaom\t\tbuild with libaom [no]" - echo -e " --enable-libass\t\tbuild with libass [no]" - echo -e " --enable-libiconv\t\tbuild with libiconv [no]" - echo -e " --enable-libilbc\t\tbuild with libilbc [no]" - echo -e " --enable-libtheora\t\tbuild with libtheora [no]" - echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" - echo -e " --enable-libvpx\t\tbuild with libvpx [no]" - echo -e " --enable-libwebp\t\tbuild with libwebp [no]" - echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" - echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" - echo -e " --enable-openh264\t\tbuild with openh264 [no]" - echo -e " --enable-opus\t\t\tbuild with opus [no]" - echo -e " --enable-sdl\t\t\tbuild with sdl [no]" - echo -e " --enable-shine\t\tbuild with shine [no]" - echo -e " --enable-snappy\t\tbuild with snappy [no]" - echo -e " --enable-soxr\t\t\tbuild with soxr [no]" - echo -e " --enable-speex\t\tbuild with speex [no]" - echo -e " --enable-tesseract\t\tbuild with tesseract [no]" - echo -e " --enable-twolame\t\tbuild with twolame [no]" - echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" - - echo -e "GPL libraries:" - - echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" - echo -e " --enable-rubberband\t\tbuild with rubber band [no]" - echo -e " --enable-x264\t\t\tbuild with x264 [no]" - echo -e " --enable-x265\t\t\tbuild with x265 [no]" - echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" - - echo -e "Advanced options:" - - echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" - echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" + echo -e "Usage: ./"$COMMAND" [OPTION]...\n" + + echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" + + echo -e "Options:" + + echo -e " -h, --help\t\t\tdisplay this help and exit" + echo -e " -v, --version\t\t\tdisplay version information and exit" + echo -e " -d, --debug\t\t\tbuild with debug information" + echo -e " -s, --speed\t\t\toptimize for speed instead of size" + echo -e " -l, --lts\t\t\tbuild lts packages to support API 16+ devices" + echo -e " -f, --force\t\t\tignore warnings\n" + + echo -e "Licensing options:" + + echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" + + echo -e "Platforms:" + + echo -e " --disable-arm-v7a\t\tdo not build arm-v7a platform [yes]" + echo -e " --disable-arm-v7a-neon\tdo not build arm-v7a-neon platform [yes]" + echo -e " --disable-arm64-v8a\t\tdo not build arm64-v8a platform [yes]" + echo -e " --disable-x86\t\t\tdo not build x86 platform [yes]" + echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]\n" + + echo -e "Libraries:" + + echo -e " --full\t\t\tenables all external libraries" + echo -e " --enable-android-media-codec\tbuild with built-in Android MediaCodec support[no]" + echo -e " --enable-android-zlib\t\tbuild with built-in zlib support[no]" + echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" + echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" + echo -e " --enable-freetype\t\tbuild with freetype [no]" + echo -e " --enable-fribidi\t\tbuild with fribidi [no]" + echo -e " --enable-gmp\t\t\tbuild with gmp [no]" + echo -e " --enable-gnutls\t\tbuild with gnutls [no]" + echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" + echo -e " --enable-lame\t\t\tbuild with lame [no]" + echo -e " --enable-libaom\t\tbuild with libaom [no]" + echo -e " --enable-libass\t\tbuild with libass [no]" + echo -e " --enable-libiconv\t\tbuild with libiconv [no]" + echo -e " --enable-libilbc\t\tbuild with libilbc [no]" + echo -e " --enable-libtheora\t\tbuild with libtheora [no]" + echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" + echo -e " --enable-libvpx\t\tbuild with libvpx [no]" + echo -e " --enable-libwebp\t\tbuild with libwebp [no]" + echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" + echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" + echo -e " --enable-openh264\t\tbuild with openh264 [no]" + echo -e " --enable-opus\t\t\tbuild with opus [no]" + echo -e " --enable-sdl\t\t\tbuild with sdl [no]" + echo -e " --enable-shine\t\tbuild with shine [no]" + echo -e " --enable-snappy\t\tbuild with snappy [no]" + echo -e " --enable-soxr\t\t\tbuild with soxr [no]" + echo -e " --enable-speex\t\tbuild with speex [no]" + echo -e " --enable-tesseract\t\tbuild with tesseract [no]" + echo -e " --enable-twolame\t\tbuild with twolame [no]" + echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" + + echo -e "GPL libraries:" + + echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" + echo -e " --enable-rubberband\t\tbuild with rubber band [no]" + echo -e " --enable-x264\t\t\tbuild with x264 [no]" + echo -e " --enable-x265\t\t\tbuild with x265 [no]" + echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" + + echo -e "Advanced options:" + + echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" + echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" } display_version() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` + COMMAND=$(echo $0 | sed -e 's/\.\///g') - echo -e "\ + echo -e "\ $COMMAND v$(get_mobile_ffmpeg_version)\n\ Copyright (c) 2018 Taner Sener\n\ License LGPLv3.0: GNU LGPL version 3 or later\n\ @@ -171,410 +171,403 @@ either version 3 of the License, or (at your option) any later version." } skip_library() { - SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") + SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") - export ${SKIP_VARIABLE}=1 + export ${SKIP_VARIABLE}=1 } no_output_redirection() { - export NO_OUTPUT_REDIRECTION=1 + export NO_OUTPUT_REDIRECTION=1 } no_workspace_cleanup_library() { - NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") + NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") - export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1 + export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1 } no_link_time_optimization() { - export NO_LINK_TIME_OPTIMIZATION=1 + export NO_LINK_TIME_OPTIMIZATION=1 } enable_debug() { - export MOBILE_FFMPEG_DEBUG="-g" + export MOBILE_FFMPEG_DEBUG="-g" - BUILD_TYPE_ID+="debug " + BUILD_TYPE_ID+="debug " } optimize_for_speed() { - export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" + export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" } enable_lts_build() { - export MOBILE_FFMPEG_LTS_BUILD="1" + export MOBILE_FFMPEG_LTS_BUILD="1" - # USING API LEVEL 16 / Android 4.1 (JELLY BEAN) - export API=16 + # USING API LEVEL 16 / Android 4.1 (JELLY BEAN) + export API=16 } reconf_library() { - local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") - local library_supported=0 - - for library in {1..44} - do - library_name=$(get_library_name $((library - 1))) - - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${RECONF_VARIABLE}=1 - RECONF_LIBRARIES+=($1) - library_supported=1 - fi - done + local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") + local library_supported=0 + + for library in {1..44}; do + library_name=$(get_library_name $((library - 1))) - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then + export ${RECONF_VARIABLE}=1 + RECONF_LIBRARIES+=($1) + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + fi } rebuild_library() { - local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") - local library_supported=0 - - for library in {1..44} - do - library_name=$(get_library_name $((library - 1))) - - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${REBUILD_VARIABLE}=1 - REBUILD_LIBRARIES+=($1) - library_supported=1 - fi - done + local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") + local library_supported=0 - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + for library in {1..44}; do + library_name=$(get_library_name $((library - 1))) + + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then + export ${REBUILD_VARIABLE}=1 + REBUILD_LIBRARIES+=($1) + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + fi } enable_library() { - set_library $1 1 + set_library $1 1 } set_library() { - case $1 in - android-media-codec) - ENABLED_LIBRARIES[LIBRARY_MEDIA_CODEC]=$2 - ;; - android-zlib) - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - chromaprint) - ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 - ;; - fontconfig) - ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - set_library "freetype" $2 - ;; - freetype) - ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "libpng" $2 - ;; - fribidi) - ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 - ;; - gmp) - ENABLED_LIBRARIES[LIBRARY_GMP]=$2 - ;; - gnutls) - ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "nettle" $2 - set_library "gmp" $2 - set_library "libiconv" $2 - ;; - kvazaar) - ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 - ;; - lame) - ENABLED_LIBRARIES[LIBRARY_LAME]=$2 - set_library "libiconv" $2 - ;; - libaom) - ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 - ;; - libass) - ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - set_library "freetype" $2 - set_library "fribidi" $2 - set_library "fontconfig" $2 - set_library "libiconv" $2 - ;; - libiconv) - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - ;; - libilbc) - ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 - ;; - libpng) - ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - libtheora) - ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - set_library "libvorbis" $2 - ;; - libvidstab) - ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 - ;; - libvorbis) - ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - ;; - libvpx) - ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 - ;; - libwebp) - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - libxml2) - ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 - set_library "libiconv" $2 - ;; - opencore-amr) - ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 - ;; - openh264) - ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 - ;; - opus) - ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 - ;; - rubberband) - ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 - ;; - sdl) - ENABLED_LIBRARIES[LIBRARY_SDL]=$2 - ;; - shine) - ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 - ;; - snappy) - ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - soxr) - ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 - ;; - speex) - ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 - ;; - tesseract) - ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 - ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - twolame) - ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ;; - wavpack) - ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 - ;; - x264) - ENABLED_LIBRARIES[LIBRARY_X264]=$2 - ;; - x265) - ENABLED_LIBRARIES[LIBRARY_X265]=$2 - ;; - xvidcore) - ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 - ;; - expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile | libuuid) - # THESE LIBRARIES ARE NOT ENABLED DIRECTLY - ;; - nettle) - ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 - set_library "gmp" $2 - ;; - tiff) - ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ;; - *) - print_unknown_library $1 - ;; - esac + case $1 in + android-media-codec) + ENABLED_LIBRARIES[LIBRARY_MEDIA_CODEC]=$2 + ;; + android-zlib) + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + chromaprint) + ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 + ;; + fontconfig) + ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + set_library "freetype" $2 + ;; + freetype) + ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "libpng" $2 + ;; + fribidi) + ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 + ;; + gmp) + ENABLED_LIBRARIES[LIBRARY_GMP]=$2 + ;; + gnutls) + ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "nettle" $2 + set_library "gmp" $2 + set_library "libiconv" $2 + ;; + kvazaar) + ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 + ;; + lame) + ENABLED_LIBRARIES[LIBRARY_LAME]=$2 + set_library "libiconv" $2 + ;; + libaom) + ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 + ;; + libass) + ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + set_library "freetype" $2 + set_library "fribidi" $2 + set_library "fontconfig" $2 + set_library "libiconv" $2 + ;; + libiconv) + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + ;; + libilbc) + ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 + ;; + libpng) + ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + libtheora) + ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + set_library "libvorbis" $2 + ;; + libvidstab) + ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 + ;; + libvorbis) + ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + ;; + libvpx) + ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 + ;; + libwebp) + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + set_library "tiff" $2 + set_library "libpng" $2 + ;; + libxml2) + ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 + set_library "libiconv" $2 + ;; + opencore-amr) + ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 + ;; + openh264) + ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 + ;; + opus) + ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 + ;; + rubberband) + ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 + ;; + sdl) + ENABLED_LIBRARIES[LIBRARY_SDL]=$2 + ;; + shine) + ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 + ;; + snappy) + ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + soxr) + ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 + ;; + speex) + ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 + ;; + tesseract) + ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 + ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "tiff" $2 + set_library "libpng" $2 + ;; + twolame) + ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ;; + wavpack) + ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 + ;; + x264) + ENABLED_LIBRARIES[LIBRARY_X264]=$2 + ;; + x265) + ENABLED_LIBRARIES[LIBRARY_X265]=$2 + ;; + xvidcore) + ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 + ;; + expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile | libuuid) + # THESE LIBRARIES ARE NOT ENABLED DIRECTLY + ;; + nettle) + ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 + set_library "gmp" $2 + ;; + tiff) + ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ;; + *) + print_unknown_library $1 + ;; + esac } disable_arch() { - set_arch $1 0 + set_arch $1 0 } set_arch() { - case $1 in - arm-v7a) - ENABLED_ARCHITECTURES[ARCH_ARM_V7A]=$2 - ;; - arm-v7a-neon) - ENABLED_ARCHITECTURES[ARCH_ARM_V7A_NEON]=$2 - ;; - arm64-v8a) - ENABLED_ARCHITECTURES[ARCH_ARM64_V8A]=$2 - ;; - x86) - ENABLED_ARCHITECTURES[ARCH_X86]=$2 - ;; - x86-64) - ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 - ;; - *) - print_unknown_platform $1 - ;; - esac + case $1 in + arm-v7a) + ENABLED_ARCHITECTURES[ARCH_ARM_V7A]=$2 + ;; + arm-v7a-neon) + ENABLED_ARCHITECTURES[ARCH_ARM_V7A_NEON]=$2 + ;; + arm64-v8a) + ENABLED_ARCHITECTURES[ARCH_ARM64_V8A]=$2 + ;; + x86) + ENABLED_ARCHITECTURES[ARCH_X86]=$2 + ;; + x86-64) + ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 + ;; + *) + print_unknown_platform $1 + ;; + esac } print_unknown_option() { - echo -e "Unknown option \"$1\".\nSee $0 --help for available options." - exit 1 + echo -e "Unknown option \"$1\".\nSee $0 --help for available options." + exit 1 } print_unknown_library() { - echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." - exit 1 + echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." + exit 1 } print_unknown_platform() { - echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." - exit 1 + echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." + exit 1 } print_enabled_architectures() { - echo -n "Architectures: " - - let enabled=0; - for print_arch in {0..4} - do - if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_arch_name $print_arch) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Architectures: " + + let enabled=0 + for print_arch in {0..4}; do + if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_arch_name $print_arch) + enabled=$((${enabled} + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_enabled_libraries() { - echo -n "Libraries: " - - let enabled=0; - - # FIRST BUILT-IN LIBRARIES - for library in {44..45} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - # THEN EXTERNAL LIBRARIES - for library in {0..32} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Libraries: " + + let enabled=0 + + # FIRST BUILT-IN LIBRARIES + for library in {44..45}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_library_name $library) + enabled=$((${enabled} + 1)) + fi + done + + # THEN EXTERNAL LIBRARIES + for library in {0..32}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_library_name $library) + enabled=$((${enabled} + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_reconfigure_requested_libraries() { - local counter=0; + local counter=0 - for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Reconfigure: " - else - echo -n ", " - fi + for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Reconfigure: " + else + echo -n ", " + fi - echo -n ${RECONF_LIBRARY} + echo -n ${RECONF_LIBRARY} - counter=$((${counter} + 1)); - done + counter=$((${counter} + 1)) + done - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } print_rebuild_requested_libraries() { - local counter=0; + local counter=0 - for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Rebuild: " - else - echo -n ", " - fi + for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Rebuild: " + else + echo -n ", " + fi - echo -n ${REBUILD_LIBRARY} + echo -n ${REBUILD_LIBRARY} - counter=$((${counter} + 1)); - done + counter=$((${counter} + 1)) + done - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } build_application_mk() { - if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - local LTS_BUILD_FLAG="-DMOBILE_FFMPEG_LTS " - fi + if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then + local LTS_BUILD_FLAG="-DMOBILE_FFMPEG_LTS " + fi - if [[ ${ENABLED_LIBRARIES[$LIBRARY_X265]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_TESSERACT]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_OPENH264]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_SNAPPY]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_RUBBERBAND]} -eq 1 ]]; then - local APP_STL="c++_shared" - else - local APP_STL="none" + if [[ ${ENABLED_LIBRARIES[$LIBRARY_X265]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_TESSERACT]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_OPENH264]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_SNAPPY]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_RUBBERBAND]} -eq 1 ]]; then + local APP_STL="c++_shared" + else + local APP_STL="none" - ${SED_INLINE} 's/c++_shared //g' ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 - fi + ${SED_INLINE} 's/c++_shared //g' ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 + fi - local BUILD_DATE="-DMOBILE_FFMPEG_BUILD_DATE=$(date +%Y%m%d 2>>${BASEDIR}/build.log)" + local BUILD_DATE="-DMOBILE_FFMPEG_BUILD_DATE=$(date +%Y%m%d 2>>${BASEDIR}/build.log)" - rm -f ${BASEDIR}/android/jni/Application.mk + rm -f ${BASEDIR}/android/jni/Application.mk - cat > "${BASEDIR}/android/jni/Application.mk" << EOF + cat >"${BASEDIR}/android/jni/Application.mk" <>${BASEDIR}/build.log) -while [ ! $# -eq 0 ] -do - - case $1 in - -h | --help) - DISPLAY_HELP="1" - ;; - -v | --version) - display_version - exit 0 - ;; - --skip-*) - SKIP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - skip_library ${SKIP_LIBRARY} - ;; - --no-output-redirection) - no_output_redirection - ;; - --no-workspace-cleanup-*) - NO_WORKSPACE_CLEANUP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g'` - - no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY} - ;; - --no-link-time-optimization) - no_link_time_optimization - ;; - -d | --debug) - enable_debug - ;; - -s | --speed) - optimize_for_speed - ;; - -l | --lts) - BUILD_LTS="1" - ;; - -f | --force) - BUILD_FORCE="1" - ;; - --reconf-*) - CONF_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - reconf_library ${CONF_LIBRARY} - ;; - --rebuild-*) - BUILD_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - rebuild_library ${BUILD_LIBRARY} - ;; - --full) - for library in {0..45} - do - if [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]] && [[ $library -ne 22 ]]; then - enable_library $(get_library_name $library) - fi - done - ;; - --enable-gpl) - GPL_ENABLED="yes" - ;; - --enable-*) - ENABLED_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - enable_library ${ENABLED_LIBRARY} - ;; - --disable-*) - DISABLED_ARCH=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - disable_arch ${DISABLED_ARCH} - ;; - *) - print_unknown_option $1 - ;; - esac - shift -done; +while [ ! $# -eq 0 ]; do + + case $1 in + -h | --help) + DISPLAY_HELP="1" + ;; + -v | --version) + display_version + exit 0 + ;; + --skip-*) + SKIP_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + skip_library ${SKIP_LIBRARY} + ;; + --no-output-redirection) + no_output_redirection + ;; + --no-workspace-cleanup-*) + NO_WORKSPACE_CLEANUP_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g') + + no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY} + ;; + --no-link-time-optimization) + no_link_time_optimization + ;; + -d | --debug) + enable_debug + ;; + -s | --speed) + optimize_for_speed + ;; + -l | --lts) + BUILD_LTS="1" + ;; + -f | --force) + BUILD_FORCE="1" + ;; + --reconf-*) + CONF_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + reconf_library ${CONF_LIBRARY} + ;; + --rebuild-*) + BUILD_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + rebuild_library ${BUILD_LIBRARY} + ;; + --full) + for library in {0..45}; do + if [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]] && [[ $library -ne 22 ]]; then + enable_library $(get_library_name $library) + fi + done + ;; + --enable-gpl) + GPL_ENABLED="yes" + ;; + --enable-*) + ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + enable_library ${ENABLED_LIBRARY} + ;; + --disable-*) + DISABLED_ARCH=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + disable_arch ${DISABLED_ARCH} + ;; + *) + print_unknown_option $1 + ;; + esac + shift +done # DETECT BUILD TYPE rm -f ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 rm -f ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1 if [[ ! -z ${BUILD_LTS} ]]; then - enable_lts_build - BUILD_TYPE_ID+="LTS " + enable_lts_build + BUILD_TYPE_ID+="LTS " - cp ${BASEDIR}/tools/ndk/Android.lts.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/tools/release/android/build.lts.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/tools/ndk/Android.lts.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/tools/release/android/build.lts.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1 else - cp ${BASEDIR}/tools/ndk/Android.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/tools/release/android/build.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/tools/ndk/Android.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/tools/release/android/build.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1 - if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM_V7A}]} -eq 1 ]]; then - echo -e "INFO: Disabled arm-v7a architecture which is not included in Main releases.\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "arm-v7a" - fi + if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM_V7A}]} -eq 1 ]]; then + echo -e "INFO: Disabled arm-v7a architecture which is not included in Main releases.\n" 1>>${BASEDIR}/build.log 2>&1 + disable_arch "arm-v7a" + fi fi if [[ ! -z ${DISPLAY_HELP} ]]; then - display_help - exit 0 + display_help + exit 0 fi if [[ -z ${ANDROID_NDK_ROOT} ]]; then - echo "ANDROID_NDK_ROOT not defined" - exit 1 + echo "ANDROID_NDK_ROOT not defined" + exit 1 fi if [[ -z ${ANDROID_HOME} ]]; then - echo "ANDROID_HOME not defined" - exit 1 + echo "ANDROID_HOME not defined" + exit 1 fi echo -e "\nBuilding mobile-ffmpeg ${BUILD_TYPE_ID}library for Android\n" echo -e -n "INFO: Building mobile-ffmpeg ${BUILD_VERSION} ${BUILD_TYPE_ID}library for Android: " 1>>${BASEDIR}/build.log 2>&1 -echo -e `date` 1>>${BASEDIR}/build.log 2>&1 +echo -e $(date) 1>>${BASEDIR}/build.log 2>&1 # PERFORM THIS CHECK ONLY ON LTS if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]] && [[ ${ENABLED_ARCHITECTURES[0]} -eq 0 ]] && [[ ${ENABLED_ARCHITECTURES[1]} -eq 1 ]]; then - ENABLED_ARCHITECTURES[ARCH_ARM_V7A]=1 + ENABLED_ARCHITECTURES[ARCH_ARM_V7A]=1 - echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n" - echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n" 1>>${BASEDIR}/build.log 2>&1 + echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n" + echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n" 1>>${BASEDIR}/build.log 2>&1 fi print_enabled_architectures @@ -736,54 +727,51 @@ print_reconfigure_requested_libraries print_rebuild_requested_libraries # CHECKING GPL LIBRARIES -for gpl_library in {18,19,20,21,22} -do - if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then - library_name=$(get_library_name ${gpl_library}) - - if [ ${GPL_ENABLED} != "yes" ]; then - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - else - DOWNLOAD_RESULT=$(download_gpl_library_source ${library_name}) - if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then - echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" - echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - fi - fi +for gpl_library in {18,19,20,21,22}; do + if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then + library_name=$(get_library_name ${gpl_library}) + + if [ ${GPL_ENABLED} != "yes" ]; then + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>${BASEDIR}/build.log 2>&1 + exit 1 + else + DOWNLOAD_RESULT=$(download_gpl_library_source ${library_name}) + if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then + echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" + echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>${BASEDIR}/build.log 2>&1 + exit 1 + fi fi + fi done # SAVE API VALUE -export ORIGINAL_API=${API}; - -for run_arch in {0..4} -do - if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then - if [[ ( ${run_arch} -eq ${ARCH_ARM64_V8A} || ${run_arch} -eq ${ARCH_X86_64} ) && ${API} < 21 ]] ; then - - # 64 bit ABIs supported after API 21 - export API=21 - else - export API=${ORIGINAL_API} - fi - - export ARCH=$(get_arch_name $run_arch) - export TOOLCHAIN=$(get_toolchain) - export TOOLCHAIN_ARCH=$(get_toolchain_arch) - - . ${BASEDIR}/build/main-android.sh "${ENABLED_LIBRARIES[@]}" || exit 1 - - # CLEAR FLAGS - for library in {1..46} - do - library_name=$(get_library_name $((library - 1))) - unset $(echo "OK_${library_name}" | sed "s/\-/\_/g") - unset $(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g") - done +export ORIGINAL_API=${API} + +for run_arch in {0..4}; do + if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then + if [[ (${run_arch} -eq ${ARCH_ARM64_V8A} || ${run_arch} -eq ${ARCH_X86_64}) && ${API} < 21 ]]; then + + # 64 bit ABIs supported after API 21 + export API=21 + else + export API=${ORIGINAL_API} fi + + export ARCH=$(get_arch_name $run_arch) + export TOOLCHAIN=$(get_toolchain) + export TOOLCHAIN_ARCH=$(get_toolchain_arch) + + . ${BASEDIR}/build/main-android.sh "${ENABLED_LIBRARIES[@]}" || exit 1 + + # CLEAR FLAGS + for library in {1..46}; do + library_name=$(get_library_name $((library - 1))) + unset $(echo "OK_${library_name}" | sed "s/\-/\_/g") + unset $(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g") + done + fi done export API=${ORIGINAL_API} @@ -791,64 +779,64 @@ export API=${ORIGINAL_API} rm -f ${BASEDIR}/android/build/.neon 1>>${BASEDIR}/build.log 2>&1 ANDROID_ARCHITECTURES="" if [[ ${ENABLED_ARCHITECTURES[1]} -eq 1 ]]; then - ANDROID_ARCHITECTURES+="$(get_android_arch 0) " - mkdir -p ${BASEDIR}/android/build 1>>${BASEDIR}/build.log 2>&1 - cat > "${BASEDIR}/android/build/.neon" << EOF + ANDROID_ARCHITECTURES+="$(get_android_arch 0) " + mkdir -p ${BASEDIR}/android/build 1>>${BASEDIR}/build.log 2>&1 + cat >"${BASEDIR}/android/build/.neon" <>${BASEDIR}/build.log 2>&1 + # BUILDING ANDROID ARCHIVE LIBRARY + rm -rf ${BASEDIR}/android/libs 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_AAR} 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${MOBILE_FFMPEG_AAR} 1>>${BASEDIR}/build.log 2>&1 - cd ${BASEDIR}/android 1>>${BASEDIR}/build.log 2>&1 + cd ${BASEDIR}/android 1>>${BASEDIR}/build.log 2>&1 - ${ANDROID_NDK_ROOT}/ndk-build -B 1>>${BASEDIR}/build.log 2>&1 + ${ANDROID_NDK_ROOT}/ndk-build -B 1>>${BASEDIR}/build.log 2>&1 - if [ $? -eq 0 ]; then - echo "ok" - else - echo "failed" - exit 1 - fi + if [ $? -eq 0 ]; then + echo "ok" + else + echo "failed" + exit 1 + fi - echo -e -n "\n\nCreating Android archive under prebuilt/android-aar: " + echo -e -n "\n\nCreating Android archive under prebuilt/android-aar: " - ./gradlew app:clean app:assembleRelease app:testReleaseUnitTest 1>>${BASEDIR}/build.log 2>&1 + ./gradlew app:clean app:assembleRelease app:testReleaseUnitTest 1>>${BASEDIR}/build.log 2>&1 - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - cp ${BASEDIR}/android/app/build/outputs/aar/mobile-ffmpeg-release.aar ${MOBILE_FFMPEG_AAR}/mobile-ffmpeg.aar 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/android/app/build/outputs/aar/mobile-ffmpeg-release.aar ${MOBILE_FFMPEG_AAR}/mobile-ffmpeg.aar 1>>${BASEDIR}/build.log 2>&1 - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - echo -e "Created mobile-ffmpeg Android archive successfully.\n" 1>>${BASEDIR}/build.log 2>&1 + echo -e "Created mobile-ffmpeg Android archive successfully.\n" 1>>${BASEDIR}/build.log 2>&1 - echo -e "ok\n" + echo -e "ok\n" fi diff --git a/build/ios-ffmpeg.sh b/build/ios-ffmpeg.sh index 6e88762aa..da6ede79b 100755 --- a/build/ios-ffmpeg.sh +++ b/build/ios-ffmpeg.sh @@ -79,6 +79,7 @@ case ${ARCH} in BITCODE_FLAGS="" ;; x86-64) + ARCH_OPTIONS="--disable-asm" TARGET_CPU="x86_64" TARGET_ARCH="x86_64" NEON_FLAG=" --disable-neon" diff --git a/build/ios-kvazaar.sh b/build/ios-kvazaar.sh index a38659d24..8957a2e8e 100755 --- a/build/ios-kvazaar.sh +++ b/build/ios-kvazaar.sh @@ -37,7 +37,7 @@ case ${ARCH} in i386) BUILD_HOST="x86-apple-darwin" ;; - x86-64-mac-catalyst) + x86-64 | x86-64-mac-catalyst) ARCH_OPTIONS="--disable-asm" BUILD_HOST=$(get_build_host) ;; diff --git a/build/ios-libass.sh b/build/ios-libass.sh index e149a9361..c1968c4d5 100755 --- a/build/ios-libass.sh +++ b/build/ios-libass.sh @@ -40,7 +40,7 @@ export PKG_CONFIG_LIBDIR=${INSTALL_PKG_CONFIG_DIR} ARCH_OPTIONS="" case ${ARCH} in - x86-64-mac-catalyst) + x86-64 | x86-64-mac-catalyst) ARCH_OPTIONS="--disable-asm" ;; *) diff --git a/build/ios-libvpx.sh b/build/ios-libvpx.sh index 759b632f9..2cd505a67 100755 --- a/build/ios-libvpx.sh +++ b/build/ios-libvpx.sh @@ -68,7 +68,7 @@ case ${ARCH} in ;; x86-64) TARGET="x86_64-iphonesimulator-gcc" - ASM_FLAGS="--enable-runtime-cpu-detect --disable-avx512" + ASM_FLAGS="--enable-runtime-cpu-detect --disable-avx512 --disable-sse --disable-sse2 --disable-mmx" ;; x86-64-mac-catalyst) TARGET="x86_64-macosx-gcc" diff --git a/build/ios-openh264.sh b/build/ios-openh264.sh index 8bc8ed328..11aea354f 100755 --- a/build/ios-openh264.sh +++ b/build/ios-openh264.sh @@ -56,13 +56,12 @@ esac cd ${BASEDIR}/src/${LIB_NAME} || exit 1 -# MAKE SURE THAT ASM IS ENABLED FOR ALL IOS ARCHITECTURES +# MAKE SURE THAT ASM IS ENABLED FOR ALL IOS ARCHITECTURES - EXCEPT x86-64 ${SED_INLINE} 's/arm64 aarch64/arm64% aarch64/g' ${BASEDIR}/src/${LIB_NAME}/build/arch.mk ${SED_INLINE} 's/%86 x86_64,/%86 x86_64 x86-64,/g' ${BASEDIR}/src/${LIB_NAME}/build/arch.mk ${SED_INLINE} 's/filter-out arm64,/filter-out arm64%,/g' ${BASEDIR}/src/${LIB_NAME}/build/arch.mk ${SED_INLINE} 's/CFLAGS += -DHAVE_NEON/#CFLAGS += -DHAVE_NEON/g' ${BASEDIR}/src/${LIB_NAME}/build/arch.mk ${SED_INLINE} 's/ifeq (\$(ASM_ARCH), arm64)/ifneq (\$(filter arm64%, \$(ASM_ARCH)),)/g' ${BASEDIR}/src/${LIB_NAME}/codec/common/targets.mk -${SED_INLINE} 's/ifeq (\$(ASM_ARCH), x86)/ifneq (\$(filter %86 x86-64, \$(ASM_ARCH)),)/g' ${BASEDIR}/src/${LIB_NAME}/codec/common/targets.mk ${SED_INLINE} 's/ifeq (\$(ASM_ARCH), arm)/ifneq (\$(filter armv%, \$(ASM_ARCH)),)/g' ${BASEDIR}/src/${LIB_NAME}/codec/common/targets.mk make clean 2>/dev/null 1>/dev/null diff --git a/ios.sh b/ios.sh index 639bab1a6..66e7d6430 100755 --- a/ios.sh +++ b/ios.sh @@ -75,119 +75,114 @@ REBUILD_LIBRARIES=() # CHECKING IF XCODE IS INSTALLED if ! [ -x "$(command -v xcrun)" ]; then - echo -e "\n(*) xcrun command not found. Please check your Xcode installation.\n" - exit 1 + echo -e "\n(*) xcrun command not found. Please check your Xcode installation.\n" + exit 1 fi # USE 12.1 AS DEFAULT IOS_MIN_VERSION export IOS_MIN_VERSION=12.1 get_mobile_ffmpeg_version() { - local MOBILE_FFMPEG_VERSION=$(grep 'const MOBILE_FFMPEG_VERSION' ${BASEDIR}/ios/src/MobileFFmpeg.m | grep -Eo '\".*\"' | sed -e 's/\"//g') + local MOBILE_FFMPEG_VERSION=$(grep 'const MOBILE_FFMPEG_VERSION' "${BASEDIR}/ios/src/MobileFFmpeg.m" | grep -Eo '\".*\"' | sed -e 's/\"//g') - if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - echo "${MOBILE_FFMPEG_VERSION}" - else - echo "${MOBILE_FFMPEG_VERSION}.LTS" - fi + if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then + echo "${MOBILE_FFMPEG_VERSION}" + else + echo "${MOBILE_FFMPEG_VERSION}.LTS" + fi } display_help() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` - - if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - echo -e "\n'"$COMMAND"' builds FFmpeg and MobileFFmpeg for iOS platform. By default seven architectures (armv7, armv7s, arm64, arm64e, i386, x86_64 and x86_64 for Mac Catalyst) are built without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends universal fat binaries and iOS frameworks are created with enabled architectures inside.\n" - else - echo -e "\n'"$COMMAND"' builds FFmpeg and MobileFFmpeg for iOS platform. By default five architectures (armv7, armv7s, arm64, i386 and x86_64) are built without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends universal fat binaries and iOS frameworks are created with enabled architectures inside.\n" - fi - - echo -e "Usage: ./"$COMMAND" [OPTION]...\n" - - echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - - echo -e "Options:" - - echo -e " -h, --help\t\t\tdisplay this help and exit" - echo -e " -v, --version\t\t\tdisplay version information and exit" - echo -e " -d, --debug\t\t\tbuild with debug information" - echo -e " -s, --speed\t\t\toptimize for speed instead of size" - echo -e " -l, --lts\t\t\tbuild lts packages to support sdk 9.3+ devices, does not include arm64e architecture" - echo -e " -f, --force\t\t\tignore warnings\n" - - echo -e "Licensing options:" - - echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" - - echo -e "Platforms:" - - echo -e " --disable-armv7\t\tdo not build armv7 platform [yes]" - echo -e " --disable-armv7s\t\tdo not build armv7s platform [yes]" - echo -e " --disable-arm64\t\tdo not build arm64 platform [yes]" - if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - echo -e " --disable-arm64e\t\tdo not build arm64e platform [yes]" - fi - echo -e " --disable-i386\t\tdo not build i386 platform [yes]" - echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]" - echo -e " --disable-x86-64-mac-catalyst\tdo not build x86-64-mac-catalyst platform [yes]\n" - - echo -e "Libraries:" - - echo -e " --full\t\t\tenables all non-GPL external libraries" - echo -e " --enable-ios-audiotoolbox\tbuild with built-in Apple AudioToolbox support[no]" - echo -e " --enable-ios-avfoundation\tbuild with built-in Apple AVFoundation support[no]" - echo -e " --enable-ios-coreimage\tbuild with built-in Apple CoreImage support[no]" - echo -e " --enable-ios-bzip2\t\tbuild with built-in bzip2 support[no]" - echo -e " --enable-ios-videotoolbox\tbuild with built-in Apple VideoToolbox support[no]" - echo -e " --enable-ios-zlib\t\tbuild with built-in zlib [no]" - echo -e " --enable-ios-libiconv\t\tbuild with built-in libiconv [no]" - echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" - echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" - echo -e " --enable-freetype\t\tbuild with freetype [no]" - echo -e " --enable-fribidi\t\tbuild with fribidi [no]" - echo -e " --enable-gmp\t\t\tbuild with gmp [no]" - echo -e " --enable-gnutls\t\tbuild with gnutls [no]" - echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" - echo -e " --enable-lame\t\t\tbuild with lame [no]" - echo -e " --enable-libaom\t\tbuild with libaom [no]" - echo -e " --enable-libass\t\tbuild with libass [no]" - echo -e " --enable-libilbc\t\tbuild with libilbc [no]" - echo -e " --enable-libtheora\t\tbuild with libtheora [no]" - echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" - echo -e " --enable-libvpx\t\tbuild with libvpx [no]" - echo -e " --enable-libwebp\t\tbuild with libwebp [no]" - echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" - echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" - echo -e " --enable-openh264\t\tbuild with openh264 [no]" - echo -e " --enable-opus\t\t\tbuild with opus [no]" - echo -e " --enable-sdl\t\t\tbuild with sdl [no]" - echo -e " --enable-shine\t\tbuild with shine [no]" - echo -e " --enable-snappy\t\tbuild with snappy [no]" - echo -e " --enable-soxr\t\t\tbuild with soxr [no]" - echo -e " --enable-speex\t\tbuild with speex [no]" - echo -e " --enable-tesseract\t\tbuild with tesseract [no]" - echo -e " --enable-twolame\t\tbuild with twolame [no]" - echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" - - echo -e "GPL libraries:" - - echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" - echo -e " --enable-rubberband\t\tbuild with rubber band [no]" - echo -e " --enable-x264\t\t\tbuild with x264 [no]" - echo -e " --enable-x265\t\t\tbuild with x265 [no]" - echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" - - echo -e "Advanced options:" - - echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" - echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" + COMMAND=$(echo "$0" | sed -e 's/\.\///g') + + echo -e "\n$COMMAND builds FFmpeg and MobileFFmpeg for iOS platform. By default seven architectures (armv7, armv7s, arm64, arm64e, i386, x86-64 and x86-64-mac-catalyst) are built without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends, library bundles are created under the prebuilt folder. By default framework bundles and universal fat binaries are created. If --xcframework option is provided then xcframework bundles are created.\n" + + echo -e "Usage: ./$COMMAND [OPTION]...\n" + + echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" + + echo -e "Options:" + + echo -e " -h, --help\t\t\tdisplay this help and exit" + echo -e " -v, --version\t\t\tdisplay version information and exit" + echo -e " -d, --debug\t\t\tbuild with debug information" + echo -e " -s, --speed\t\t\toptimize for speed instead of size" + echo -e " -l, --lts\t\t\tbuild lts packages to support sdk 9.3+ devices" + echo -e " -x, --xcframework\t\tbuild xcframework bundles instead of framework bundles and universal libraries" + echo -e " -f, --force\t\t\tignore warnings and build with given options\n" + + echo -e "Licensing options:" + + echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" + + echo -e "Platforms:" + + echo -e " --disable-armv7\t\tdo not build armv7 platform [yes]" + echo -e " --disable-armv7s\t\tdo not build armv7s platform [yes]" + echo -e " --disable-arm64\t\tdo not build arm64 platform [yes]" + echo -e " --disable-arm64e\t\tdo not build arm64e platform [yes]" + echo -e " --disable-i386\t\tdo not build i386 platform [yes]" + echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]" + echo -e " --disable-x86-64-mac-catalyst\tdo not build x86-64-mac-catalyst platform [yes]\n" + + echo -e "Libraries:" + + echo -e " --full\t\t\tenables all non-GPL external libraries" + echo -e " --enable-ios-audiotoolbox\tbuild with built-in Apple AudioToolbox support[no]" + echo -e " --enable-ios-avfoundation\tbuild with built-in Apple AVFoundation support[no]" + echo -e " --enable-ios-coreimage\tbuild with built-in Apple CoreImage support[no]" + echo -e " --enable-ios-bzip2\t\tbuild with built-in bzip2 support[no]" + echo -e " --enable-ios-videotoolbox\tbuild with built-in Apple VideoToolbox support[no]" + echo -e " --enable-ios-zlib\t\tbuild with built-in zlib [no]" + echo -e " --enable-ios-libiconv\t\tbuild with built-in libiconv [no]" + echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" + echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" + echo -e " --enable-freetype\t\tbuild with freetype [no]" + echo -e " --enable-fribidi\t\tbuild with fribidi [no]" + echo -e " --enable-gmp\t\t\tbuild with gmp [no]" + echo -e " --enable-gnutls\t\tbuild with gnutls [no]" + echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" + echo -e " --enable-lame\t\t\tbuild with lame [no]" + echo -e " --enable-libaom\t\tbuild with libaom [no]" + echo -e " --enable-libass\t\tbuild with libass [no]" + echo -e " --enable-libilbc\t\tbuild with libilbc [no]" + echo -e " --enable-libtheora\t\tbuild with libtheora [no]" + echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" + echo -e " --enable-libvpx\t\tbuild with libvpx [no]" + echo -e " --enable-libwebp\t\tbuild with libwebp [no]" + echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" + echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" + echo -e " --enable-openh264\t\tbuild with openh264 [no]" + echo -e " --enable-opus\t\t\tbuild with opus [no]" + echo -e " --enable-sdl\t\t\tbuild with sdl [no]" + echo -e " --enable-shine\t\tbuild with shine [no]" + echo -e " --enable-snappy\t\tbuild with snappy [no]" + echo -e " --enable-soxr\t\t\tbuild with soxr [no]" + echo -e " --enable-speex\t\tbuild with speex [no]" + echo -e " --enable-tesseract\t\tbuild with tesseract [no]" + echo -e " --enable-twolame\t\tbuild with twolame [no]" + echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" + + echo -e "GPL libraries:" + + echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" + echo -e " --enable-rubberband\t\tbuild with rubber band [no]" + echo -e " --enable-x264\t\t\tbuild with x264 [no]" + echo -e " --enable-x265\t\t\tbuild with x265 [no]" + echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" + + echo -e "Advanced options:" + + echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" + echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" } display_version() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` + local COMMAND=$(echo "$0" | sed -e 's/\.\///g') - echo -e "\ + echo -e "\ $COMMAND v$(get_mobile_ffmpeg_version)\n\ -Copyright (c) 2018 Taner Sener\n\ +Copyright (c) 2018-2020 Taner Sener\n\ License LGPLv3.0: GNU LGPL version 3 or later\n\ \n\ This is free software: you can redistribute it and/or modify it under the terms of the \ @@ -196,420 +191,410 @@ either version 3 of the License, or (at your option) any later version." } skip_library() { - SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") + SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") - export ${SKIP_VARIABLE}=1 + export "${SKIP_VARIABLE}"=1 } no_output_redirection() { - export NO_OUTPUT_REDIRECTION=1 + export NO_OUTPUT_REDIRECTION=1 } no_workspace_cleanup_library() { - NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") + NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") - export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1 + export "${NO_WORKSPACE_CLEANUP_VARIABLE}"=1 } enable_debug() { - export MOBILE_FFMPEG_DEBUG="-g" + export MOBILE_FFMPEG_DEBUG="-g" - BUILD_TYPE_ID+="debug " + BUILD_TYPE_ID+="debug " } optimize_for_speed() { - export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" + export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" } enable_lts_build() { - export MOBILE_FFMPEG_LTS_BUILD="1" + export MOBILE_FFMPEG_LTS_BUILD="1" - # XCODE 7.3 HAS IOS SDK 9.3 - export IOS_MIN_VERSION=9.3 - - disable_arch "arm64e" - disable_arch "x86-64-mac-catalyst" + # XCODE 7.3 HAS IOS SDK 9.3 + export IOS_MIN_VERSION=9.3 } reconf_library() { - local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") - local library_supported=0 + local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") + local library_supported=0 - for library in {1..42} - do - library_name=$(get_library_name $((library - 1))) - - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${RECONF_VARIABLE}=1 - RECONF_LIBRARIES+=($1) - library_supported=1 - fi - done + for library in {1..42}; do + library_name=$(get_library_name $((library - 1))) - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == "$1" ]]; then + export "${RECONF_VARIABLE}"=1 + RECONF_LIBRARIES+=("$1") + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>"${BASEDIR}/build.log" 2>&1 + fi } rebuild_library() { - local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") - local library_supported=0 - - for library in {1..42} - do - library_name=$(get_library_name $((library - 1))) + local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") + local library_supported=0 - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${REBUILD_VARIABLE}=1 - REBUILD_LIBRARIES+=($1) - library_supported=1 - fi - done + for library in {1..42}; do + library_name=$(get_library_name $((library - 1))) - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == "$1" ]]; then + export "${REBUILD_VARIABLE}"=1 + REBUILD_LIBRARIES+=("$1") + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>"${BASEDIR}/build.log" 2>&1 + fi } enable_library() { - set_library $1 1 + set_library "$1" 1 } set_library() { - case $1 in - ios-zlib) - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - ios-audiotoolbox) - ENABLED_LIBRARIES[LIBRARY_AUDIOTOOLBOX]=$2 - ;; - ios-avfoundation) - ENABLED_LIBRARIES[LIBRARY_AVFOUNDATION]=$2 - ;; - ios-coreimage) - ENABLED_LIBRARIES[LIBRARY_COREIMAGE]=$2 - ;; - ios-bzip2) - ENABLED_LIBRARIES[LIBRARY_BZIP2]=$2 - ;; - ios-videotoolbox) - ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=$2 - ;; - ios-libiconv) - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - ;; - ios-libuuid) - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ;; - chromaprint) - ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 - ;; - fontconfig) - ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - set_library "freetype" $2 - ;; - freetype) - ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "libpng" $2 - ;; - fribidi) - ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 - ;; - gmp) - ENABLED_LIBRARIES[LIBRARY_GMP]=$2 - ;; - gnutls) - ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "nettle" $2 - set_library "gmp" $2 - set_library "ios-libiconv" $2 - ;; - kvazaar) - ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 - ;; - lame) - ENABLED_LIBRARIES[LIBRARY_LAME]=$2 - set_library "ios-libiconv" $2 - ;; - libaom) - ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 - ;; - libass) - ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - set_library "freetype" $2 - set_library "fribidi" $2 - set_library "fontconfig" $2 - set_library "ios-libiconv" $2 - ;; - libilbc) - ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 - ;; - libpng) - ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - libtheora) - ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - set_library "libvorbis" $2 - ;; - libvidstab) - ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 - ;; - libvorbis) - ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - ;; - libvpx) - ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 - ;; - libwebp) - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - libxml2) - ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 - set_library "ios-libiconv" $2 - ;; - opencore-amr) - ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 - ;; - openh264) - ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 - ;; - opus) - ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 - ;; - rubberband) - ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 - ;; - sdl) - ENABLED_LIBRARIES[LIBRARY_SDL]=$2 - ;; - shine) - ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 - ;; - snappy) - ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - soxr) - ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 - ;; - speex) - ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 - ;; - tesseract) - ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 - ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - twolame) - ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ;; - wavpack) - ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 - ;; - x264) - ENABLED_LIBRARIES[LIBRARY_X264]=$2 - ;; - x265) - ENABLED_LIBRARIES[LIBRARY_X265]=$2 - ;; - xvidcore) - ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 - ;; - expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile) - # THESE LIBRARIES ARE NOT ENABLED DIRECTLY - ;; - nettle) - ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 - set_library "gmp" $2 - ;; - tiff) - ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ;; - *) - print_unknown_library $1 - ;; - esac + case $1 in + ios-zlib) + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + ios-audiotoolbox) + ENABLED_LIBRARIES[LIBRARY_AUDIOTOOLBOX]=$2 + ;; + ios-avfoundation) + ENABLED_LIBRARIES[LIBRARY_AVFOUNDATION]=$2 + ;; + ios-coreimage) + ENABLED_LIBRARIES[LIBRARY_COREIMAGE]=$2 + ;; + ios-bzip2) + ENABLED_LIBRARIES[LIBRARY_BZIP2]=$2 + ;; + ios-videotoolbox) + ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=$2 + ;; + ios-libiconv) + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + ;; + ios-libuuid) + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ;; + chromaprint) + ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 + ;; + fontconfig) + ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + set_library "freetype" "$2" + ;; + freetype) + ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "libpng" "$2" + ;; + fribidi) + ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 + ;; + gmp) + ENABLED_LIBRARIES[LIBRARY_GMP]=$2 + ;; + gnutls) + ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "nettle" "$2" + set_library "gmp" "$2" + set_library "ios-libiconv" "$2" + ;; + kvazaar) + ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 + ;; + lame) + ENABLED_LIBRARIES[LIBRARY_LAME]=$2 + set_library "ios-libiconv" "$2" + ;; + libaom) + ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 + ;; + libass) + ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + set_library "freetype" "$2" + set_library "fribidi" "$2" + set_library "fontconfig" "$2" + set_library "ios-libiconv" "$2" + ;; + libilbc) + ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 + ;; + libpng) + ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + libtheora) + ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + set_library "libvorbis" "$2" + ;; + libvidstab) + ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 + ;; + libvorbis) + ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + ;; + libvpx) + ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 + ;; + libwebp) + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + set_library "tiff" "$2" + set_library "libpng" "$2" + ;; + libxml2) + ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 + set_library "ios-libiconv" "$2" + ;; + opencore-amr) + ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 + ;; + openh264) + ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 + ;; + opus) + ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 + ;; + rubberband) + ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 + ;; + sdl) + ENABLED_LIBRARIES[LIBRARY_SDL]=$2 + ;; + shine) + ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 + ;; + snappy) + ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + soxr) + ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 + ;; + speex) + ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 + ;; + tesseract) + ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 + ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "tiff" "$2" + set_library "libpng" "$2" + ;; + twolame) + ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ;; + wavpack) + ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 + ;; + x264) + ENABLED_LIBRARIES[LIBRARY_X264]=$2 + ;; + x265) + ENABLED_LIBRARIES[LIBRARY_X265]=$2 + ;; + xvidcore) + ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 + ;; + expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile) + # THESE LIBRARIES ARE NOT ENABLED DIRECTLY + ;; + nettle) + ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 + set_library "gmp" "$2" + ;; + tiff) + ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ;; + *) + print_unknown_library "$1" + ;; + esac } disable_arch() { - set_arch $1 0 + set_arch "$1" 0 } set_arch() { - case $1 in - armv7) - ENABLED_ARCHITECTURES[ARCH_ARMV7]=$2 - ;; - armv7s) - ENABLED_ARCHITECTURES[ARCH_ARMV7S]=$2 - ;; - arm64) - ENABLED_ARCHITECTURES[ARCH_ARM64]=$2 - ;; - arm64e) - ENABLED_ARCHITECTURES[ARCH_ARM64E]=$2 - ;; - i386) - ENABLED_ARCHITECTURES[ARCH_I386]=$2 - ;; - x86-64) - ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 - ;; - x86-64-mac-catalyst) - ENABLED_ARCHITECTURES[ARCH_X86_64_MAC_CATALYST]=$2 - ;; - *) - print_unknown_platform $1 - ;; - esac + case $1 in + armv7) + ENABLED_ARCHITECTURES[ARCH_ARMV7]=$2 + ;; + armv7s) + ENABLED_ARCHITECTURES[ARCH_ARMV7S]=$2 + ;; + arm64) + ENABLED_ARCHITECTURES[ARCH_ARM64]=$2 + ;; + arm64e) + ENABLED_ARCHITECTURES[ARCH_ARM64E]=$2 + ;; + i386) + ENABLED_ARCHITECTURES[ARCH_I386]=$2 + ;; + x86-64) + ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 + ;; + x86-64-mac-catalyst) + ENABLED_ARCHITECTURES[ARCH_X86_64_MAC_CATALYST]=$2 + ;; + *) + print_unknown_platform "$1" + ;; + esac } print_unknown_option() { - echo -e "Unknown option \"$1\".\nSee $0 --help for available options." - exit 1 + echo -e "Unknown option \"$1\".\nSee $0 --help for available options." + exit 1 } print_unknown_library() { - echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." - exit 1 + echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." + exit 1 } print_unknown_platform() { - echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." - exit 1 + echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." + exit 1 } print_enabled_architectures() { - echo -n "Architectures: " - - let enabled=0; - for print_arch in {0..6} - do - if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_arch_name $print_arch) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Architectures: " + + let enabled=0 + for print_arch in {0..6}; do + if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n "$(get_arch_name $print_arch)" + enabled=$((enabled + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_enabled_libraries() { - echo -n "Libraries: " - - let enabled=0; - - # FIRST BUILT-IN LIBRARIES - for library in {42..49} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - # THEN EXTERNAL LIBRARIES - for library in {0..31} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Libraries: " + + let enabled=0 + + # FIRST BUILT-IN LIBRARIES + for library in {42..49}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n "$(get_library_name $library)" + enabled=$((enabled + 1)) + fi + done + + # THEN EXTERNAL LIBRARIES + for library in {0..31}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n "$(get_library_name $library)" + enabled=$((enabled + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_reconfigure_requested_libraries() { - local counter=0; + local counter=0 - for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Reconfigure: " - else - echo -n ", " - fi + for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Reconfigure: " + else + echo -n ", " + fi - echo -n ${RECONF_LIBRARY} + echo -n "${RECONF_LIBRARY}" - counter=$((${counter} + 1)); - done + counter=$((counter + 1)) + done - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } print_rebuild_requested_libraries() { - local counter=0; + local counter=0 - for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Rebuild: " - else - echo -n ", " - fi + for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Rebuild: " + else + echo -n ", " + fi - echo -n ${REBUILD_LIBRARY} + echo -n "${REBUILD_LIBRARY}" - counter=$((${counter} + 1)); - done + counter=$((counter + 1)) + done - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } build_info_plist() { - local FILE_PATH="$1" - local FRAMEWORK_NAME="$2" - local FRAMEWORK_ID="$3" - local FRAMEWORK_SHORT_VERSION="$4" - local FRAMEWORK_VERSION="$5" + local FILE_PATH="$1" + local FRAMEWORK_NAME="$2" + local FRAMEWORK_ID="$3" + local FRAMEWORK_SHORT_VERSION="$4" + local FRAMEWORK_VERSION="$5" - cat > ${FILE_PATH} <"${FILE_PATH}" < @@ -646,9 +631,9 @@ EOF } build_modulemap() { - local FILE_PATH="$1" + local FILE_PATH="$1" - cat > ${FILE_PATH} <"${FILE_PATH}" <>"${BASEDIR}/build.log" 2>&1 || exit 1 + local STATIC_LIBRARY_PATH=$(find ${BASEDIR}/prebuilt/ios-${TARGET_ARCH} -name $3) + local CAPITAL_CASE_LIBRARY_NAME=$(to_capital_case "$2") + + build_info_plist "${FRAMEWORK_PATH}/Info.plist" "$2" "com.arthenica.mobileffmpeg.${CAPITAL_CASE_LIBRARY_NAME}" "$4" "$4" + cp "${STATIC_LIBRARY_PATH}" "${FRAMEWORK_PATH}/$2" 1>>"${BASEDIR}/build.log" 2>&1 + fi + done + + # 2. CREATE XCFRAMEWORKS + local XCFRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-xcframework/$2.xcframework + mkdir -p "${XCFRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + BUILD_COMMAND="xcodebuild -create-xcframework " + + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + if [[ ${TARGET_ARCH} != "arm64e" ]]; then + local FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-xcframework/.tmp/ios-${TARGET_ARCH}/$2.framework + BUILD_COMMAND+=" -framework ${FRAMEWORK_PATH}" + fi + done + + BUILD_COMMAND+=" -output ${XCFRAMEWORK_PATH}" + + COMMAND_OUTPUT=$(${BUILD_COMMAND} 2>&1) + + echo "${COMMAND_OUTPUT}" 1>>"${BASEDIR}/build.log" 2>&1 + + echo "" 1>>"${BASEDIR}/build.log" 2>&1 + + if [[ ${COMMAND_OUTPUT} == *"is empty in library"* ]]; then + RC=1 + else + RC=0 + fi + + else + + # 1. CREATE FAT LIBRARY local FAT_LIBRARY_PATH=${BASEDIR}/prebuilt/ios-universal/$2-universal - mkdir -p ${FAT_LIBRARY_PATH}/lib 1>>${BASEDIR}/build.log 2>&1 + mkdir -p "${FAT_LIBRARY_PATH}/lib" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 LIPO_COMMAND="${LIPO} -create" - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" $(find ${BASEDIR}/prebuilt/ios-${TARGET_ARCH} -name $1)" + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" $(find ${BASEDIR}/prebuilt/ios-${TARGET_ARCH} -name $3)" done - LIPO_COMMAND+=" -output ${FAT_LIBRARY_PATH}/lib/$1" + LIPO_COMMAND+=" -output ${FAT_LIBRARY_PATH}/lib/$3" + + RC=$(${LIPO_COMMAND} 1>>"${BASEDIR}/build.log" 2>&1) + + if [[ ${RC} -eq 0 ]]; then + + # 2. CREATE FRAMEWORK + RC=$(create_static_framework "$2" "$3" "$4") + + if [[ ${RC} -eq 0 ]]; then + + # 3. COPY LICENSES + if [[ ${LIBRARY_LIBTHEORA} == "$1" ]]; then + license_directories=("${BASEDIR}/prebuilt/ios-universal/libtheora-universal" "${BASEDIR}/prebuilt/ios-universal/libtheoraenc-universal" "${BASEDIR}/prebuilt/ios-universal/libtheoradec-universal" "${BASEDIR}/prebuilt/ios-framework/libtheora.framework" "${BASEDIR}/prebuilt/ios-framework/libtheoraenc.framework" "${BASEDIR}/prebuilt/ios-framework/libtheoradec.framework") + elif [[ ${LIBRARY_LIBVORBIS} == "$1" ]]; then + license_directories=("${BASEDIR}/prebuilt/ios-universal/libvorbisfile-universal" "${BASEDIR}/prebuilt/ios-universal/libvorbisenc-universal" "${BASEDIR}/prebuilt/ios-universal/libvorbis-universal" "${BASEDIR}/prebuilt/ios-framework/libvorbisfile.framework" "${BASEDIR}/prebuilt/ios-framework/libvorbisenc.framework" "${BASEDIR}/prebuilt/ios-framework/libvorbis.framework") + elif [[ ${LIBRARY_LIBWEBP} == "$1" ]]; then + license_directories=("${BASEDIR}/prebuilt/ios-universal/libwebpdecoder-universal" "${BASEDIR}/prebuilt/ios-universal/libwebpdemux-universal" "${BASEDIR}/prebuilt/ios-universal/libwebp-universal" "${BASEDIR}/prebuilt/ios-framework/libwebpdecoder.framework" "${BASEDIR}/prebuilt/ios-framework/libwebpdemux.framework" "${BASEDIR}/prebuilt/ios-framework/libwebp.framework") + elif [[ ${LIBRARY_OPENCOREAMR} == "$1" ]]; then + license_directories=("${BASEDIR}/prebuilt/ios-universal/libopencore-amrwb-universal" "${BASEDIR}/prebuilt/ios-universal/libopencore-amrnb-universal" "${BASEDIR}/prebuilt/ios-framework/libopencore-amrwb.framework" "${BASEDIR}/prebuilt/ios-framework/libopencore-amrnb.framework") + elif [[ ${LIBRARY_NETTLE} == "$1" ]]; then + license_directories=("${BASEDIR}/prebuilt/ios-universal/libnettle-universal" "${BASEDIR}/prebuilt/ios-universal/libhogweed-universal" "${BASEDIR}/prebuilt/ios-framework/libnettle.framework" "${BASEDIR}/prebuilt/ios-framework/libhogweed.framework") + else + license_directories=("${BASEDIR}/prebuilt/ios-universal/$2-universal" "${BASEDIR}/prebuilt/ios-framework/$2.framework") + fi + + RC=$(copy_external_library_license "$1" "${license_directories[@]}") + fi - RC=$(${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1) + fi + + fi + + echo "${RC}" - echo ${RC} } # 1 - library name # 2 - static library name # 3 - library version create_static_framework() { - local FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-framework/$1.framework + local FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-framework/$1.framework - mkdir -p ${FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 + mkdir -p "${FRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 - local CAPITAL_CASE_LIBRARY_NAME=$(to_capital_case $1) + local CAPITAL_CASE_LIBRARY_NAME=$(to_capital_case "$1") - build_info_plist "${FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${CAPITAL_CASE_LIBRARY_NAME}" "$3" "$3" + build_info_plist "${FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${CAPITAL_CASE_LIBRARY_NAME}" "$3" "$3" - cp ${BASEDIR}/prebuilt/ios-universal/$1-universal/lib/$2 ${FRAMEWORK_PATH}/$1 1>>${BASEDIR}/build.log 2>&1 + cp "${BASEDIR}/prebuilt/ios-universal/$1-universal/lib/$2" "${FRAMEWORK_PATH}/$1" 1>>"${BASEDIR}/build.log" 2>&1 - echo "$?" + echo "$?" +} + +# 1 - library index +# 2 - output path +copy_external_library_license() { + output_path_array="$2" + for output_path in "${output_path_array[@]}" + do + $(cp $(get_external_library_license_path "$1") "${output_path}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1) + if [ $? -ne 0 ]; then + echo 1 + return + fi + done; + echo 0 } +# 1 - library index get_external_library_license_path() { - case $1 in - 1) echo "${BASEDIR}/src/$(get_library_name $1)/docs/LICENSE.TXT" ;; - 3) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; - 25) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LGPL" ;; - 27) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md" ;; - 29) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.txt" ;; - 33) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md " ;; - 36) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; - 37) echo "${BASEDIR}/src/$(get_library_name $1)/COPYRIGHT" ;; - 40) echo "${BASEDIR}/src/$(get_library_name $1)/leptonica-license.txt" ;; - 4 | 9 | 12 | 18 | 20 | 26 | 31 | 35) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE" ;; - *) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING" ;; - esac + case $1 in + 1) echo "${BASEDIR}/src/$(get_library_name "$1")/docs/LICENSE.TXT" ;; + 3) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.LESSERv3" ;; + 25) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.LGPL" ;; + 27) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE.md" ;; + 29) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.txt" ;; + 33) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE.md " ;; + 36) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING.LESSERv3" ;; + 37) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYRIGHT" ;; + 40) echo "${BASEDIR}/src/$(get_library_name "$1")/leptonica-license.txt" ;; + 4 | 9 | 12 | 18 | 20 | 26 | 31 | 35) echo "${BASEDIR}/src/$(get_library_name "$1")/LICENSE" ;; + *) echo "${BASEDIR}/src/$(get_library_name "$1")/COPYING" ;; + esac } get_external_library_version() { - echo "$(grep Version ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/pkgconfig/$1.pc 2>>${BASEDIR}/build.log | sed 's/Version://g;s/\ //g')" + echo "$(grep Version ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/pkgconfig/$1.pc 2>>"${BASEDIR}/build.log" | sed 's/Version://g;s/\ //g')" } # ENABLE COMMON FUNCTIONS . ${BASEDIR}/build/ios-common.sh -echo -e "\nINFO: Build options: $@\n" 1>>${BASEDIR}/build.log 2>&1 +echo -e "\nINFO: Build options: $*\n" 1>>"${BASEDIR}/build.log" 2>&1 GPL_ENABLED="no" DISPLAY_HELP="" -BUILD_LTS="" BUILD_TYPE_ID="" +BUILD_LTS="" +MOBILE_FFMPEG_XCF_BUILD="" BUILD_FORCE="" -BUILD_VERSION=$(git describe --tags 2>>${BASEDIR}/build.log) - -while [ ! $# -eq 0 ] -do - case $1 in - -h | --help) - DISPLAY_HELP="1" - ;; - -v | --version) - display_version - exit 0 - ;; - --skip-*) - SKIP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - skip_library ${SKIP_LIBRARY} - ;; - --no-output-redirection) - no_output_redirection - ;; - --no-workspace-cleanup-*) - NO_WORKSPACE_CLEANUP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g'` - - no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY} - ;; - -d | --debug) - enable_debug - ;; - -s | --speed) - optimize_for_speed - ;; - -l | --lts) - BUILD_LTS="1" - ;; - -f | --force) - BUILD_FORCE="1" - ;; - --reconf-*) - CONF_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - reconf_library ${CONF_LIBRARY} - ;; - --rebuild-*) - BUILD_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - rebuild_library ${BUILD_LIBRARY} - ;; - --full) - for library in {0..49} - do - if [[ $library -ne 17 ]] && [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then - enable_library $(get_library_name $library) - fi - done - ;; - --enable-gpl) - GPL_ENABLED="yes" - ;; - --enable-*) - ENABLED_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - enable_library ${ENABLED_LIBRARY} - ;; - --disable-*) - DISABLED_ARCH=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - disable_arch ${DISABLED_ARCH} - ;; - *) - print_unknown_option $1 - ;; - esac - shift -done; +BUILD_VERSION=$(git describe --tags 2>>"${BASEDIR}/build.log") + +while [ ! $# -eq 0 ]; do + case $1 in + -h | --help) + DISPLAY_HELP="1" + ;; + -v | --version) + display_version + exit 0 + ;; + --skip-*) + SKIP_LIBRARY=$(echo "$1" | sed -e 's/^--[A-Za-z]*-//g') + + skip_library "${SKIP_LIBRARY}" + ;; + --no-output-redirection) + no_output_redirection + ;; + --no-workspace-cleanup-*) + NO_WORKSPACE_CLEANUP_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g') + + no_workspace_cleanup_library "${NO_WORKSPACE_CLEANUP_LIBRARY}" + ;; + -d | --debug) + enable_debug + ;; + -s | --speed) + optimize_for_speed + ;; + -l | --lts) + BUILD_LTS="1" + ;; + -x | --xcframework) + MOBILE_FFMPEG_XCF_BUILD="1" + ;; + -f | --force) + BUILD_FORCE="1" + ;; + --reconf-*) + CONF_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + reconf_library "${CONF_LIBRARY}" + ;; + --rebuild-*) + BUILD_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + rebuild_library "${BUILD_LIBRARY}" + ;; + --full) + for library in {0..49}; do + if [[ $library -ne 17 ]] && [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then + enable_library "$(get_library_name $library)" + fi + done + ;; + --enable-gpl) + GPL_ENABLED="yes" + ;; + --enable-*) + ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + enable_library "${ENABLED_LIBRARY}" + ;; + --disable-*) + DISABLED_ARCH=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + disable_arch "${DISABLED_ARCH}" + ;; + *) + print_unknown_option "$1" + ;; + esac + shift +done # DETECT BUILD TYPE -if [[ ! -z ${BUILD_LTS} ]]; then - enable_lts_build - BUILD_TYPE_ID+="LTS " +if [[ -n ${BUILD_LTS} ]]; then + enable_lts_build + BUILD_TYPE_ID+="LTS " fi -if [[ ! -z ${DISPLAY_HELP} ]]; then - display_help - exit 0 +if [[ -n ${DISPLAY_HELP} ]]; then + display_help + exit 0 fi # SELECT XCODE VERSION USED FOR BUILDING XCODE_FOR_MOBILE_FFMPEG=~/.xcode.for.mobile.ffmpeg.sh if [[ -f ${XCODE_FOR_MOBILE_FFMPEG} ]]; then - source ${XCODE_FOR_MOBILE_FFMPEG} 1>>${BASEDIR}/build.log 2>&1 + source ${XCODE_FOR_MOBILE_FFMPEG} 1>>"${BASEDIR}/build.log" 2>&1 fi DETECTED_IOS_SDK_VERSION="$(xcrun --sdk iphoneos --show-sdk-version)" -echo -e "INFO: Using SDK ${DETECTED_IOS_SDK_VERSION} by Xcode provided at $(xcode-select -p)\n" 1>>${BASEDIR}/build.log 2>&1 -if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]] && [[ "${DETECTED_IOS_SDK_VERSION}" != "${IOS_MIN_VERSION}" ]]; then - echo -e "\n(*) LTS packages should be built using SDK ${IOS_MIN_VERSION} but current configuration uses SDK ${DETECTED_IOS_SDK_VERSION}\n" +echo -e "INFO: Using SDK ${DETECTED_IOS_SDK_VERSION} by Xcode provided at $(xcode-select -p)\n" 1>>"${BASEDIR}/build.log" 2>&1 +if [[ -n ${MOBILE_FFMPEG_LTS_BUILD} ]] && [[ "${DETECTED_IOS_SDK_VERSION}" != "${IOS_MIN_VERSION}" ]]; then + echo -e "\n(*) LTS packages should be built using SDK ${IOS_MIN_VERSION} but current configuration uses SDK ${DETECTED_IOS_SDK_VERSION}\n" - if [[ -z ${BUILD_FORCE} ]]; then - exit 1 - fi + if [[ -z ${BUILD_FORCE} ]]; then + exit 1 + fi fi # DISABLE 32-bit architectures on newer IOS versions if [[ ${DETECTED_IOS_SDK_VERSION} == 11* ]] || [[ ${DETECTED_IOS_SDK_VERSION} == 12* ]] || [[ ${DETECTED_IOS_SDK_VERSION} == 13* ]]; then - if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARMV7}]} -eq 1 ]]; then - echo -e "INFO: Disabled armv7 architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "armv7" - fi - if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARMV7S}]} -eq 1 ]]; then - echo -e "INFO: Disabled armv7s architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "armv7s" - fi - if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_I386}]} -eq 1 ]]; then - echo -e "INFO: Disabled i386 architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "i386" - fi + if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARMV7}]} -eq 1 ]]; then + echo -e "INFO: Disabled armv7 architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "armv7" + fi + if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARMV7S}]} -eq 1 ]]; then + echo -e "INFO: Disabled armv7s architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "armv7s" + fi + if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_I386}]} -eq 1 ]]; then + echo -e "INFO: Disabled i386 architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "i386" + fi + +# DISABLE arm64e architecture on older IOS versions +elif [[ ${DETECTED_IOS_SDK_VERSION} != 10* ]]; then + if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM64E}]} -eq 1 ]]; then + echo -e "INFO: Disabled arm64e architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "arm64e" + fi fi # DISABLE x86-64-mac-catalyst architecture on IOS versions lower than 13 if [[ ${DETECTED_IOS_SDK_VERSION} != 13* ]] && [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_X86_64_MAC_CATALYST}]} -eq 1 ]]; then - echo -e "INFO: Disabled x86-64-mac-catalyst architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "x86-64-mac-catalyst" + echo -e "INFO: Disabled x86-64-mac-catalyst architecture which is not supported on SDK ${DETECTED_IOS_SDK_VERSION}\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "x86-64-mac-catalyst" fi # DISABLE x86-64-mac-catalyst when x86-64 is enabled -if [[ ${ENABLED_ARCHITECTURES[${ARCH_X86_64}]} -eq 1 ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_X86_64_MAC_CATALYST}]} -eq 1 ]]; then - echo -e "INFO: Disabled x86-64-mac-catalyst architecture which can not co-exist with x86-64.\n" 1>>${BASEDIR}/build.log 2>&1 - disable_arch "x86-64-mac-catalyst" +if [[ -z ${MOBILE_FFMPEG_XCF_BUILD} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_X86_64}]} -eq 1 ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_X86_64_MAC_CATALYST}]} -eq 1 ]]; then + echo -e "INFO: Disabled x86-64-mac-catalyst architecture which can not co-exist with x86-64 in a framework bundle / universal fat library.\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "x86-64-mac-catalyst" +fi + +# DISABLE arm64e when arm64 is enabled +if [[ -n ${MOBILE_FFMPEG_XCF_BUILD} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM64E}]} -eq 1 ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM64}]} -eq 1 ]]; then + echo -e "INFO: Disabled arm64e architecture which can not co-exist with arm64 in an xcframework bundle.\n" 1>>"${BASEDIR}/build.log" 2>&1 + disable_arch "arm64e" fi echo -e "\nBuilding mobile-ffmpeg ${BUILD_TYPE_ID}static library for iOS\n" -echo -e -n "INFO: Building mobile-ffmpeg ${BUILD_VERSION} ${BUILD_TYPE_ID}for iOS: " 1>>${BASEDIR}/build.log 2>&1 -echo -e `date` 1>>${BASEDIR}/build.log 2>&1 +echo -e -n "INFO: Building mobile-ffmpeg ${BUILD_VERSION} ${BUILD_TYPE_ID}for iOS: " 1>>"${BASEDIR}/build.log" 2>&1 +echo -e "$(date)" 1>>"${BASEDIR}/build.log" 2>&1 print_enabled_architectures print_enabled_libraries @@ -875,556 +969,422 @@ print_reconfigure_requested_libraries print_rebuild_requested_libraries # CHECKING GPL LIBRARIES -for gpl_library in {17..21} -do - if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then - library_name=$(get_library_name ${gpl_library}) - - if [ ${GPL_ENABLED} != "yes" ]; then - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - else - DOWNLOAD_RESULT=$(download_gpl_library_source ${library_name}) - if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then - echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" - echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - fi - fi +for gpl_library in {17..21}; do + if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then + library_name=$(get_library_name ${gpl_library}) + + if [ ${GPL_ENABLED} != "yes" ]; then + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>"${BASEDIR}/build.log" 2>&1 + exit 1 + else + DOWNLOAD_RESULT=$(download_gpl_library_source "${library_name}") + if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then + echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" + echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>"${BASEDIR}/build.log" 2>&1 + exit 1 + fi fi + fi done TARGET_ARCH_LIST=() -for run_arch in {0..6} -do - if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then - export ARCH=$(get_arch_name $run_arch) - export TARGET_SDK=$(get_target_sdk) - export SDK_PATH=$(get_sdk_path) - export SDK_NAME=$(get_sdk_name) - - export LIPO="$(xcrun --sdk $(get_sdk_name) -f lipo)" - - . ${BASEDIR}/build/main-ios.sh "${ENABLED_LIBRARIES[@]}" - case ${ARCH} in - x86-64) - TARGET_ARCH="x86_64" - ;; - x86-64-mac-catalyst) - TARGET_ARCH="x86_64-mac-catalyst" - ;; - *) - TARGET_ARCH="${ARCH}" - ;; - esac - TARGET_ARCH_LIST+=(${TARGET_ARCH}) - - # CLEAR FLAGS - for library in {1..50} - do - library_name=$(get_library_name $((library - 1))) - unset $(echo "OK_${library_name}" | sed "s/\-/\_/g") - unset $(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g") - done - fi +for run_arch in {0..6}; do + if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then + export ARCH=$(get_arch_name $run_arch) + export TARGET_SDK=$(get_target_sdk) + export SDK_PATH=$(get_sdk_path) + export SDK_NAME=$(get_sdk_name) + + export LIPO="$(xcrun --sdk $(get_sdk_name) -f lipo)" + + . ${BASEDIR}/build/main-ios.sh "${ENABLED_LIBRARIES[@]}" + case ${ARCH} in + x86-64) + TARGET_ARCH="x86_64" + ;; + x86-64-mac-catalyst) + TARGET_ARCH="x86_64-mac-catalyst" + ;; + *) + TARGET_ARCH="${ARCH}" + ;; + esac + TARGET_ARCH_LIST+=("${TARGET_ARCH}") + + # CLEAR FLAGS + for library in {1..50}; do + library_name=$(get_library_name $((library - 1))) + unset "$(echo "OK_${library_name}" | sed "s/\-/\_/g")" + unset "$(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g")" + done + fi done FFMPEG_LIBS="libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale" -BUILD_LIBRARY_EXTENSION="a"; +BUILD_LIBRARY_EXTENSION="a" + +if [[ -n ${TARGET_ARCH_LIST[0]} ]]; then -if [[ ! -z ${TARGET_ARCH_LIST} ]]; then + # BUILDING PACKAGES + if [[ -n ${MOBILE_FFMPEG_XCF_BUILD} ]]; then + echo -e -n "\n\nCreating xcframeworks under prebuilt: " + rm -rf "${BASEDIR}/prebuilt/ios-xcframework" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${BASEDIR}/prebuilt/ios-xcframework" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + else echo -e -n "\n\nCreating frameworks and universal libraries under prebuilt: " - # BUILDING UNIVERSAL LIBRARIES - rm -rf ${BASEDIR}/prebuilt/ios-universal 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${BASEDIR}/prebuilt/ios-universal 1>>${BASEDIR}/build.log 2>&1 - rm -rf ${BASEDIR}/prebuilt/ios-framework 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${BASEDIR}/prebuilt/ios-framework 1>>${BASEDIR}/build.log 2>&1 - - # 1. EXTERNAL LIBRARIES - for library in {0..41} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - - library_name=$(get_library_name ${library}) - package_config_file_name=$(get_package_config_file_name ${library}) - library_version=$(get_external_library_version ${package_config_file_name}) - capital_case_library_name=$(to_capital_case ${library_name}) - if [[ -z ${library_version} ]]; then - echo -e "Failed to detect version for ${library_name} from ${package_config_file_name}.pc\n" 1>>${BASEDIR}/build.log 2>&1 - echo -e "failed\n" - exit 1 - fi - - echo -e "Creating universal library for ${library_name}\n" 1>>${BASEDIR}/build.log 2>&1 - - if [[ ${LIBRARY_LIBTHEORA} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libtheora.a" "libtheora") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libtheoraenc.a" "libtheoraenc") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libtheoradec.a" "libtheoradec") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheora" "libtheora.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheoraenc" "libtheoraenc.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheoradec" "libtheoradec.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libtheora-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libtheoraenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libtheoradec-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libtheora.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libtheoraenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libtheoradec.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_LIBVORBIS} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libvorbisfile.a" "libvorbisfile") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libvorbisenc.a" "libvorbisenc") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libvorbis.a" "libvorbis") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbisfile" "libvorbisfile.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbisenc" "libvorbisenc.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbis" "libvorbis.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libvorbisfile-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libvorbisenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libvorbis-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libvorbisfile.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libvorbisenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libvorbis.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_LIBWEBP} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libwebpdecoder.a" "libwebpdecoder") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libwebpdemux.a" "libwebpdemux") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libwebp.a" "libwebp") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebpdecoder" "libwebpdecoder.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebpdemux" "libwebpdemux.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebp" "libwebp.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libwebpdecoder-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libwebpdemux-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libwebp-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libwebpdecoder.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libwebpdemux.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libwebp.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - - elif [[ ${LIBRARY_OPENCOREAMR} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrwb.a" "libopencore-amrwb") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrnb.a" "libopencore-amrnb") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrwb" "libopencore-amrwb.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrnb" "libopencore-amrnb.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libopencore-amrwb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libopencore-amrnb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libopencore-amrwb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libopencore-amrnb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_NETTLE} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libnettle.a" "libnettle") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libhogweed.a" "libhogweed") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libnettle" "libnettle.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libhogweed" "libhogweed.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libnettle-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/libhogweed-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libnettle.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/libhogweed.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - else - - library_name=$(get_library_name $((library))) - static_archive_name=$(get_static_archive_name $((library))) - LIBRARY_CREATED=$(create_static_fat_library $static_archive_name $library_name) - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework $library_name $static_archive_name $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-universal/${library_name}-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/ios-framework/${library_name}.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - fi + rm -rf "${BASEDIR}/prebuilt/ios-universal" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${BASEDIR}/prebuilt/ios-universal" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + rm -rf "${BASEDIR}/prebuilt/ios-framework" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${BASEDIR}/prebuilt/ios-framework" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + fi + + # 1. EXTERNAL LIBRARIES + for library in {0..41}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + + library_name=$(get_library_name ${library}) + package_config_file_name=$(get_package_config_file_name ${library}) + library_version=$(get_external_library_version "${package_config_file_name}") + if [[ -z ${library_version} ]]; then + echo -e "Failed to detect version for ${library_name} from ${package_config_file_name}.pc\n" 1>>"${BASEDIR}/build.log" 2>&1 + echo -e "failed\n" + exit 1 + fi + + echo -e "Creating external library package for ${library_name}\n" 1>>"${BASEDIR}/build.log" 2>&1 + if [[ ${LIBRARY_LIBTHEORA} == "$library" ]]; then + + LIBRARY_CREATED=$(create_external_library_package $library "libtheora" "libtheora.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_external_library_package $library "libtheoraenc" "libtheoraenc.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 fi - done - # 2. FFMPEG - FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/ios-universal/ffmpeg-universal - mkdir -p ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 + LIBRARY_CREATED=$(create_external_library_package $library "libtheoradec" "libtheoradec.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/ffmpeg/include/* ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/ffmpeg/include/config.h ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + elif [[ ${LIBRARY_LIBVORBIS} == "$library" ]]; then - for FFMPEG_LIB in ${FFMPEG_LIBS} - do - LIPO_COMMAND="${LIPO} -create" + LIBRARY_CREATED=$(create_external_library_package $library "libvorbisfile" "libvorbisfile.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" - done + LIBRARY_CREATED=$(create_external_library_package $library "libvorbisenc" "libvorbisenc.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - LIPO_COMMAND+=" -output ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" + LIBRARY_CREATED=$(create_external_library_package $library "libvorbis" "libvorbis.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - ${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1 + elif [[ ${LIBRARY_LIBWEBP} == "$library" ]]; then - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 + LIBRARY_CREATED=$(create_external_library_package $library "libwebpdecoder" "libwebpdecoder.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 fi - FFMPEG_LIB_UPPERCASE=$(echo ${FFMPEG_LIB} | tr '[a-z]' '[A-Z]') - FFMPEG_LIB_CAPITALCASE=$(to_capital_case ${FFMPEG_LIB}) + LIBRARY_CREATED=$(create_external_library_package $library "libwebpdemux" "libwebpdemux.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - FFMPEG_LIB_MAJOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR//g;s/\ //g") - FFMPEG_LIB_MINOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR//g;s/\ //g") - FFMPEG_LIB_MICRO=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO//g;s/\ //g") + LIBRARY_CREATED=$(create_external_library_package $library "libwebp" "libwebp.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - FFMPEG_LIB_VERSION="${FFMPEG_LIB_MAJOR}.${FFMPEG_LIB_MINOR}.${FFMPEG_LIB_MICRO}" + elif [[ ${LIBRARY_OPENCOREAMR} == "$library" ]]; then - FFMPEG_LIB_FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-framework/${FFMPEG_LIB}.framework + LIBRARY_CREATED=$(create_external_library_package $library "libopencore-amrwb" "libopencore-amrwb.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - rm -rf ${FFMPEG_LIB_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + LIBRARY_CREATED=$(create_external_library_package $library "libopencore-amrnb" "libopencore-amrnb.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - cp -r ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/* ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - cp ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION} ${FFMPEG_LIB_FRAMEWORK_PATH}/${FFMPEG_LIB} 1>>${BASEDIR}/build.log 2>&1 + elif [[ ${LIBRARY_NETTLE} == "$library" ]]; then - # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then + LIBRARY_CREATED=$(create_external_library_package $library "libnettle" "libnettle.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_external_library_package $library "libhogweed" "libhogweed.a" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + else + + library_name=$(get_library_name $((library))) + static_archive_name=$(get_static_archive_name $((library))) + LIBRARY_CREATED=$(create_external_library_package $library "$library_name" "$static_archive_name" "${library_version}") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + fi + + fi + done + + # 2. FFMPEG & MOBILE FFMPEG + if [[ -n ${MOBILE_FFMPEG_XCF_BUILD} ]]; then + + # FFMPEG + for FFMPEG_LIB in ${FFMPEG_LIBS}; do + + XCFRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-xcframework/${FFMPEG_LIB}.xcframework + mkdir -p "${XCFRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + echo -e "Creating package for ${FFMPEG_LIB}\n" 1>>"${BASEDIR}/build.log" 2>&1 + + BUILD_COMMAND="xcodebuild -create-xcframework " + + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + + if [[ ${TARGET_ARCH} != "arm64e" ]]; then + + FFMPEG_LIB_UPPERCASE=$(echo "${FFMPEG_LIB}" | tr '[a-z]' '[A-Z]') + FFMPEG_LIB_CAPITALCASE=$(to_capital_case "${FFMPEG_LIB}") + + FFMPEG_LIB_MAJOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR" "${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/include/${FFMPEG_LIB}/version.h" | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR//g;s/\ //g") + FFMPEG_LIB_MINOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR" "${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/include/${FFMPEG_LIB}/version.h" | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR//g;s/\ //g") + FFMPEG_LIB_MICRO=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO" "${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/include/${FFMPEG_LIB}/version.h" | sed "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO//g;s/\ //g") + + FFMPEG_LIB_VERSION="${FFMPEG_LIB_MAJOR}.${FFMPEG_LIB_MINOR}.${FFMPEG_LIB_MICRO}" + + FFMPEG_LIB_FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-xcframework/.tmp/ios-${TARGET_ARCH}/${FFMPEG_LIB}.framework + + rm -rf "${FFMPEG_LIB_FRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 + mkdir -p "${FFMPEG_LIB_FRAMEWORK_PATH}/Headers" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/include/${FFMPEG_LIB}/* ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>"${BASEDIR}/build.log" 2>&1 + cp "${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" "${FFMPEG_LIB_FRAMEWORK_PATH}/${FFMPEG_LIB}" 1>>"${BASEDIR}/build.log" 2>&1 + + # COPY THE LICENSES + if [ ${GPL_ENABLED} == "yes" ]; then # GPLv3.0 - cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - else + cp "${BASEDIR}/LICENSE.GPLv3" "${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + else # LGPLv3.0 - cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + cp "${BASEDIR}/LICENSE.LGPLv3" "${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + fi + + build_info_plist "${FFMPEG_LIB_FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${FFMPEG_LIB_CAPITALCASE}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" + + BUILD_COMMAND+=" -framework ${FFMPEG_LIB_FRAMEWORK_PATH}" fi - build_info_plist "${FFMPEG_LIB_FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${FFMPEG_LIB_CAPITALCASE}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" + done + + BUILD_COMMAND+=" -output ${XCFRAMEWORK_PATH}" + + COMMAND_OUTPUT=$(${BUILD_COMMAND} 2>&1) + + echo "${COMMAND_OUTPUT}" 1>>"${BASEDIR}/build.log" 2>&1 + + echo "" 1>>"${BASEDIR}/build.log" 2>&1 + + if [[ ${COMMAND_OUTPUT} == *"is empty in library"* ]]; then + echo -e "failed\n" + exit 1 + fi + + echo -e "Created ${FFMPEG_LIB} xcframework successfully.\n" 1>>"${BASEDIR}/build.log" 2>&1 - echo -e "Created ${FFMPEG_LIB} framework successfully.\n" 1>>${BASEDIR}/build.log 2>&1 + done + + # MOBILE FFMPEG + XCFRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-xcframework/mobileffmpeg.xcframework + mkdir -p "${XCFRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + BUILD_COMMAND="xcodebuild -create-xcframework " + + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + + if [[ ${TARGET_ARCH} != "arm64e" ]]; then + + MOBILE_FFMPEG_FRAMEWORK_PATH="${BASEDIR}/prebuilt/ios-xcframework/.tmp/ios-${TARGET_ARCH}/mobileffmpeg.framework" + + rm -rf "${MOBILE_FFMPEG_FRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 + mkdir -p "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + build_modulemap "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules/module.modulemap" + + cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/mobile-ffmpeg/include/* ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>"${BASEDIR}/build.log" 2>&1 + cp "${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/mobile-ffmpeg/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/mobileffmpeg" 1>>"${BASEDIR}/build.log" 2>&1 + + # COPY THE LICENSES + if [ ${GPL_ENABLED} == "yes" ]; then + cp "${BASEDIR}/LICENSE.GPLv3" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + else + cp "${BASEDIR}/LICENSE.LGPLv3" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + fi + + BUILD_COMMAND+=" -framework ${MOBILE_FFMPEG_FRAMEWORK_PATH}" + + fi + done; + + BUILD_COMMAND+=" -output ${XCFRAMEWORK_PATH}" + + COMMAND_OUTPUT=$(${BUILD_COMMAND} 2>&1) + + echo "${COMMAND_OUTPUT}" 1>>"${BASEDIR}/build.log" 2>&1 + + echo "" 1>>"${BASEDIR}/build.log" 2>&1 + + if [[ ${COMMAND_OUTPUT} == *"is empty in library"* ]]; then + echo -e "failed\n" + exit 1 + fi + + echo -e "Created mobileffmpeg xcframework successfully.\n" 1>>"${BASEDIR}/build.log" 2>&1 + + echo -e "ok\n" + + else + + FFMPEG_UNIVERSAL="${BASEDIR}/prebuilt/ios-universal/ffmpeg-universal" + mkdir -p "${FFMPEG_UNIVERSAL}/include" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${FFMPEG_UNIVERSAL}/lib" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/ffmpeg/include/* ${FFMPEG_UNIVERSAL}/include 1>>"${BASEDIR}/build.log" 2>&1 + cp "${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/ffmpeg/include/config.h" "${FFMPEG_UNIVERSAL}/include" 1>>"${BASEDIR}/build.log" 2>&1 + + for FFMPEG_LIB in ${FFMPEG_LIBS}; do + LIPO_COMMAND="${LIPO} -create" + + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/ffmpeg/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" + done + + LIPO_COMMAND+=" -output ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" + + ${LIPO_COMMAND} 1>>"${BASEDIR}/build.log" 2>&1 + + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + FFMPEG_LIB_UPPERCASE=$(echo "${FFMPEG_LIB}" | tr '[a-z]' '[A-Z]') + FFMPEG_LIB_CAPITALCASE=$(to_capital_case "${FFMPEG_LIB}") + + FFMPEG_LIB_MAJOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR" "${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h" | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR//g;s/\ //g") + FFMPEG_LIB_MINOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR" "${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h" | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR//g;s/\ //g") + FFMPEG_LIB_MICRO=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO" "${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h" | sed "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO//g;s/\ //g") + + FFMPEG_LIB_VERSION="${FFMPEG_LIB_MAJOR}.${FFMPEG_LIB_MINOR}.${FFMPEG_LIB_MICRO}" + + FFMPEG_LIB_FRAMEWORK_PATH="${BASEDIR}/prebuilt/ios-framework/${FFMPEG_LIB}.framework" + + rm -rf "${FFMPEG_LIB_FRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 + mkdir -p "${FFMPEG_LIB_FRAMEWORK_PATH}/Headers" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + + cp -r ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/* ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>"${BASEDIR}/build.log" 2>&1 + cp "${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" "${FFMPEG_LIB_FRAMEWORK_PATH}/${FFMPEG_LIB}" 1>>"${BASEDIR}/build.log" 2>&1 + + # COPY THE LICENSES + if [ ${GPL_ENABLED} == "yes" ]; then + + # GPLv3.0 + cp "${BASEDIR}/LICENSE.GPLv3" "${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + else + + # LGPLv3.0 + cp "${BASEDIR}/LICENSE.LGPLv3" "${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + fi + + build_info_plist "${FFMPEG_LIB_FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${FFMPEG_LIB_CAPITALCASE}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" + + echo -e "Created ${FFMPEG_LIB} framework successfully.\n" 1>>"${BASEDIR}/build.log" 2>&1 done # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then - cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + if [ ${GPL_ENABLED} == "yes" ]; then + cp "${BASEDIR}/LICENSE.GPLv3" "${FFMPEG_UNIVERSAL}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 else - cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + cp "${BASEDIR}/LICENSE.LGPLv3" "${FFMPEG_UNIVERSAL}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 fi # 3. MOBILE FFMPEG MOBILE_FFMPEG_VERSION=$(get_mobile_ffmpeg_version) - MOBILE_FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/ios-universal/mobile-ffmpeg-universal - MOBILE_FFMPEG_FRAMEWORK_PATH=${BASEDIR}/prebuilt/ios-framework/mobileffmpeg.framework - mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 - rm -rf ${MOBILE_FFMPEG_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules 1>>${BASEDIR}/build.log 2>&1 + MOBILE_FFMPEG_UNIVERSAL="${BASEDIR}/prebuilt/ios-universal/mobile-ffmpeg-universal" + MOBILE_FFMPEG_FRAMEWORK_PATH="${BASEDIR}/prebuilt/ios-framework/mobileffmpeg.framework" + mkdir -p "${MOBILE_FFMPEG_UNIVERSAL}/include" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${MOBILE_FFMPEG_UNIVERSAL}/lib" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + rm -rf "${MOBILE_FFMPEG_FRAMEWORK_PATH}" 1>>"${BASEDIR}/build.log" 2>&1 + mkdir -p "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 + mkdir -p "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules" 1>>"${BASEDIR}/build.log" 2>&1 || exit 1 LIPO_COMMAND="${LIPO} -create" - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/mobile-ffmpeg/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" ${BASEDIR}/prebuilt/ios-${TARGET_ARCH}/mobile-ffmpeg/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" done LIPO_COMMAND+=" -output ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" - ${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1 + ${LIPO_COMMAND} 1>>"${BASEDIR}/build.log" 2>&1 if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 + echo -e "failed\n" + exit 1 fi - cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/mobile-ffmpeg/include/* ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - cp -r ${MOBILE_FFMPEG_UNIVERSAL}/include/* ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - cp ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION} ${MOBILE_FFMPEG_FRAMEWORK_PATH}/mobileffmpeg 1>>${BASEDIR}/build.log 2>&1 + cp -r ${BASEDIR}/prebuilt/ios-${TARGET_ARCH_LIST[0]}/mobile-ffmpeg/include/* ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>"${BASEDIR}/build.log" 2>&1 + cp -r ${MOBILE_FFMPEG_UNIVERSAL}/include/* ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>"${BASEDIR}/build.log" 2>&1 + cp "${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/mobileffmpeg" 1>>"${BASEDIR}/build.log" 2>&1 # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then - cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + if [ ${GPL_ENABLED} == "yes" ]; then + cp "${BASEDIR}/LICENSE.GPLv3" "${MOBILE_FFMPEG_UNIVERSAL}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + cp "${BASEDIR}/LICENSE.GPLv3" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 else - cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + cp "${BASEDIR}/LICENSE.LGPLv3" "${MOBILE_FFMPEG_UNIVERSAL}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 + cp "${BASEDIR}/LICENSE.LGPLv3" "${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE" 1>>"${BASEDIR}/build.log" 2>&1 fi build_info_plist "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Info.plist" "mobileffmpeg" "com.arthenica.mobileffmpeg.MobileFFmpeg" "${MOBILE_FFMPEG_VERSION}" "${MOBILE_FFMPEG_VERSION}" build_modulemap "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules/module.modulemap" - echo -e "Created mobile-ffmpeg.framework and universal library successfully.\n" 1>>${BASEDIR}/build.log 2>&1 + echo -e "Created mobileffmpeg.framework and universal library successfully.\n" 1>>"${BASEDIR}/build.log" 2>&1 echo -e "ok\n" + fi fi diff --git a/ios/src/MobileFFmpegConfig.m b/ios/src/MobileFFmpegConfig.m index ea668c389..cc9022fe1 100644 --- a/ios/src/MobileFFmpegConfig.m +++ b/ios/src/MobileFFmpegConfig.m @@ -369,11 +369,15 @@ + (void)initialize { [supportedExternalLibraries addObject:@"libwebp"]; [supportedExternalLibraries addObject:@"libxml2"]; [supportedExternalLibraries addObject:@"opencore-amr"]; + [supportedExternalLibraries addObject:@"openh264"]; [supportedExternalLibraries addObject:@"opus"]; + [supportedExternalLibraries addObject:@"rubberband"]; + [supportedExternalLibraries addObject:@"sdl2"]; [supportedExternalLibraries addObject:@"shine"]; [supportedExternalLibraries addObject:@"snappy"]; [supportedExternalLibraries addObject:@"soxr"]; [supportedExternalLibraries addObject:@"speex"]; + [supportedExternalLibraries addObject:@"tesseract"]; [supportedExternalLibraries addObject:@"twolame"]; [supportedExternalLibraries addObject:@"wavpack"]; [supportedExternalLibraries addObject:@"x264"]; diff --git a/ios/test-app/manual-frameworks/.gitignore b/ios/test-app/manual-frameworks/.gitignore index df2913487..053014eab 100644 --- a/ios/test-app/manual-frameworks/.gitignore +++ b/ios/test-app/manual-frameworks/.gitignore @@ -1,2 +1,3 @@ /Pods/ /*.framework/ +/*.xcframework/ diff --git a/ios/test-app/universal/.gitignore b/ios/test-app/universal/.gitignore index fa9498365..c700054e7 100644 --- a/ios/test-app/universal/.gitignore +++ b/ios/test-app/universal/.gitignore @@ -1,3 +1,4 @@ /Pods/ /*.framework/ +/*.xcframework/ /mobile-ffmpeg-universal/ diff --git a/tools/clean.sh b/tools/clean.sh index ae1cf05c3..044030f53 100755 --- a/tools/clean.sh +++ b/tools/clean.sh @@ -13,16 +13,21 @@ rm -rf ../android/test-app/build rm -rf ../ios/test-app/pods-with-tooltips/Pods rm -rf ../ios/test-app/manual-frameworks/Pods rm -rf ../ios/test-app/manual-frameworks/*.framework +rm -rf ../ios/test-app/manual-frameworks/*.xcframework rm -rf ../ios/test-app/universal/Pods rm -rf ../ios/test-app/universal/*.framework +rm -rf ../ios/test-app/universal/*.xcframework rm -rf ../ios/test-app/universal/mobile-ffmpeg-universal rm -rf ../tvos/test-app/pods/Pods rm -rf ../tvos/test-app/pods/*.framework +rm -rf ../tvos/test-app/pods/*.xcframework rm -rf ../tvos/test-app/manual-frameworks/Pods rm -rf ../tvos/test-app/manual-frameworks/*.framework +rm -rf ../tvos/test-app/manual-frameworks/*.xcframework rm -rf ../tvos/test-app/universal/Pods rm -rf ../tvos/test-app/universal/*.framework +rm -rf ../tvos/test-app/universal/*.xcframework rm -rf ../tvos/test-app/universal/mobile-ffmpeg-universal rm -rf ../src/libvidstab diff --git a/tools/release/ios.sh b/tools/release/ios.sh index 0a2921be0..4dbcfeb62 100755 --- a/tools/release/ios.sh +++ b/tools/release/ios.sh @@ -4,11 +4,9 @@ # export BASEDIR=$(pwd) -export SOURCE_PACKAGE="${BASEDIR}/../../prebuilt/ios-framework" +export SOURCE_PACKAGE="${BASEDIR}/../../prebuilt/ios-xcframework" export COCOA_PACKAGE="${BASEDIR}/../../prebuilt/ios-cocoa" -export UNIVERSAL_PACKAGE="${BASEDIR}/../../prebuilt/ios-universal" -export ALL_UNIVERSAL_PACKAGES="${BASEDIR}/../../prebuilt/ios-all-universal" -export CUSTOM_OPTIONS="--disable-armv7 --disable-armv7s --disable-i386 --enable-ios-zlib --enable-ios-bzip2 --enable-ios-coreimage --enable-ios-avfoundation --enable-ios-audiotoolbox --enable-ios-videotoolbox" +export CUSTOM_OPTIONS="--xcframework --disable-armv7 --disable-armv7s --disable-i386 --disable-arm64e --enable-ios-zlib --enable-ios-bzip2 --enable-ios-coreimage --enable-ios-avfoundation --enable-ios-audiotoolbox --enable-ios-videotoolbox" export GPL_PACKAGES="--enable-gpl --enable-libvidstab --enable-x264 --enable-x265 --enable-xvidcore" export FULL_PACKAGES="--enable-fontconfig --enable-freetype --enable-fribidi --enable-gmp --enable-gnutls --enable-kvazaar --enable-lame --enable-libaom --enable-libass --enable-libilbc --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-opencore-amr --enable-opus --enable-shine --enable-snappy --enable-soxr --enable-speex --enable-twolame --enable-wavpack" @@ -22,36 +20,14 @@ create_package() { cp -r ${SOURCE_PACKAGE}/* ${CURRENT_PACKAGE} || exit 1 cd ${CURRENT_PACKAGE} || exit 1 - zip -r "../mobile-ffmpeg-$1-$2-ios-framework.zip" * || exit 1 + zip -r "../mobile-ffmpeg-$1-$2-ios-xcframework.zip" * || exit 1 # COPY PODSPEC AS THE LAST ITEM cp ${BASEDIR}/ios/${PACKAGE_NAME}.podspec ${CURRENT_PACKAGE} || exit 1 sed -i '' "s/VERSION/${PACKAGE_VERSION}/g" ${CURRENT_PACKAGE}/${PACKAGE_NAME}.podspec || exit 1 - - mkdir -p ${ALL_UNIVERSAL_PACKAGES} || exit 1 - local CURRENT_UNIVERSAL_PACKAGE="${ALL_UNIVERSAL_PACKAGES}/${PACKAGE_NAME}-universal" - rm -rf ${CURRENT_UNIVERSAL_PACKAGE} - mkdir -p ${CURRENT_UNIVERSAL_PACKAGE}/include || exit 1 - mkdir -p ${CURRENT_UNIVERSAL_PACKAGE}/lib || exit 1 - - cd ${UNIVERSAL_PACKAGE} || exit 1 - find . -name "*.a" -exec cp {} ${CURRENT_UNIVERSAL_PACKAGE}/lib \; || exit 1 - - # COPY LICENSE FILE OF EACH LIBRARY - LICENSE_FILES=$(find . -name LICENSE | grep -vi ffmpeg) - - for LICENSE_FILE in ${LICENSE_FILES[@]} - do - LIBRARY_NAME=$(echo ${LICENSE_FILE} | sed 's/\.\///g;s/-universal\/LICENSE//g') - cp ${LICENSE_FILE} ${CURRENT_UNIVERSAL_PACKAGE}/LICENSE.${LIBRARY_NAME} || exit 1 - done - - cp -r ${UNIVERSAL_PACKAGE}/mobile-ffmpeg-universal/include/* ${CURRENT_UNIVERSAL_PACKAGE}/include || exit 1 - cp -r ${UNIVERSAL_PACKAGE}/ffmpeg-universal/include/* ${CURRENT_UNIVERSAL_PACKAGE}/include || exit 1 - cp ${UNIVERSAL_PACKAGE}/ffmpeg-universal/LICENSE ${CURRENT_UNIVERSAL_PACKAGE}/LICENSE || exit 1 - - cd ${ALL_UNIVERSAL_PACKAGES} || exit 1 - zip -r "${PACKAGE_NAME}-${PACKAGE_VERSION}-ios-static-universal.zip" ${PACKAGE_NAME}-universal || exit 1 + sed -i '' "s/\.framework/\.xcframework/g" ${CURRENT_PACKAGE}/${PACKAGE_NAME}.podspec || exit 1 + sed -i '' "s/-framework/-xcframework/g" ${CURRENT_PACKAGE}/${PACKAGE_NAME}.podspec || exit 1 + sed -i '' "s/ios\.xcframeworks/ios\.frameworks/g" ${CURRENT_PACKAGE}/${PACKAGE_NAME}.podspec || exit 1 } if [[ $# -ne 1 ]]; @@ -77,9 +53,6 @@ fi rm -rf ${COCOA_PACKAGE} mkdir -p ${COCOA_PACKAGE} || exit 1 -rm -rf ${ALL_UNIVERSAL_PACKAGES} -mkdir -p ${ALL_UNIVERSAL_PACKAGES} || exit 1 - # MIN RELEASE cd ${BASEDIR}/../.. || exit 1 ./ios.sh ${CUSTOM_OPTIONS} || exit 1 diff --git a/tvos.sh b/tvos.sh index 064f88bc4..fc45bb3fe 100755 --- a/tvos.sh +++ b/tvos.sh @@ -69,8 +69,8 @@ REBUILD_LIBRARIES=() # CHECKING IF XCODE IS INSTALLED if ! [ -x "$(command -v xcrun)" ]; then - echo -e "\n(*) xcrun command not found. Please check your Xcode installation.\n" - exit 1 + echo -e "\n(*) xcrun command not found. Please check your Xcode installation.\n" + exit 1 fi # USE 10.2 AS TVOS_MIN_VERSION @@ -79,101 +79,101 @@ export TVOS_MIN_VERSION=10.2 export APPLE_TVOS_BUILD=1 get_mobile_ffmpeg_version() { - local MOBILE_FFMPEG_VERSION=$(grep 'const MOBILE_FFMPEG_VERSION' ${BASEDIR}/ios/src/MobileFFmpeg.m | grep -Eo '\".*\"' | sed -e 's/\"//g') + local MOBILE_FFMPEG_VERSION=$(grep 'const MOBILE_FFMPEG_VERSION' ${BASEDIR}/ios/src/MobileFFmpeg.m | grep -Eo '\".*\"' | sed -e 's/\"//g') - if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - echo "${MOBILE_FFMPEG_VERSION}" - else - echo "${MOBILE_FFMPEG_VERSION}.LTS" - fi + if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then + echo "${MOBILE_FFMPEG_VERSION}" + else + echo "${MOBILE_FFMPEG_VERSION}.LTS" + fi } display_help() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` - - echo -e "\n'"$COMMAND"' builds FFmpeg and MobileFFmpeg for tvOS platform. By default two architectures (arm64 and x86_64) are built without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends universal fat binaries and tvOS frameworks are created with enabled architectures inside.\n" - - echo -e "Usage: ./"$COMMAND" [OPTION]...\n" - - echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" - - echo -e "Options:" - - echo -e " -h, --help\t\t\tdisplay this help and exit" - echo -e " -v, --version\t\t\tdisplay version information and exit" - echo -e " -d, --debug\t\t\tbuild with debug information" - echo -e " -s, --speed\t\t\toptimize for speed instead of size" - echo -e " -l, --lts\t\t\tbuild lts packages to support sdk 9.2+ devices" - echo -e " -f, --force\t\t\tignore warnings\n" - - echo -e "Licensing options:" - - echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" - - echo -e "Platforms:" - - echo -e " --disable-arm64\t\tdo not build arm64 platform [yes]" - echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]\n" - - echo -e "Libraries:" - - echo -e " --full\t\t\tenables all non-GPL external libraries" - echo -e " --enable-tvos-audiotoolbox\tbuild with built-in Apple AudioToolbox support[no]" - echo -e " --enable-tvos-coreimage\tbuild with built-in Apple CoreImage support[no]" - echo -e " --enable-tvos-bzip2\t\tbuild with built-in bzip2 support[no]" - if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then - echo -e " --enable-tvos-videotoolbox\tbuild with built-in Apple VideoToolbox support[no]" - fi - echo -e " --enable-tvos-zlib\t\tbuild with built-in zlib [no]" - echo -e " --enable-tvos-libiconv\tbuild with built-in libiconv [no]" - echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" - echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" - echo -e " --enable-freetype\t\tbuild with freetype [no]" - echo -e " --enable-fribidi\t\tbuild with fribidi [no]" - echo -e " --enable-gmp\t\t\tbuild with gmp [no]" - echo -e " --enable-gnutls\t\tbuild with gnutls [no]" - echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" - echo -e " --enable-lame\t\t\tbuild with lame [no]" - echo -e " --enable-libaom\t\tbuild with libaom [no]" - echo -e " --enable-libass\t\tbuild with libass [no]" - echo -e " --enable-libilbc\t\tbuild with libilbc [no]" - echo -e " --enable-libtheora\t\tbuild with libtheora [no]" - echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" - echo -e " --enable-libvpx\t\tbuild with libvpx [no]" - echo -e " --enable-libwebp\t\tbuild with libwebp [no]" - echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" - echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" - echo -e " --enable-openh264\t\tbuild with openh264 [no]" - echo -e " --enable-opus\t\t\tbuild with opus [no]" - echo -e " --enable-sdl\t\t\tbuild with sdl [no]" - echo -e " --enable-shine\t\tbuild with shine [no]" - echo -e " --enable-snappy\t\tbuild with snappy [no]" - echo -e " --enable-soxr\t\t\tbuild with soxr [no]" - echo -e " --enable-speex\t\tbuild with speex [no]" - echo -e " --enable-tesseract\t\tbuild with tesseract [no]" - echo -e " --enable-twolame\t\tbuild with twolame [no]" - echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" - - echo -e "GPL libraries:" - - echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" - echo -e " --enable-rubberband\t\tbuild with rubber band [no]" - echo -e " --enable-x264\t\t\tbuild with x264 [no]" - echo -e " --enable-x265\t\t\tbuild with x265 [no]" - echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" - - echo -e "Advanced options:" - - echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" - echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" + COMMAND=$(echo $0 | sed -e 's/\.\///g') + + echo -e "\n$COMMAND builds FFmpeg and MobileFFmpeg for tvOS platform. By default two architectures (arm64 and x86-64) are built without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends, framework bundles and universal fat binaries are created under the prebuilt folder.\n" + + echo -e "Usage: ./$COMMAND [OPTION]...\n" + + echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" + + echo -e "Options:" + + echo -e " -h, --help\t\t\tdisplay this help and exit" + echo -e " -v, --version\t\t\tdisplay version information and exit" + echo -e " -d, --debug\t\t\tbuild with debug information" + echo -e " -s, --speed\t\t\toptimize for speed instead of size" + echo -e " -l, --lts\t\t\tbuild lts packages to support sdk 9.2+ devices" + echo -e " -f, --force\t\t\tignore warnings and build with given options\n" + + echo -e "Licensing options:" + + echo -e " --enable-gpl\t\t\tallow use of GPL libraries, resulting libs will be licensed under GPLv3.0 [no]\n" + + echo -e "Platforms:" + + echo -e " --disable-arm64\t\tdo not build arm64 platform [yes]" + echo -e " --disable-x86-64\t\tdo not build x86-64 platform [yes]\n" + + echo -e "Libraries:" + + echo -e " --full\t\t\tenables all non-GPL external libraries" + echo -e " --enable-tvos-audiotoolbox\tbuild with built-in Apple AudioToolbox support[no]" + echo -e " --enable-tvos-coreimage\tbuild with built-in Apple CoreImage support[no]" + echo -e " --enable-tvos-bzip2\t\tbuild with built-in bzip2 support[no]" + if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then + echo -e " --enable-tvos-videotoolbox\tbuild with built-in Apple VideoToolbox support[no]" + fi + echo -e " --enable-tvos-zlib\t\tbuild with built-in zlib [no]" + echo -e " --enable-tvos-libiconv\tbuild with built-in libiconv [no]" + echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]" + echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]" + echo -e " --enable-freetype\t\tbuild with freetype [no]" + echo -e " --enable-fribidi\t\tbuild with fribidi [no]" + echo -e " --enable-gmp\t\t\tbuild with gmp [no]" + echo -e " --enable-gnutls\t\tbuild with gnutls [no]" + echo -e " --enable-kvazaar\t\tbuild with kvazaar [no]" + echo -e " --enable-lame\t\t\tbuild with lame [no]" + echo -e " --enable-libaom\t\tbuild with libaom [no]" + echo -e " --enable-libass\t\tbuild with libass [no]" + echo -e " --enable-libilbc\t\tbuild with libilbc [no]" + echo -e " --enable-libtheora\t\tbuild with libtheora [no]" + echo -e " --enable-libvorbis\t\tbuild with libvorbis [no]" + echo -e " --enable-libvpx\t\tbuild with libvpx [no]" + echo -e " --enable-libwebp\t\tbuild with libwebp [no]" + echo -e " --enable-libxml2\t\tbuild with libxml2 [no]" + echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]" + echo -e " --enable-openh264\t\tbuild with openh264 [no]" + echo -e " --enable-opus\t\t\tbuild with opus [no]" + echo -e " --enable-sdl\t\t\tbuild with sdl [no]" + echo -e " --enable-shine\t\tbuild with shine [no]" + echo -e " --enable-snappy\t\tbuild with snappy [no]" + echo -e " --enable-soxr\t\t\tbuild with soxr [no]" + echo -e " --enable-speex\t\tbuild with speex [no]" + echo -e " --enable-tesseract\t\tbuild with tesseract [no]" + echo -e " --enable-twolame\t\tbuild with twolame [no]" + echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n" + + echo -e "GPL libraries:" + + echo -e " --enable-libvidstab\t\tbuild with libvidstab [no]" + echo -e " --enable-rubberband\t\tbuild with rubber band [no]" + echo -e " --enable-x264\t\t\tbuild with x264 [no]" + echo -e " --enable-x265\t\t\tbuild with x265 [no]" + echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n" + + echo -e "Advanced options:" + + echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]" + echo -e " --rebuild-LIBRARY\t\tbuild LIBRARY even it is detected as already built [no]\n" } display_version() { - COMMAND=`echo $0 | sed -e 's/\.\///g'` + COMMAND=$(echo $0 | sed -e 's/\.\///g') - echo -e "\ + echo -e "\ $COMMAND v$(get_mobile_ffmpeg_version)\n\ -Copyright (c) 2019 Taner Sener\n\ +Copyright (c) 2019-2020 Taner Sener\n\ License LGPLv3.0: GNU LGPL version 3 or later\n\ \n\ This is free software: you can redistribute it and/or modify it under the terms of the \ @@ -182,402 +182,395 @@ either version 3 of the License, or (at your option) any later version." } skip_library() { - SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") + SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g") - export ${SKIP_VARIABLE}=1 + export ${SKIP_VARIABLE}=1 } no_output_redirection() { - export NO_OUTPUT_REDIRECTION=1 + export NO_OUTPUT_REDIRECTION=1 } no_workspace_cleanup_library() { - NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") + NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g") - export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1 + export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1 } enable_debug() { - export MOBILE_FFMPEG_DEBUG="-g" + export MOBILE_FFMPEG_DEBUG="-g" - BUILD_TYPE_ID+="debug " + BUILD_TYPE_ID+="debug " } optimize_for_speed() { - export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" + export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1" } enable_lts_build() { - export MOBILE_FFMPEG_LTS_BUILD="1" + export MOBILE_FFMPEG_LTS_BUILD="1" - # XCODE 7.3 HAS TVOS SDK 9.2 - export TVOS_MIN_VERSION=9.2 + # XCODE 7.3 HAS TVOS SDK 9.2 + export TVOS_MIN_VERSION=9.2 - # TVOS SDK 9.2 DOES NOT INCLUDE VIDEOTOOLBOX - ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=0 + # TVOS SDK 9.2 DOES NOT INCLUDE VIDEOTOOLBOX + ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=0 } reconf_library() { - local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") - local library_supported=0 - - for library in {1..42} - do - library_name=$(get_library_name $((library - 1))) + local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g") + local library_supported=0 - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${RECONF_VARIABLE}=1 - RECONF_LIBRARIES+=($1) - library_supported=1 - fi - done + for library in {1..42}; do + library_name=$(get_library_name $((library - 1))) - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then + export ${RECONF_VARIABLE}=1 + RECONF_LIBRARIES+=($1) + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + fi } rebuild_library() { - local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") - local library_supported=0 - - for library in {1..42} - do - library_name=$(get_library_name $((library - 1))) + local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g") + local library_supported=0 - if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then - export ${REBUILD_VARIABLE}=1 - REBUILD_LIBRARIES+=($1) - library_supported=1 - fi - done + for library in {1..42}; do + library_name=$(get_library_name $((library - 1))) - if [[ ${library_supported} -eq 0 ]]; then - echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then + export ${REBUILD_VARIABLE}=1 + REBUILD_LIBRARIES+=($1) + library_supported=1 fi + done + + if [[ ${library_supported} -eq 0 ]]; then + echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1 + fi } enable_library() { - set_library $1 1 + set_library $1 1 } set_library() { - case $1 in - tvos-zlib) - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - tvos-audiotoolbox) - ENABLED_LIBRARIES[LIBRARY_AUDIOTOOLBOX]=$2 - ;; - tvos-coreimage) - ENABLED_LIBRARIES[LIBRARY_COREIMAGE]=$2 - ;; - tvos-bzip2) - ENABLED_LIBRARIES[LIBRARY_BZIP2]=$2 - ;; - tvos-videotoolbox) - ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=$2 - ;; - tvos-libiconv) - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - ;; - tvos-libuuid) - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ;; - chromaprint) - ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 - ;; - fontconfig) - ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 - set_library "freetype" $2 - ;; - freetype) - ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "libpng" $2 - ;; - fribidi) - ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 - ;; - gmp) - ENABLED_LIBRARIES[LIBRARY_GMP]=$2 - ;; - gnutls) - ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "nettle" $2 - set_library "gmp" $2 - set_library "tvos-libiconv" $2 - ;; - kvazaar) - ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 - ;; - lame) - ENABLED_LIBRARIES[LIBRARY_LAME]=$2 - set_library "tvos-libiconv" $2 - ;; - libaom) - ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 - ;; - libass) - ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 - ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 - set_library "freetype" $2 - set_library "fribidi" $2 - set_library "fontconfig" $2 - set_library "tvos-libiconv" $2 - ;; - libilbc) - ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 - ;; - libpng) - ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - libtheora) - ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - set_library "libvorbis" $2 - ;; - libvidstab) - ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 - ;; - libvorbis) - ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 - ;; - libvpx) - ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 - ;; - libwebp) - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - libxml2) - ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 - set_library "tvos-libiconv" $2 - ;; - opencore-amr) - ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 - ;; - openh264) - ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 - ;; - opus) - ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 - ;; - rubberband) - ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 - ;; - sdl) - ENABLED_LIBRARIES[LIBRARY_SDL]=$2 - ;; - shine) - ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 - ;; - snappy) - ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - ;; - soxr) - ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 - ;; - speex) - ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 - ;; - tesseract) - ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 - ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 - ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 - ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 - set_library "tiff" $2 - set_library "libpng" $2 - ;; - twolame) - ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 - ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 - ;; - wavpack) - ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 - ;; - x264) - ENABLED_LIBRARIES[LIBRARY_X264]=$2 - ;; - x265) - ENABLED_LIBRARIES[LIBRARY_X265]=$2 - ;; - xvidcore) - ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 - ;; - expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile) - # THESE LIBRARIES ARE NOT ENABLED DIRECTLY - ;; - nettle) - ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 - set_library "gmp" $2 - ;; - tiff) - ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 - ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 - ;; - *) - print_unknown_library $1 - ;; - esac + case $1 in + tvos-zlib) + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + tvos-audiotoolbox) + ENABLED_LIBRARIES[LIBRARY_AUDIOTOOLBOX]=$2 + ;; + tvos-coreimage) + ENABLED_LIBRARIES[LIBRARY_COREIMAGE]=$2 + ;; + tvos-bzip2) + ENABLED_LIBRARIES[LIBRARY_BZIP2]=$2 + ;; + tvos-videotoolbox) + ENABLED_LIBRARIES[LIBRARY_VIDEOTOOLBOX]=$2 + ;; + tvos-libiconv) + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + ;; + tvos-libuuid) + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ;; + chromaprint) + ENABLED_LIBRARIES[LIBRARY_CHROMAPRINT]=$2 + ;; + fontconfig) + ENABLED_LIBRARIES[LIBRARY_FONTCONFIG]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBICONV]=$2 + set_library "freetype" $2 + ;; + freetype) + ENABLED_LIBRARIES[LIBRARY_FREETYPE]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "libpng" $2 + ;; + fribidi) + ENABLED_LIBRARIES[LIBRARY_FRIBIDI]=$2 + ;; + gmp) + ENABLED_LIBRARIES[LIBRARY_GMP]=$2 + ;; + gnutls) + ENABLED_LIBRARIES[LIBRARY_GNUTLS]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "nettle" $2 + set_library "gmp" $2 + set_library "tvos-libiconv" $2 + ;; + kvazaar) + ENABLED_LIBRARIES[LIBRARY_KVAZAAR]=$2 + ;; + lame) + ENABLED_LIBRARIES[LIBRARY_LAME]=$2 + set_library "tvos-libiconv" $2 + ;; + libaom) + ENABLED_LIBRARIES[LIBRARY_LIBAOM]=$2 + ;; + libass) + ENABLED_LIBRARIES[LIBRARY_LIBASS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBUUID]=$2 + ENABLED_LIBRARIES[LIBRARY_EXPAT]=$2 + set_library "freetype" $2 + set_library "fribidi" $2 + set_library "fontconfig" $2 + set_library "tvos-libiconv" $2 + ;; + libilbc) + ENABLED_LIBRARIES[LIBRARY_LIBILBC]=$2 + ;; + libpng) + ENABLED_LIBRARIES[LIBRARY_LIBPNG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + libtheora) + ENABLED_LIBRARIES[LIBRARY_LIBTHEORA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + set_library "libvorbis" $2 + ;; + libvidstab) + ENABLED_LIBRARIES[LIBRARY_LIBVIDSTAB]=$2 + ;; + libvorbis) + ENABLED_LIBRARIES[LIBRARY_LIBVORBIS]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBOGG]=$2 + ;; + libvpx) + ENABLED_LIBRARIES[LIBRARY_LIBVPX]=$2 + ;; + libwebp) + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + set_library "tiff" $2 + set_library "libpng" $2 + ;; + libxml2) + ENABLED_LIBRARIES[LIBRARY_LIBXML2]=$2 + set_library "tvos-libiconv" $2 + ;; + opencore-amr) + ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2 + ;; + openh264) + ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2 + ;; + opus) + ENABLED_LIBRARIES[LIBRARY_OPUS]=$2 + ;; + rubberband) + ENABLED_LIBRARIES[LIBRARY_RUBBERBAND]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBSAMPLERATE]=$2 + ;; + sdl) + ENABLED_LIBRARIES[LIBRARY_SDL]=$2 + ;; + shine) + ENABLED_LIBRARIES[LIBRARY_SHINE]=$2 + ;; + snappy) + ENABLED_LIBRARIES[LIBRARY_SNAPPY]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + ;; + soxr) + ENABLED_LIBRARIES[LIBRARY_SOXR]=$2 + ;; + speex) + ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2 + ;; + tesseract) + ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2 + ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2 + ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2 + ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2 + set_library "tiff" $2 + set_library "libpng" $2 + ;; + twolame) + ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2 + ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2 + ;; + wavpack) + ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2 + ;; + x264) + ENABLED_LIBRARIES[LIBRARY_X264]=$2 + ;; + x265) + ENABLED_LIBRARIES[LIBRARY_X265]=$2 + ;; + xvidcore) + ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2 + ;; + expat | giflib | jpeg | leptonica | libogg | libsamplerate | libsndfile) + # THESE LIBRARIES ARE NOT ENABLED DIRECTLY + ;; + nettle) + ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2 + set_library "gmp" $2 + ;; + tiff) + ENABLED_LIBRARIES[LIBRARY_TIFF]=$2 + ENABLED_LIBRARIES[LIBRARY_JPEG]=$2 + ;; + *) + print_unknown_library $1 + ;; + esac } disable_arch() { - set_arch $1 0 + set_arch $1 0 } set_arch() { - case $1 in - arm64) - ENABLED_ARCHITECTURES[ARCH_ARM64]=$2 - ;; - x86-64) - ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 - ;; - *) - print_unknown_platform $1 - ;; - esac + case $1 in + arm64) + ENABLED_ARCHITECTURES[ARCH_ARM64]=$2 + ;; + x86-64) + ENABLED_ARCHITECTURES[ARCH_X86_64]=$2 + ;; + *) + print_unknown_platform $1 + ;; + esac } print_unknown_option() { - echo -e "Unknown option \"$1\".\nSee $0 --help for available options." - exit 1 + echo -e "Unknown option \"$1\".\nSee $0 --help for available options." + exit 1 } print_unknown_library() { - echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." - exit 1 + echo -e "Unknown library \"$1\".\nSee $0 --help for available libraries." + exit 1 } print_unknown_platform() { - echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." - exit 1 + echo -e "Unknown platform \"$1\".\nSee $0 --help for available platforms." + exit 1 } print_enabled_architectures() { - echo -n "Architectures: " - - let enabled=0; - for print_arch in {0..1} - do - if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_arch_name $print_arch) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Architectures: " + + let enabled=0 + for print_arch in {0..1}; do + if [[ ${ENABLED_ARCHITECTURES[$print_arch]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_arch_name $print_arch) + enabled=$((${enabled} + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_enabled_libraries() { - echo -n "Libraries: " - - let enabled=0; - - # FIRST BUILT-IN LIBRARIES - for library in {42..48} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - # THEN EXTERNAL LIBRARIES - for library in {0..31} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - if [[ ${enabled} -ge 1 ]]; then - echo -n ", " - fi - echo -n $(get_library_name $library) - enabled=$((${enabled} + 1)); - fi - done - - if [ ${enabled} -gt 0 ]; then - echo "" - else - echo "none" + echo -n "Libraries: " + + let enabled=0 + + # FIRST BUILT-IN LIBRARIES + for library in {42..48}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_library_name $library) + enabled=$((${enabled} + 1)) + fi + done + + # THEN EXTERNAL LIBRARIES + for library in {0..31}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + if [[ ${enabled} -ge 1 ]]; then + echo -n ", " + fi + echo -n $(get_library_name $library) + enabled=$((${enabled} + 1)) fi + done + + if [ ${enabled} -gt 0 ]; then + echo "" + else + echo "none" + fi } print_reconfigure_requested_libraries() { - local counter=0; - - for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Reconfigure: " - else - echo -n ", " - fi + local counter=0 - echo -n ${RECONF_LIBRARY} + for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Reconfigure: " + else + echo -n ", " + fi - counter=$((${counter} + 1)); - done + echo -n ${RECONF_LIBRARY} - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + counter=$((${counter} + 1)) + done + + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } print_rebuild_requested_libraries() { - local counter=0; - - for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}" - do - if [[ ${counter} -eq 0 ]]; then - echo -n "Rebuild: " - else - echo -n ", " - fi + local counter=0 - echo -n ${REBUILD_LIBRARY} + for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}"; do + if [[ ${counter} -eq 0 ]]; then + echo -n "Rebuild: " + else + echo -n ", " + fi - counter=$((${counter} + 1)); - done + echo -n ${REBUILD_LIBRARY} - if [[ ${counter} -gt 0 ]]; then - echo "" - fi + counter=$((${counter} + 1)) + done + + if [[ ${counter} -gt 0 ]]; then + echo "" + fi } build_info_plist() { - local FILE_PATH="$1" - local FRAMEWORK_NAME="$2" - local FRAMEWORK_ID="$3" - local FRAMEWORK_SHORT_VERSION="$4" - local FRAMEWORK_VERSION="$5" + local FILE_PATH="$1" + local FRAMEWORK_NAME="$2" + local FRAMEWORK_ID="$3" + local FRAMEWORK_SHORT_VERSION="$4" + local FRAMEWORK_VERSION="$5" - cat > ${FILE_PATH} <${FILE_PATH} < @@ -614,9 +607,9 @@ EOF } build_modulemap() { - local FILE_PATH="$1" + local FILE_PATH="$1" - cat > ${FILE_PATH} <${FILE_PATH} <>${BASEDIR}/build.log 2>&1 + mkdir -p ${FAT_LIBRARY_PATH}/lib 1>>${BASEDIR}/build.log 2>&1 - LIPO_COMMAND="${LIPO} -create" + LIPO_COMMAND="${LIPO} -create" - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" $(find ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin -name $1)" - done + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" $(find ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin -name $1)" + done - LIPO_COMMAND+=" -output ${FAT_LIBRARY_PATH}/lib/$1" + LIPO_COMMAND+=" -output ${FAT_LIBRARY_PATH}/lib/$1" - RC=$(${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1) + RC=$(${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1) - echo ${RC} + echo ${RC} } # 1 - library name # 2 - static library name # 3 - library version create_static_framework() { - local FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/$1.framework + local FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/$1.framework - mkdir -p ${FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 - local CAPITAL_CASE_LIBRARY_NAME=$(to_capital_case $1) + local CAPITAL_CASE_LIBRARY_NAME=$(to_capital_case $1) - build_info_plist "${FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${CAPITAL_CASE_LIBRARY_NAME}" "$3" "$3" + build_info_plist "${FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${CAPITAL_CASE_LIBRARY_NAME}" "$3" "$3" - cp ${BASEDIR}/prebuilt/tvos-universal/$1-universal/lib/$2 ${FRAMEWORK_PATH}/$1 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/prebuilt/tvos-universal/$1-universal/lib/$2 ${FRAMEWORK_PATH}/$1 1>>${BASEDIR}/build.log 2>&1 - echo "$?" + echo "$?" } get_external_library_license_path() { - case $1 in - 1) echo "${BASEDIR}/src/$(get_library_name $1)/docs/LICENSE.TXT" ;; - 3) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; - 25) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LGPL" ;; - 27) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md" ;; - 29) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.txt" ;; - 33) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md " ;; - 36) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; - 37) echo "${BASEDIR}/src/$(get_library_name $1)/COPYRIGHT" ;; - 40) echo "${BASEDIR}/src/$(get_library_name $1)/leptonica-license.txt" ;; - 4 | 9 | 12 | 18 | 20 | 26 | 31 | 35) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE" ;; - *) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING" ;; - esac + case $1 in + 1) echo "${BASEDIR}/src/$(get_library_name $1)/docs/LICENSE.TXT" ;; + 3) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; + 25) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LGPL" ;; + 27) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md" ;; + 29) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.txt" ;; + 33) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE.md " ;; + 36) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING.LESSERv3" ;; + 37) echo "${BASEDIR}/src/$(get_library_name $1)/COPYRIGHT" ;; + 40) echo "${BASEDIR}/src/$(get_library_name $1)/leptonica-license.txt" ;; + 4 | 9 | 12 | 18 | 20 | 26 | 31 | 35) echo "${BASEDIR}/src/$(get_library_name $1)/LICENSE" ;; + *) echo "${BASEDIR}/src/$(get_library_name $1)/COPYING" ;; + esac } get_external_library_version() { - echo "$(grep Version ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/pkgconfig/$1.pc 2>>${BASEDIR}/build.log | sed 's/Version://g;s/\ //g')" + echo "$(grep Version ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/pkgconfig/$1.pc 2>>${BASEDIR}/build.log | sed 's/Version://g;s/\ //g')" } # ENABLE COMMON FUNCTIONS . ${BASEDIR}/build/tvos-common.sh -echo -e "\nINFO: Build options: $@\n" 1>>${BASEDIR}/build.log 2>&1 +echo -e "\nINFO: Build options: $*\n" 1>>${BASEDIR}/build.log 2>&1 GPL_ENABLED="no" DISPLAY_HELP="" @@ -704,110 +696,108 @@ BUILD_TYPE_ID="" BUILD_FORCE="" BUILD_VERSION=$(git describe --tags 2>>${BASEDIR}/build.log) -while [ ! $# -eq 0 ] -do - case $1 in - -h | --help) - DISPLAY_HELP="1" - ;; - -v | --version) - display_version - exit 0 - ;; - --skip-*) - SKIP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - skip_library ${SKIP_LIBRARY} - ;; - --no-output-redirection) - no_output_redirection - ;; - --no-workspace-cleanup-*) - NO_WORKSPACE_CLEANUP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g'` - - no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY} - ;; - -d | --debug) - enable_debug - ;; - -s | --speed) - optimize_for_speed - ;; - -l | --lts) - BUILD_LTS="1" - ;; - -f | --force) - BUILD_FORCE="1" - ;; - --reconf-*) - CONF_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - reconf_library ${CONF_LIBRARY} - ;; - --rebuild-*) - BUILD_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - rebuild_library ${BUILD_LIBRARY} - ;; - --full) - for library in {0..48} - do - if [[ $library -ne 17 ]] && [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then - enable_library $(get_library_name $library) - fi - done - ;; - --enable-gpl) - GPL_ENABLED="yes" - ;; - --enable-*) - ENABLED_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - enable_library ${ENABLED_LIBRARY} - ;; - --disable-*) - DISABLED_ARCH=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'` - - disable_arch ${DISABLED_ARCH} - ;; - *) - print_unknown_option $1 - ;; - esac - shift -done; +while [ ! $# -eq 0 ]; do + case $1 in + -h | --help) + DISPLAY_HELP="1" + ;; + -v | --version) + display_version + exit 0 + ;; + --skip-*) + SKIP_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + skip_library ${SKIP_LIBRARY} + ;; + --no-output-redirection) + no_output_redirection + ;; + --no-workspace-cleanup-*) + NO_WORKSPACE_CLEANUP_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g') + + no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY} + ;; + -d | --debug) + enable_debug + ;; + -s | --speed) + optimize_for_speed + ;; + -l | --lts) + BUILD_LTS="1" + ;; + -f | --force) + BUILD_FORCE="1" + ;; + --reconf-*) + CONF_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + reconf_library ${CONF_LIBRARY} + ;; + --rebuild-*) + BUILD_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + rebuild_library ${BUILD_LIBRARY} + ;; + --full) + for library in {0..48}; do + if [[ $library -ne 17 ]] && [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then + enable_library $(get_library_name $library) + fi + done + ;; + --enable-gpl) + GPL_ENABLED="yes" + ;; + --enable-*) + ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + enable_library ${ENABLED_LIBRARY} + ;; + --disable-*) + DISABLED_ARCH=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g') + + disable_arch ${DISABLED_ARCH} + ;; + *) + print_unknown_option $1 + ;; + esac + shift +done # DETECT BUILD TYPE if [[ ! -z ${BUILD_LTS} ]]; then - enable_lts_build - BUILD_TYPE_ID+="LTS " + enable_lts_build + BUILD_TYPE_ID+="LTS " fi if [[ ! -z ${DISPLAY_HELP} ]]; then - display_help - exit 0 + display_help + exit 0 fi # SELECT XCODE VERSION USED FOR BUILDING XCODE_FOR_MOBILE_FFMPEG=~/.xcode.for.mobile.ffmpeg.sh if [[ -f ${XCODE_FOR_MOBILE_FFMPEG} ]]; then - source ${XCODE_FOR_MOBILE_FFMPEG} 1>>${BASEDIR}/build.log 2>&1 + source ${XCODE_FOR_MOBILE_FFMPEG} 1>>${BASEDIR}/build.log 2>&1 fi DETECTED_TVOS_SDK_VERSION="$(xcrun --sdk appletvos --show-sdk-version)" echo -e "INFO: Using SDK ${DETECTED_TVOS_SDK_VERSION} by Xcode provided at $(xcode-select -p)\n" 1>>${BASEDIR}/build.log 2>&1 if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]] && [[ "${DETECTED_TVOS_SDK_VERSION}" != "${TVOS_MIN_VERSION}" ]]; then - echo -e "\n(*) LTS packages should be built using SDK ${TVOS_MIN_VERSION} but current configuration uses SDK ${DETECTED_TVOS_SDK_VERSION}\n" + echo -e "\n(*) LTS packages should be built using SDK ${TVOS_MIN_VERSION} but current configuration uses SDK ${DETECTED_TVOS_SDK_VERSION}\n" - if [[ -z ${BUILD_FORCE} ]]; then - exit 1 - fi + if [[ -z ${BUILD_FORCE} ]]; then + exit 1 + fi fi echo -e "\nBuilding mobile-ffmpeg ${BUILD_TYPE_ID}static library for tvOS\n" echo -e -n "INFO: Building mobile-ffmpeg ${BUILD_VERSION} ${BUILD_TYPE_ID}for tvOS: " 1>>${BASEDIR}/build.log 2>&1 -echo -e `date` 1>>${BASEDIR}/build.log 2>&1 +echo -e $(date) 1>>${BASEDIR}/build.log 2>&1 print_enabled_architectures print_enabled_libraries @@ -815,552 +805,546 @@ print_reconfigure_requested_libraries print_rebuild_requested_libraries # CHECKING GPL LIBRARIES -for gpl_library in {17..21} -do - if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then - library_name=$(get_library_name ${gpl_library}) - - if [ ${GPL_ENABLED} != "yes" ]; then - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" - echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - else - DOWNLOAD_RESULT=$(download_gpl_library_source ${library_name}) - if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then - echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" - echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>${BASEDIR}/build.log 2>&1 - exit 1 - fi - fi +for gpl_library in {17..21}; do + if [[ ${ENABLED_LIBRARIES[$gpl_library]} -eq 1 ]]; then + library_name=$(get_library_name ${gpl_library}) + + if [ ${GPL_ENABLED} != "yes" ]; then + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" + echo -e "\n(*) Invalid configuration detected. GPL library ${library_name} enabled without --enable-gpl flag.\n" 1>>${BASEDIR}/build.log 2>&1 + exit 1 + else + DOWNLOAD_RESULT=$(download_gpl_library_source ${library_name}) + if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then + echo -e "\n(*) Failed to download GPL library ${library_name} source. Please check build.log file for details. If the problem persists refer to offline building instructions.\n" + echo -e "\n(*) Failed to download GPL library ${library_name} source.\n" 1>>${BASEDIR}/build.log 2>&1 + exit 1 + fi fi + fi done TARGET_ARCH_LIST=() -for run_arch in {0..1} -do - if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then - export ARCH=$(get_arch_name $run_arch) - export TARGET_SDK=$(get_target_sdk) - export SDK_PATH=$(get_sdk_path) - export SDK_NAME=$(get_sdk_name) - - export LIPO="$(xcrun --sdk $(get_sdk_name) -f lipo)" - - . ${BASEDIR}/build/main-tvos.sh "${ENABLED_LIBRARIES[@]}" - case ${ARCH} in - x86-64) - TARGET_ARCH="x86_64" - ;; - *) - TARGET_ARCH="${ARCH}" - ;; - esac - TARGET_ARCH_LIST+=(${TARGET_ARCH}) - - # CLEAR FLAGS - for library in {1..47} - do - library_name=$(get_library_name $((library - 1))) - unset $(echo "OK_${library_name}" | sed "s/\-/\_/g") - unset $(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g") - done - fi +for run_arch in {0..1}; do + if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then + export ARCH=$(get_arch_name $run_arch) + export TARGET_SDK=$(get_target_sdk) + export SDK_PATH=$(get_sdk_path) + export SDK_NAME=$(get_sdk_name) + + export LIPO="$(xcrun --sdk $(get_sdk_name) -f lipo)" + + . ${BASEDIR}/build/main-tvos.sh "${ENABLED_LIBRARIES[@]}" + case ${ARCH} in + x86-64) + TARGET_ARCH="x86_64" + ;; + *) + TARGET_ARCH="${ARCH}" + ;; + esac + TARGET_ARCH_LIST+=(${TARGET_ARCH}) + + # CLEAR FLAGS + for library in {1..47}; do + library_name=$(get_library_name $((library - 1))) + unset $(echo "OK_${library_name}" | sed "s/\-/\_/g") + unset $(echo "DEPENDENCY_REBUILT_${library_name}" | sed "s/\-/\_/g") + done + fi done FFMPEG_LIBS="libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale" -BUILD_LIBRARY_EXTENSION="a"; +BUILD_LIBRARY_EXTENSION="a" if [[ ! -z ${TARGET_ARCH_LIST} ]]; then - echo -e -n "\n\nCreating frameworks and universal libraries under prebuilt: " - - # BUILDING UNIVERSAL LIBRARIES - rm -rf ${BASEDIR}/prebuilt/tvos-universal 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${BASEDIR}/prebuilt/tvos-universal 1>>${BASEDIR}/build.log 2>&1 - rm -rf ${BASEDIR}/prebuilt/tvos-framework 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${BASEDIR}/prebuilt/tvos-framework 1>>${BASEDIR}/build.log 2>&1 - - # 1. EXTERNAL LIBRARIES - for library in {0..41} - do - if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then - - library_name=$(get_library_name ${library}) - package_config_file_name=$(get_package_config_file_name ${library}) - library_version=$(get_external_library_version ${package_config_file_name}) - capital_case_library_name=$(to_capital_case ${library_name}) - if [[ -z ${library_version} ]]; then - echo -e "Failed to detect version for ${library_name} from ${package_config_file_name}.pc\n" 1>>${BASEDIR}/build.log 2>&1 - echo -e "failed\n" - exit 1 - fi - - echo -e "Creating universal library for ${library_name}\n" 1>>${BASEDIR}/build.log 2>&1 - - if [[ ${LIBRARY_LIBTHEORA} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libtheora.a" "libtheora") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libtheoraenc.a" "libtheoraenc") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libtheoradec.a" "libtheoradec") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheora" "libtheora.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheoraenc" "libtheoraenc.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libtheoradec" "libtheoradec.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheora-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheoraenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheoradec-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheora.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheoraenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheoradec.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_LIBVORBIS} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libvorbisfile.a" "libvorbisfile") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libvorbisenc.a" "libvorbisenc") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libvorbis.a" "libvorbis") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbisfile" "libvorbisfile.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbisenc" "libvorbisenc.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libvorbis" "libvorbis.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbisfile-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbisenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbis-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbisfile.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbisenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbis.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_LIBWEBP} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libwebpdecoder.a" "libwebpdecoder") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libwebpdemux.a" "libwebpdemux") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libwebp.a" "libwebp") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebpdecoder" "libwebpdecoder.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebpdemux" "libwebpdemux.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libwebp" "libwebp.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebpdecoder-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebpdemux-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebp-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebpdecoder.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebpdemux.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebp.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - - elif [[ ${LIBRARY_OPENCOREAMR} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrwb.a" "libopencore-amrwb") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrnb.a" "libopencore-amrnb") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrwb" "libopencore-amrwb.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrnb" "libopencore-amrnb.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libopencore-amrwb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libopencore-amrnb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libopencore-amrwb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libopencore-amrnb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - elif [[ ${LIBRARY_NETTLE} == $library ]]; then - - LIBRARY_CREATED=$(create_static_fat_library "libnettle.a" "libnettle") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - LIBRARY_CREATED=$(create_static_fat_library "libhogweed.a" "libhogweed") - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libnettle" "libnettle.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework "libhogweed" "libhogweed.a" $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libnettle-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libhogweed-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libnettle.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libhogweed.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - else - library_name=$(get_library_name $((library))) - static_archive_name=$(get_static_archive_name $((library))) - LIBRARY_CREATED=$(create_static_fat_library $static_archive_name $library_name) - if [[ ${LIBRARY_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - FRAMEWORK_CREATED=$(create_static_framework $library_name $static_archive_name $library_version) - if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/${library_name}-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/${library_name}.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) - if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 - fi - - fi + echo -e -n "\n\nCreating frameworks and universal libraries under prebuilt: " + + # BUILDING UNIVERSAL LIBRARIES + rm -rf ${BASEDIR}/prebuilt/tvos-universal 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${BASEDIR}/prebuilt/tvos-universal 1>>${BASEDIR}/build.log 2>&1 + rm -rf ${BASEDIR}/prebuilt/tvos-framework 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${BASEDIR}/prebuilt/tvos-framework 1>>${BASEDIR}/build.log 2>&1 + + # 1. EXTERNAL LIBRARIES + for library in {0..41}; do + if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then + + library_name=$(get_library_name ${library}) + package_config_file_name=$(get_package_config_file_name ${library}) + library_version=$(get_external_library_version ${package_config_file_name}) + capital_case_library_name=$(to_capital_case ${library_name}) + if [[ -z ${library_version} ]]; then + echo -e "Failed to detect version for ${library_name} from ${package_config_file_name}.pc\n" 1>>${BASEDIR}/build.log 2>&1 + echo -e "failed\n" + exit 1 + fi + + echo -e "Creating universal library for ${library_name}\n" 1>>${BASEDIR}/build.log 2>&1 + + if [[ ${LIBRARY_LIBTHEORA} == $library ]]; then + LIBRARY_CREATED=$(create_static_fat_library "libtheora.a" "libtheora") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 fi - done - # 2. FFMPEG - FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/tvos-universal/ffmpeg-universal - mkdir -p ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 + LIBRARY_CREATED=$(create_static_fat_library "libtheoraenc.a" "libtheoraenc") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - cp -r ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/ffmpeg/include/* ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/ffmpeg/include/config.h ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + LIBRARY_CREATED=$(create_static_fat_library "libtheoradec.a" "libtheoradec") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - for FFMPEG_LIB in ${FFMPEG_LIBS} - do - LIPO_COMMAND="${LIPO} -create" + FRAMEWORK_CREATED=$(create_static_framework "libtheora" "libtheora.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin/ffmpeg/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" - done + FRAMEWORK_CREATED=$(create_static_framework "libtheoraenc" "libtheoraenc.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - LIPO_COMMAND+=" -output ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" + FRAMEWORK_CREATED=$(create_static_framework "libtheoradec" "libtheoradec.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - ${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1 + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheora-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheoraenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 + echo -e "failed\n" + exit 1 fi - FFMPEG_LIB_UPPERCASE=$(echo ${FFMPEG_LIB} | tr '[a-z]' '[A-Z]') - FFMPEG_LIB_CAPITALCASE=$(to_capital_case ${FFMPEG_LIB}) + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libtheoradec-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - FFMPEG_LIB_MAJOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR//g;s/\ //g") - FFMPEG_LIB_MINOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR//g;s/\ //g") - FFMPEG_LIB_MICRO=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO//g;s/\ //g") + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheora.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - FFMPEG_LIB_VERSION="${FFMPEG_LIB_MAJOR}.${FFMPEG_LIB_MINOR}.${FFMPEG_LIB_MICRO}" + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheoraenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - FFMPEG_LIB_FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/${FFMPEG_LIB}.framework + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libtheoradec.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi - rm -rf ${FFMPEG_LIB_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + elif [[ ${LIBRARY_LIBVORBIS} == $library ]]; then - cp -r ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/* ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - cp ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION} ${FFMPEG_LIB_FRAMEWORK_PATH}/${FFMPEG_LIB} 1>>${BASEDIR}/build.log 2>&1 + LIBRARY_CREATED=$(create_static_fat_library "libvorbisfile.a" "libvorbisfile") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then + LIBRARY_CREATED=$(create_static_fat_library "libvorbisenc.a" "libvorbisenc") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - # GPLv3.0 - cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - else + LIBRARY_CREATED=$(create_static_fat_library "libvorbis.a" "libvorbis") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - # LGPLv3.0 - cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + FRAMEWORK_CREATED=$(create_static_framework "libvorbisfile" "libvorbisfile.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 fi - build_info_plist "${FFMPEG_LIB_FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${FFMPEG_LIB_CAPITALCASE}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" + FRAMEWORK_CREATED=$(create_static_framework "libvorbisenc" "libvorbisenc.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi - echo -e "Created ${FFMPEG_LIB} framework successfully.\n" 1>>${BASEDIR}/build.log 2>&1 - done + FRAMEWORK_CREATED=$(create_static_framework "libvorbis" "libvorbis.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbisfile-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbisenc-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libvorbis-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbisfile.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbisenc.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libvorbis.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + elif [[ ${LIBRARY_LIBWEBP} == $library ]]; then + + LIBRARY_CREATED=$(create_static_fat_library "libwebpdecoder.a" "libwebpdecoder") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_static_fat_library "libwebpdemux.a" "libwebpdemux") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_static_fat_library "libwebp.a" "libwebp") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libwebpdecoder" "libwebpdecoder.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libwebpdemux" "libwebpdemux.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libwebp" "libwebp.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebpdecoder-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebpdemux-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libwebp-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebpdecoder.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebpdemux.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libwebp.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + elif + [[ ${LIBRARY_OPENCOREAMR} == $library ]] + then + + LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrwb.a" "libopencore-amrwb") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_static_fat_library "libopencore-amrnb.a" "libopencore-amrnb") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrwb" "libopencore-amrwb.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libopencore-amrnb" "libopencore-amrnb.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libopencore-amrwb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libopencore-amrnb-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libopencore-amrwb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libopencore-amrnb.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + elif [[ ${LIBRARY_NETTLE} == $library ]]; then + + LIBRARY_CREATED=$(create_static_fat_library "libnettle.a" "libnettle") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + LIBRARY_CREATED=$(create_static_fat_library "libhogweed.a" "libhogweed") + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libnettle" "libnettle.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework "libhogweed" "libhogweed.a" $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libnettle-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/libhogweed-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libnettle.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/libhogweed.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + else + library_name=$(get_library_name $((library))) + static_archive_name=$(get_static_archive_name $((library))) + LIBRARY_CREATED=$(create_static_fat_library $static_archive_name $library_name) + if [[ ${LIBRARY_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + FRAMEWORK_CREATED=$(create_static_framework $library_name $static_archive_name $library_version) + if [[ ${FRAMEWORK_CREATED} -ne 0 ]]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-universal/${library_name}-universal/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + $(cp $(get_external_library_license_path ${library}) ${BASEDIR}/prebuilt/tvos-framework/${library_name}.framework/LICENSE 1>>${BASEDIR}/build.log 2>&1) + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + fi - # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then - cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - else - cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 fi + done - # 3. MOBILE FFMPEG - MOBILE_FFMPEG_VERSION=$(get_mobile_ffmpeg_version) - MOBILE_FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/tvos-universal/mobile-ffmpeg-universal - MOBILE_FFMPEG_FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/mobileffmpeg.framework - mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 - rm -rf ${MOBILE_FFMPEG_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules 1>>${BASEDIR}/build.log 2>&1 + # 2. FFMPEG + FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/tvos-universal/ffmpeg-universal + mkdir -p ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 + cp -r ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/ffmpeg/include/* ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/ffmpeg/include/config.h ${FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + + for FFMPEG_LIB in ${FFMPEG_LIBS}; do LIPO_COMMAND="${LIPO} -create" - for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}" - do - LIPO_COMMAND+=" ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin/mobile-ffmpeg/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" + + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin/ffmpeg/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" done - LIPO_COMMAND+=" -output ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" + + LIPO_COMMAND+=" -output ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION}" ${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1 if [ $? -ne 0 ]; then - echo -e "failed\n" - exit 1 + echo -e "failed\n" + exit 1 fi - cp -r ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/mobile-ffmpeg/include/* ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 - cp -r ${MOBILE_FFMPEG_UNIVERSAL}/include/* ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 - cp ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION} ${MOBILE_FFMPEG_FRAMEWORK_PATH}/mobileffmpeg 1>>${BASEDIR}/build.log 2>&1 + FFMPEG_LIB_UPPERCASE=$(echo ${FFMPEG_LIB} | tr '[a-z]' '[A-Z]') + FFMPEG_LIB_CAPITALCASE=$(to_capital_case ${FFMPEG_LIB}) + + FFMPEG_LIB_MAJOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MAJOR//g;s/\ //g") + FFMPEG_LIB_MINOR=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed -e "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MINOR//g;s/\ //g") + FFMPEG_LIB_MICRO=$(grep "#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO" ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/version.h | sed "s/#define ${FFMPEG_LIB_UPPERCASE}_VERSION_MICRO//g;s/\ //g") + + FFMPEG_LIB_VERSION="${FFMPEG_LIB_MAJOR}.${FFMPEG_LIB_MINOR}.${FFMPEG_LIB_MICRO}" + + FFMPEG_LIB_FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/${FFMPEG_LIB}.framework + + rm -rf ${FFMPEG_LIB_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + + cp -r ${FFMPEG_UNIVERSAL}/include/${FFMPEG_LIB}/* ${FFMPEG_LIB_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + cp ${FFMPEG_UNIVERSAL}/lib/${FFMPEG_LIB}.${BUILD_LIBRARY_EXTENSION} ${FFMPEG_LIB_FRAMEWORK_PATH}/${FFMPEG_LIB} 1>>${BASEDIR}/build.log 2>&1 # COPY THE LICENSES - if [ ${GPL_ENABLED} == "yes" ]; then - cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + if [ ${GPL_ENABLED} == "yes" ]; then + + # GPLv3.0 + cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 else - cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 - cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + + # LGPLv3.0 + cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_LIB_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 fi - build_info_plist "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Info.plist" "mobileffmpeg" "com.arthenica.mobileffmpeg.MobileFFmpeg" "${MOBILE_FFMPEG_VERSION}" "${MOBILE_FFMPEG_VERSION}" - build_modulemap "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules/module.modulemap" + build_info_plist "${FFMPEG_LIB_FRAMEWORK_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.mobileffmpeg.${FFMPEG_LIB_CAPITALCASE}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" + + echo -e "Created ${FFMPEG_LIB} framework successfully.\n" 1>>${BASEDIR}/build.log 2>&1 + done + + # COPY THE LICENSES + if [ ${GPL_ENABLED} == "yes" ]; then + cp ${BASEDIR}/LICENSE.GPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + else + cp ${BASEDIR}/LICENSE.LGPLv3 ${FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + fi + + # 3. MOBILE FFMPEG + MOBILE_FFMPEG_VERSION=$(get_mobile_ffmpeg_version) + MOBILE_FFMPEG_UNIVERSAL=${BASEDIR}/prebuilt/tvos-universal/mobile-ffmpeg-universal + MOBILE_FFMPEG_FRAMEWORK_PATH=${BASEDIR}/prebuilt/tvos-framework/mobileffmpeg.framework + mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${MOBILE_FFMPEG_UNIVERSAL}/lib 1>>${BASEDIR}/build.log 2>&1 + rm -rf ${MOBILE_FFMPEG_FRAMEWORK_PATH} 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + mkdir -p ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules 1>>${BASEDIR}/build.log 2>&1 + + LIPO_COMMAND="${LIPO} -create" + for TARGET_ARCH in "${TARGET_ARCH_LIST[@]}"; do + LIPO_COMMAND+=" ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH}-apple-darwin/mobile-ffmpeg/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" + done + LIPO_COMMAND+=" -output ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION}" + + ${LIPO_COMMAND} 1>>${BASEDIR}/build.log 2>&1 + + if [ $? -ne 0 ]; then + echo -e "failed\n" + exit 1 + fi + + cp -r ${BASEDIR}/prebuilt/tvos-${TARGET_ARCH_LIST[0]}-apple-darwin/mobile-ffmpeg/include/* ${MOBILE_FFMPEG_UNIVERSAL}/include 1>>${BASEDIR}/build.log 2>&1 + cp -r ${MOBILE_FFMPEG_UNIVERSAL}/include/* ${MOBILE_FFMPEG_FRAMEWORK_PATH}/Headers 1>>${BASEDIR}/build.log 2>&1 + cp ${MOBILE_FFMPEG_UNIVERSAL}/lib/libmobileffmpeg.${BUILD_LIBRARY_EXTENSION} ${MOBILE_FFMPEG_FRAMEWORK_PATH}/mobileffmpeg 1>>${BASEDIR}/build.log 2>&1 + + # COPY THE LICENSES + if [ ${GPL_ENABLED} == "yes" ]; then + cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/LICENSE.GPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + else + cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_UNIVERSAL}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + cp ${BASEDIR}/LICENSE.LGPLv3 ${MOBILE_FFMPEG_FRAMEWORK_PATH}/LICENSE 1>>${BASEDIR}/build.log 2>&1 + fi + + build_info_plist "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Info.plist" "mobileffmpeg" "com.arthenica.mobileffmpeg.MobileFFmpeg" "${MOBILE_FFMPEG_VERSION}" "${MOBILE_FFMPEG_VERSION}" + build_modulemap "${MOBILE_FFMPEG_FRAMEWORK_PATH}/Modules/module.modulemap" - echo -e "Created mobile-ffmpeg.framework and universal library successfully.\n" 1>>${BASEDIR}/build.log 2>&1 + echo -e "Created mobile-ffmpeg.framework and universal library successfully.\n" 1>>${BASEDIR}/build.log 2>&1 - echo -e "ok\n" + echo -e "ok\n" fi