2020-08-05 03:26:42 +03:00
#!/bin/bash
2020-08-05 03:53:02 +03:00
# CHECK IF XCODE IS INSTALLED
if [ ! -x " $( command -v xcrun) " ] ; then
echo -e "\n(*) xcrun command not found. Please check your Xcode installation\n"
2020-08-05 03:26:42 +03:00
exit 1
fi
2020-08-05 03:53:02 +03:00
# LOAD INITIAL SETTINGS
export BASEDIR = " $( pwd ) "
export FFMPEG_KIT_BUILD_TYPE = "ios"
source " ${ BASEDIR } " /scripts/variable.sh
source " ${ BASEDIR } " /scripts/function-${ FFMPEG_KIT_BUILD_TYPE } .sh
# SET DEFAULTS SETTINGS
enable_default_ios_architectures
enable_main_build
2020-08-05 03:26:42 +03:00
# SELECT XCODE VERSION USED FOR BUILDING
2020-08-05 03:53:02 +03:00
XCODE_FOR_FFMPEG_KIT = $( ls ~/.xcode.for.ffmpeg.kit.sh)
2020-08-05 03:26:42 +03:00
if [ [ -f ${ XCODE_FOR_FFMPEG_KIT } ] ] ; then
source " ${ XCODE_FOR_FFMPEG_KIT } " 1>>" ${ BASEDIR } " /build.log 2>& 1
fi
2020-08-05 03:53:02 +03:00
# DETECT IOS SDK VERSION
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
echo -e " INFO: Build options: $* \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# SET DEFAULT BUILD OPTIONS
2020-08-05 03:26:42 +03:00
GPL_ENABLED = "no"
DISPLAY_HELP = ""
BUILD_TYPE_ID = ""
BUILD_FULL = ""
FFMPEG_KIT_XCF_BUILD = ""
BUILD_FORCE = ""
2020-08-05 03:53:02 +03:00
BUILD_VERSION = $( git describe --tags --always 2>>" ${ BASEDIR } " /build.log)
if [ [ -z ${ BUILD_VERSION } ] ] ; then
echo -e "\n(*): Can not run git commands in this folder. See build.log.\n"
exit 1
fi
# PROCESS LTS BUILD OPTION FIRST AND SET BUILD TYPE: MAIN OR LTS
for argument in " $@ " ; do
if [ [ " $argument " = = "-l" ] ] || [ [ " $argument " = = "--lts" ] ] ; then
enable_lts_build
BUILD_TYPE_ID += "LTS "
fi
done
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# PROCESS BUILD OPTIONS
2020-08-05 03:26:42 +03:00
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
; ;
2020-08-05 03:53:02 +03:00
-l | --lts) ; ;
2020-08-05 03:26:42 +03:00
-x | --xcframework)
FFMPEG_KIT_XCF_BUILD = "1"
; ;
-f | --force)
2020-08-05 03:53:02 +03:00
export BUILD_FORCE = "1"
2020-08-05 03:26:42 +03:00
; ;
--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 } "
; ;
2020-08-05 03:53:02 +03:00
--redownload-*)
2020-08-05 03:26:42 +03:00
DOWNLOAD_LIBRARY = $( echo $1 | sed -e 's/^--[A-Za-z]*-//g' )
redownload_library " ${ DOWNLOAD_LIBRARY } "
; ;
--full)
BUILD_FULL = "1"
; ;
--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
2020-08-05 03:53:02 +03:00
# VALIDATE THAT LTS RELEASES ARE BUILT USING THE CORRECT VERSION
if [ [ -n ${ FFMPEG_KIT_LTS_BUILD } ] ] && [ [ " ${ DETECTED_IOS_SDK_VERSION } " != " ${ IOS_MIN_VERSION } " ] ] ; then
if [ [ -z ${ BUILD_FORCE } ] ] ; then
echo -e " \n(*) LTS packages should be built using SDK ${ IOS_MIN_VERSION } but current configuration uses SDK ${ DETECTED_IOS_SDK_VERSION } \n "
exit 1
fi
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# PROCESS FULL OPTION AS LAST OPTION
2020-08-05 03:26:42 +03:00
if [ [ -n ${ BUILD_FULL } ] ] ; then
2020-08-05 03:53:02 +03:00
for library in { 0..57} ; do
2020-08-05 03:26:42 +03:00
if [ ${ GPL_ENABLED } = = "yes" ] ; then
2020-08-05 03:53:02 +03:00
enable_library " $( get_library_name $library ) " 1
2020-08-05 03:26:42 +03:00
else
2020-08-05 03:53:02 +03:00
if [ [ $( is_gpl_licensed $library ) -eq 1 ] ] ; then
enable_library " $( get_library_name $library ) " 1
2020-08-05 03:26:42 +03:00
fi
fi
done
fi
2020-08-05 03:53:02 +03:00
# IF HELP DISPLAYED EXIT
if [ [ -n ${ DISPLAY_HELP } ] ] ; then
display_help
exit 0
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# DISABLE NOT SUPPORTED ARCHITECTURES
disable_architecture_not_supported_on_detected_sdk_version " ${ ARCH_ARMV7 } " " ${ DETECTED_IOS_SDK_VERSION } "
disable_architecture_not_supported_on_detected_sdk_version " ${ ARCH_ARMV7S } " " ${ DETECTED_IOS_SDK_VERSION } "
disable_architecture_not_supported_on_detected_sdk_version " ${ ARCH_I386 } " " ${ DETECTED_IOS_SDK_VERSION } "
disable_architecture_not_supported_on_detected_sdk_version " ${ ARCH_ARM64E } " " ${ DETECTED_IOS_SDK_VERSION } "
disable_architecture_not_supported_on_detected_sdk_version " ${ ARCH_X86_64_MAC_CATALYST } " " ${ DETECTED_IOS_SDK_VERSION } "
# CHECK SOME RULES FOR .xcframework BUNDLES
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# 1. DISABLE x86-64-mac-catalyst WHEN x86-64 IS ENABLED IN xcframework BUNDLES
2020-08-05 03:26:42 +03:00
if [ [ -z ${ FFMPEG_KIT_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
2020-08-05 03:53:02 +03:00
# 2. DISABLE arm64e WHEN arm64 IS ENABLED IN xcframework BUNDLES
2020-08-05 03:26:42 +03:00
if [ [ -n ${ FFMPEG_KIT_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
2020-08-05 03:53:02 +03:00
# 3. DO NOT ALLOW --lts AND --xcframework OPTIONS TOGETHER
if [ [ -n ${ FFMPEG_KIT_XCF_BUILD } ] ] && [ [ -n ${ FFMPEG_KIT_LTS_BUILD } ] ] ; then
echo -e "\n(*) LTS packages does not support xcframework bundles.\n"
exit 1
fi
2020-08-05 03:26:42 +03:00
echo -e " \nBuilding ffmpeg-kit ${ BUILD_TYPE_ID } static library for iOS\n "
echo -e -n " INFO: Building ffmpeg-kit ${ BUILD_VERSION } ${ BUILD_TYPE_ID } for iOS: " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
echo -e " $( date) \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
# PRINT BUILD SUMMARY
print_enabled_architectures
print_enabled_libraries
print_reconfigure_requested_libraries
print_rebuild_requested_libraries
print_redownload_requested_libraries
2020-08-05 03:53:02 +03:00
# VALIDATE GPL FLAGS
2020-08-05 03:26:42 +03:00
for gpl_library in { $LIBRARY_X264 ,$LIBRARY_XVIDCORE ,$LIBRARY_X265 ,$LIBRARY_LIBVIDSTAB ,$LIBRARY_RUBBERBAND } ; 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
fi
fi
done
2020-08-05 03:53:02 +03:00
echo -n -e "\nDownloading sources: "
echo -e "INFO: Downloading source code of ffmpeg and enabled external libraries.\n" 1>>" ${ BASEDIR } " /build.log 2>& 1
# DOWNLOAD LIBRARY SOURCES
downloaded_enabled_library_sources " ${ ENABLED_LIBRARIES [@] } "
# THIS WILL SAVE ARCHITECTURES TO BUILD
2020-08-05 03:26:42 +03:00
TARGET_ARCH_LIST = ( )
2020-08-05 03:53:02 +03:00
# BUILD ENABLED LIBRARIES ON ENABLED ARCHITECTURES
2020-08-05 03:26:42 +03:00
for run_arch in { 0..10} ; 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) "
2020-08-05 03:53:02 +03:00
# EXECUTE MAIN BUILD SCRIPT
2020-08-05 03:26:42 +03:00
. " ${ BASEDIR } " /scripts/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
2020-08-05 03:53:02 +03:00
for library in { 0..57} ; do
2020-08-05 03:26:42 +03:00
library_name = $( get_library_name ${ library } )
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"
2020-08-05 03:53:02 +03:00
# BUILD STATIC LIBRARIES
2020-08-05 03:26:42 +03:00
BUILD_LIBRARY_EXTENSION = "a"
2020-08-05 03:53:02 +03:00
# BUILD FFMPEG-KIT
2020-08-05 03:26:42 +03:00
if [ [ -n ${ TARGET_ARCH_LIST [0] } ] ] ; then
2020-08-05 03:53:02 +03:00
# INITIALIZE TARGET FOLDERS
2020-08-05 03:26:42 +03:00
if [ [ -n ${ FFMPEG_KIT_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: "
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
2020-08-05 03:53:02 +03:00
# CREATE ENABLED LIBRARY PACKAGES. IT IS EITHER
# .framework and fat/universal library
# OR
# .xcframework
for library in { 0..57} ; do
2020-08-05 03:26:42 +03:00
if [ [ ${ ENABLED_LIBRARIES [ $library ] } -eq 1 ] ] ; then
library_name = $( get_library_name ${ library } )
package_config_file_name = $( get_package_config_file_name ${ library } )
2020-08-05 03:53:02 +03:00
# EACH ENABLED LIBRARY HAS TO HAVE A .pc FILE AND A VERSION
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# SOME CUSTOM CODE TO HANDLE LIBRARIES THAT PRODUCE MULTIPLE LIBRARY FILES
2020-08-05 03:26:42 +03:00
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
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
elif [ [ ${ LIBRARY_LIBVORBIS } = = " $library " ] ] ; then
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
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
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
elif [ [ ${ LIBRARY_LIBWEBP } = = " $library " ] ] ; then
LIBRARY_CREATED = $( create_external_library_package $library "libwebpmux" "libwebpmux.a" " ${ library_version } " )
if [ [ ${ LIBRARY_CREATED } -ne 0 ] ] ; then
echo -e "failed\n"
exit 1
fi
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
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
elif [ [ ${ LIBRARY_OPENCOREAMR } = = " $library " ] ] ; then
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
elif [ [ ${ LIBRARY_NETTLE } = = " $library " ] ] ; 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
2020-08-05 03:53:02 +03:00
# LIBRARIES WHICH HAVE ONLY ONE LIBRARY FILE ARE CREATED HERE
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# CREATE FFMPEG & FFMPEG KIT PACKAGES
2020-08-05 03:26:42 +03:00
if [ [ -n ${ FFMPEG_KIT_XCF_BUILD } ] ] ; then
2020-08-05 03:53:02 +03:00
# CREATE .xcframework BUNDLE IF ENABLED
# CREATE FFMPEG
2020-08-05 03:26:42 +03:00
for FFMPEG_LIB in ${ FFMPEG_LIBS } ; do
2020-08-05 03:53:02 +03:00
# INITIALIZE FFMPEG FRAMEWORK DIRECTORY
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# arm64e NOT INCLUDED IN .xcframework BUNDLES
2020-08-05 03:26:42 +03:00
if [ [ ${ TARGET_ARCH } != "arm64e" ] ] ; then
FFMPEG_LIB_UPPERCASE = $( echo " ${ FFMPEG_LIB } " | tr '[a-z]' '[A-Z]' )
FFMPEG_LIB_CAPITALCASE = $( to_capital_case " ${ FFMPEG_LIB } " )
2020-08-05 03:53:02 +03:00
# EXTRACT FFMPEG VERSION
2020-08-05 03:26:42 +03:00
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 } "
2020-08-05 03:53:02 +03:00
# INITIALIZE SUB-FRAMEWORK DIRECTORY
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# COPY HEADER FILES
2020-08-05 03:26:42 +03:00
cp -r " ${ BASEDIR } " /prebuilt/ios-${ TARGET_ARCH } /ffmpeg/include/${ FFMPEG_LIB } /* ${ FFMPEG_LIB_FRAMEWORK_PATH } /Headers 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# COPY LIBRARY FILE
2020-08-05 03:26:42 +03:00
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
cp " ${ BASEDIR } /LICENSE.GPLv3 " " ${ FFMPEG_LIB_FRAMEWORK_PATH } /LICENSE " 1>>" ${ BASEDIR } " /build.log 2>& 1
else
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.ffmpegkit. ${ FFMPEG_LIB_CAPITALCASE } " " ${ FFMPEG_LIB_VERSION } " " ${ FFMPEG_LIB_VERSION } "
BUILD_COMMAND += " -framework ${ FFMPEG_LIB_FRAMEWORK_PATH } "
fi
done
BUILD_COMMAND += " -output ${ XCFRAMEWORK_PATH } "
2020-08-05 03:53:02 +03:00
# EXECUTE CREATE FRAMEWORK COMMAND
2020-08-05 03:26:42 +03:00
COMMAND_OUTPUT = $( ${ BUILD_COMMAND } 2>& 1)
echo " ${ COMMAND_OUTPUT } " 1>>" ${ BASEDIR } " /build.log 2>& 1
echo "" 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# DO NOT ALLOW EMPTY FRAMEWORKS
2020-08-05 03:26:42 +03:00
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
done
2020-08-05 03:53:02 +03:00
# CREATE FFMPEG
# INITIALIZE FFMPEG KIT FRAMEWORK DIRECTORY
2020-08-05 03:26:42 +03:00
XCFRAMEWORK_PATH = ${ BASEDIR } /prebuilt/ios-xcframework/ffmpegkit.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
2020-08-05 03:53:02 +03:00
# arm64e NOT INCLUDED IN .xcframework BUNDLES
2020-08-05 03:26:42 +03:00
if [ [ ${ TARGET_ARCH } != "arm64e" ] ] ; then
2020-08-05 03:53:02 +03:00
# INITIALIZE SUB-FRAMEWORK DIRECTORY
2020-08-05 03:26:42 +03:00
FFMPEG_KIT_FRAMEWORK_PATH = " ${ BASEDIR } /prebuilt/ios-xcframework/.tmp/ios- ${ TARGET_ARCH } /ffmpegkit.framework "
rm -rf " ${ FFMPEG_KIT_FRAMEWORK_PATH } " 1>>" ${ BASEDIR } " /build.log 2>& 1
mkdir -p " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Headers " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
mkdir -p " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Modules " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
2020-08-05 03:53:02 +03:00
2020-08-05 03:26:42 +03:00
build_modulemap " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Modules/module.modulemap "
2020-08-05 03:53:02 +03:00
# COPY HEADER FILES
2020-08-05 03:26:42 +03:00
cp -r " ${ BASEDIR } " /prebuilt/ios-" ${ TARGET_ARCH } " /ffmpeg-kit/include/* " ${ FFMPEG_KIT_FRAMEWORK_PATH } " /Headers 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# COPY LIBRARY FILE
2020-08-05 03:26:42 +03:00
cp " ${ BASEDIR } /prebuilt/ios- ${ TARGET_ARCH } /ffmpeg-kit/lib/libffmpegkit. ${ BUILD_LIBRARY_EXTENSION } " " ${ FFMPEG_KIT_FRAMEWORK_PATH } /ffmpegkit " 1>>" ${ BASEDIR } " /build.log 2>& 1
# COPY THE LICENSES
if [ ${ GPL_ENABLED } = = "yes" ] ; then
cp " ${ BASEDIR } /LICENSE.GPLv3 " " ${ FFMPEG_KIT_FRAMEWORK_PATH } /LICENSE " 1>>" ${ BASEDIR } " /build.log 2>& 1
else
cp " ${ BASEDIR } /LICENSE.LGPLv3 " " ${ FFMPEG_KIT_FRAMEWORK_PATH } /LICENSE " 1>>" ${ BASEDIR } " /build.log 2>& 1
fi
BUILD_COMMAND += " -framework ${ FFMPEG_KIT_FRAMEWORK_PATH } "
fi
2020-08-05 03:53:02 +03:00
done
2020-08-05 03:26:42 +03:00
BUILD_COMMAND += " -output ${ XCFRAMEWORK_PATH } "
2020-08-05 03:53:02 +03:00
# EXECUTE CREATE FRAMEWORK COMMAND
2020-08-05 03:26:42 +03:00
COMMAND_OUTPUT = $( ${ BUILD_COMMAND } 2>& 1)
echo " ${ COMMAND_OUTPUT } " 1>>" ${ BASEDIR } " /build.log 2>& 1
echo "" 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# DO NOT ALLOW EMPTY FRAMEWORKS
2020-08-05 03:26:42 +03:00
if [ [ ${ COMMAND_OUTPUT } = = *"is empty in library" * ] ] ; then
echo -e "failed\n"
exit 1
fi
echo -e "Created ffmpegkit xcframework successfully.\n" 1>>" ${ BASEDIR } " /build.log 2>& 1
echo -e "ok\n"
else
2020-08-05 03:53:02 +03:00
# CREATE .framework AND FAT/UNIVERSAL LIBRARY IF ENABLED
# CREATE FFMPEG
# INITIALIZE UNIVERSAL LIBRARY DIRECTORY
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# COPY HEADER FILES
2020-08-05 03:26:42 +03:00
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 } "
2020-08-05 03:53:02 +03:00
# EXECUTE CREATE UNIVERSAL LIBRARY COMMAND
2020-08-05 03:26:42 +03:00
${ 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 } " )
2020-08-05 03:53:02 +03:00
# EXTRACT FFMPEG VERSION
2020-08-05 03:26:42 +03:00
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 } "
2020-08-05 03:53:02 +03:00
# INITIALIZE FRAMEWORK DIRECTORY
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# COPY HEADER FILES
2020-08-05 03:26:42 +03:00
cp -r ${ FFMPEG_UNIVERSAL } /include/${ FFMPEG_LIB } /* ${ FFMPEG_LIB_FRAMEWORK_PATH } /Headers 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# COPY LIBRARY FILE
2020-08-05 03:26:42 +03:00
cp " ${ FFMPEG_UNIVERSAL } /lib/ ${ FFMPEG_LIB } . ${ BUILD_LIBRARY_EXTENSION } " " ${ FFMPEG_LIB_FRAMEWORK_PATH } / ${ FFMPEG_LIB } " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# COPY FRAMEWORK LICENSES
2020-08-05 03:26:42 +03:00
if [ ${ GPL_ENABLED } = = "yes" ] ; then
cp " ${ BASEDIR } /LICENSE.GPLv3 " " ${ FFMPEG_LIB_FRAMEWORK_PATH } /LICENSE " 1>>" ${ BASEDIR } " /build.log 2>& 1
else
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.ffmpegkit. ${ FFMPEG_LIB_CAPITALCASE } " " ${ FFMPEG_LIB_VERSION } " " ${ FFMPEG_LIB_VERSION } "
echo -e " Created ${ FFMPEG_LIB } framework successfully.\n " 1>>" ${ BASEDIR } " /build.log 2>& 1
done
2020-08-05 03:53:02 +03:00
# COPY UNIVERSAL LIBRARY LICENSES
2020-08-05 03:26:42 +03:00
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
2020-08-05 03:53:02 +03:00
# FFMPEG KIT
# INITIALIZE FRAMEWORK AND UNIVERSAL LIBRARY DIRECTORIES
2020-08-05 03:26:42 +03:00
FFMPEG_KIT_VERSION = $( get_ffmpeg_kit_version)
FFMPEG_KIT_UNIVERSAL = " ${ BASEDIR } /prebuilt/ios-universal/ffmpeg-kit-universal "
FFMPEG_KIT_FRAMEWORK_PATH = " ${ BASEDIR } /prebuilt/ios-framework/ffmpegkit.framework "
mkdir -p " ${ FFMPEG_KIT_UNIVERSAL } /include " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
mkdir -p " ${ FFMPEG_KIT_UNIVERSAL } /lib " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
rm -rf " ${ FFMPEG_KIT_FRAMEWORK_PATH } " 1>>" ${ BASEDIR } " /build.log 2>& 1
mkdir -p " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Headers " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
mkdir -p " ${ FFMPEG_KIT_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 } /ffmpeg-kit/lib/libffmpegkit. ${ BUILD_LIBRARY_EXTENSION } "
done
LIPO_COMMAND += " -output ${ FFMPEG_KIT_UNIVERSAL } /lib/libffmpegkit. ${ BUILD_LIBRARY_EXTENSION } "
2020-08-05 03:53:02 +03:00
# EXECUTE CREATE UNIVERSAL LIBRARY COMMAND
2020-08-05 03:26:42 +03:00
${ LIPO_COMMAND } 1>>" ${ BASEDIR } " /build.log 2>& 1
if [ $? -ne 0 ] ; then
echo -e "failed\n"
exit 1
fi
2020-08-05 03:53:02 +03:00
# COPY HEADER FILES
2020-08-05 03:26:42 +03:00
cp -r " ${ BASEDIR } " /prebuilt/ios-" ${ TARGET_ARCH_LIST [0] } " /ffmpeg-kit/include/* " ${ FFMPEG_KIT_UNIVERSAL } " /include 1>>" ${ BASEDIR } " /build.log 2>& 1
cp -r " ${ FFMPEG_KIT_UNIVERSAL } " /include/* " ${ FFMPEG_KIT_FRAMEWORK_PATH } " /Headers 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# COPY LIBRARY FILE
2020-08-05 03:26:42 +03:00
cp " ${ FFMPEG_KIT_UNIVERSAL } /lib/libffmpegkit. ${ BUILD_LIBRARY_EXTENSION } " " ${ FFMPEG_KIT_FRAMEWORK_PATH } /ffmpegkit " 1>>" ${ BASEDIR } " /build.log 2>& 1
# COPY THE LICENSES
if [ ${ GPL_ENABLED } = = "yes" ] ; then
cp " ${ BASEDIR } " /LICENSE.GPLv3 " ${ FFMPEG_KIT_UNIVERSAL } " /LICENSE 1>>" ${ BASEDIR } " /build.log 2>& 1
cp " ${ BASEDIR } " /LICENSE.GPLv3 " ${ FFMPEG_KIT_FRAMEWORK_PATH } " /LICENSE 1>>" ${ BASEDIR } " /build.log 2>& 1
else
cp " ${ BASEDIR } " /LICENSE.LGPLv3 " ${ FFMPEG_KIT_UNIVERSAL } " /LICENSE 1>>" ${ BASEDIR } " /build.log 2>& 1
cp " ${ BASEDIR } " /LICENSE.LGPLv3 " ${ FFMPEG_KIT_FRAMEWORK_PATH } " /LICENSE 1>>" ${ BASEDIR } " /build.log 2>& 1
fi
build_info_plist " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Info.plist " "ffmpegkit" "com.arthenica.ffmpegkit.FFmpegKit" " ${ FFMPEG_KIT_VERSION } " " ${ FFMPEG_KIT_VERSION } "
build_modulemap " ${ FFMPEG_KIT_FRAMEWORK_PATH } /Modules/module.modulemap "
echo -e "Created ffmpegkit.framework and universal library successfully.\n" 1>>" ${ BASEDIR } " /build.log 2>& 1
echo -e "ok\n"
fi
fi