2020-08-05 03:26:42 +03:00
#!/bin/bash
if [ [ -z ${ ARCH } ] ] ; then
2020-08-05 03:53:02 +03:00
echo -e "\n(*) ARCH not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
if [ [ -z ${ TVOS_MIN_VERSION } ] ] ; then
2020-08-05 03:53:02 +03:00
echo -e "\n(*) TVOS_MIN_VERSION not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
if [ [ -z ${ BASEDIR } ] ] ; then
echo -e "\n(*) BASEDIR not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
if [ [ -z ${ SDK_PATH } ] ] ; then
echo -e "\n(*) SDK_PATH not defined\n"
exit 1
2020-08-05 03:26:42 +03:00
fi
2021-10-09 17:14:44 +03:00
echo -e " \nBuilding ${ ARCH } platform targeting tvOS SDK ${ TVOS_MIN_VERSION } \n "
echo -e " \nINFO: Starting new build for ${ ARCH } targeting tvOS SDK ${ TVOS_MIN_VERSION } at $( date) \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
# SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE
2020-11-23 00:51:45 +02:00
export LIB_INSTALL_BASE = " ${ BASEDIR } /prebuilt/ $( get_build_directory) "
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# CREATE PACKAGE CONFIG DIRECTORY FOR THIS ARCHITECTURE
2020-11-23 00:51:45 +02:00
PKG_CONFIG_DIRECTORY = " ${ LIB_INSTALL_BASE } /pkgconfig "
2020-08-05 03:53:02 +03:00
if [ ! -d " ${ PKG_CONFIG_DIRECTORY } " ] ; then
mkdir -p " ${ PKG_CONFIG_DIRECTORY } " || exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# FILTER WHICH EXTERNAL LIBRARIES WILL BE BUILT
2020-08-05 03:26:42 +03:00
# NOTE THAT BUILT-IN LIBRARIES ARE FORWARDED TO FFMPEG SCRIPT WITHOUT ANY PROCESSING
enabled_library_list = ( )
2021-12-25 20:07:45 +02:00
for library in { 1..50} ; do
2020-08-05 03:53:02 +03:00
if [ [ ${ !library } -eq 1 ] ] ; then
ENABLED_LIBRARY = $( get_library_name $(( library - 1 )) )
enabled_library_list += ( ${ ENABLED_LIBRARY } )
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
echo -e " INFO: Enabled library ${ ENABLED_LIBRARY } will be built\n " 1>>" ${ BASEDIR } " /build.log 2>& 1
fi
2020-08-05 03:26:42 +03:00
done
2020-08-05 03:53:02 +03:00
# BUILD ENABLED LIBRARIES AND THEIR DEPENDENCIES
2020-08-05 03:26:42 +03:00
let completed = 0
while [ ${# enabled_library_list [@] } -gt $completed ] ; do
2020-08-05 03:53:02 +03:00
for library in " ${ enabled_library_list [@] } " ; do
let run = 0
case $library in
fontconfig)
2020-11-23 00:51:45 +02:00
if [ [ $OK_expat -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
freetype)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libpng -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
gnutls)
2020-11-23 00:51:45 +02:00
if [ [ $OK_nettle -eq 1 ] ] && [ [ $OK_gmp -eq 1 ] ] ; then
run = 1
fi
; ;
harfbuzz)
if [ [ $OK_fontconfig -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
leptonica)
2020-11-23 00:51:45 +02:00
if [ [ $OK_giflib -eq 1 ] ] && [ [ $OK_jpeg -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_tiff -eq 1 ] ] && [ [ $OK_libwebp -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libass)
2020-11-23 00:51:45 +02:00
if [ [ $OK_expat -eq 1 ] ] && [ [ $OK_freetype -eq 1 ] ] && [ [ $OK_fribidi -eq 1 ] ] && [ [ $OK_fontconfig -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_harfbuzz -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libtheora)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libvorbis -eq 1 ] ] && [ [ $OK_libogg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libvorbis)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libogg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
libwebp)
2020-11-23 00:51:45 +02:00
if [ [ $OK_giflib -eq 1 ] ] && [ [ $OK_jpeg -eq 1 ] ] && [ [ $OK_libpng -eq 1 ] ] && [ [ $OK_tiff -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
nettle)
2020-11-23 00:51:45 +02:00
if [ [ $OK_gmp -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
rubberband)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libsndfile -eq 1 ] ] && [ [ $OK_libsamplerate -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
2021-12-25 20:07:45 +02:00
srt)
if [ [ $OK_openssl -eq 1 ] ] ; then
run = 1
fi
; ;
2020-08-05 03:53:02 +03:00
tesseract)
2020-11-23 00:51:45 +02:00
if [ [ $OK_leptonica -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
tiff)
2020-11-23 00:51:45 +02:00
if [ [ $OK_jpeg -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
twolame)
2020-11-23 00:51:45 +02:00
if [ [ $OK_libsndfile -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
run = 1
fi
; ;
*)
run = 1
; ;
esac
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
BUILD_COMPLETED_FLAG = $( echo " OK_ ${ library } " | sed "s/\-/\_/g" )
REBUILD_FLAG = $( echo " REBUILD_ ${ library } " | sed "s/\-/\_/g" )
DEPENDENCY_REBUILT_FLAG = $( echo " DEPENDENCY_REBUILT_ ${ library } " | sed "s/\-/\_/g" )
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
if [ [ $run -eq 1 ] ] && [ [ " ${ !BUILD_COMPLETED_FLAG } " != "1" ] ] ; then
LIBRARY_IS_INSTALLED = $( library_is_installed " ${ LIB_INSTALL_BASE } " " ${ library } " )
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
echo -e " INFO: Flags detected for ${ library } : already installed= ${ LIBRARY_IS_INSTALLED } , rebuild requested by user= ${ !REBUILD_FLAG } , will be rebuilt due to dependency update= ${ !DEPENDENCY_REBUILT_FLAG } \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
2020-08-05 03:53:02 +03:00
# CHECK IF BUILD IS NECESSARY OR NOT
2020-11-23 00:51:45 +02:00
if [ [ ${ LIBRARY_IS_INSTALLED } -ne 1 ] ] || [ [ ${ !REBUILD_FLAG } -eq 1 ] ] || [ [ ${ !DEPENDENCY_REBUILT_FLAG } -eq 1 ] ] ; then
2020-08-05 03:53:02 +03:00
echo -n " ${ library } : "
2020-08-05 03:26:42 +03:00
2020-11-23 00:51:45 +02:00
" ${ BASEDIR } " /scripts/run-apple.sh " ${ library } " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:26:42 +03:00
2021-12-25 20:07:45 +02:00
RC = $?
2020-11-23 00:51:45 +02:00
# SET SOME FLAGS AFTER THE BUILD
2021-12-25 20:07:45 +02:00
if [ $RC -eq 0 ] ; then
2020-08-05 03:53:02 +03:00
( ( completed += 1) )
declare " $BUILD_COMPLETED_FLAG =1 "
check_if_dependency_rebuilt " ${ library } "
echo "ok"
2021-12-25 20:07:45 +02:00
elif [ $RC -eq 200 ] ; then
echo -e "not supported\n\nSee build.log for details\n"
exit 1
2020-08-05 03:26:42 +03:00
else
2020-11-23 00:51:45 +02:00
echo -e "failed\n\nSee build.log for details\n"
2020-08-05 03:53:02 +03:00
exit 1
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
else
( ( completed += 1) )
declare " $BUILD_COMPLETED_FLAG =1 "
echo " ${ library } : already built "
fi
else
2020-11-23 00:51:45 +02:00
echo -e " INFO: Skipping $library , dependencies built= $run , already built= ${ !BUILD_COMPLETED_FLAG } \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
2020-08-05 03:53:02 +03:00
fi
done
2020-08-05 03:26:42 +03:00
done
2021-12-28 13:32:40 +02:00
# BUILD CUSTOM LIBRARIES
for custom_library_index in " ${ CUSTOM_LIBRARIES [@] } " ; do
library_name = " CUSTOM_LIBRARY_ ${ custom_library_index } _NAME "
echo -e " \nDEBUG: Custom library ${ !library_name } will be built\n " 1>>" ${ BASEDIR } " /build.log 2>& 1
# DEFINE SOME FLAGS TO REBUILD OPTIONS
REBUILD_FLAG = $( echo " REBUILD_ ${ !library_name } " | sed "s/\-/\_/g" )
LIBRARY_IS_INSTALLED = $( library_is_installed " ${ LIB_INSTALL_BASE } " " ${ !library_name } " )
echo -e " INFO: Flags detected for custom library ${ !library_name } : already installed= ${ LIBRARY_IS_INSTALLED } , rebuild requested by user= ${ !REBUILD_FLAG } \n " 1>>" ${ BASEDIR } " /build.log 2>& 1
if [ [ ${ LIBRARY_IS_INSTALLED } -ne 1 ] ] || [ [ ${ !REBUILD_FLAG } -eq 1 ] ] ; then
echo -n " ${ !library_name } : "
" ${ BASEDIR } " /scripts/run-apple.sh " ${ !library_name } " 1>>" ${ BASEDIR } " /build.log 2>& 1
RC = $?
# SET SOME FLAGS AFTER THE BUILD
if [ $RC -eq 0 ] ; then
echo "ok"
elif [ $RC -eq 200 ] ; then
echo -e "not supported\n\nSee build.log for details\n"
exit 1
else
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
else
echo " ${ !library_name } : already built "
fi
done
2020-08-05 03:53:02 +03:00
# SKIP TO SPEED UP THE BUILD
2020-08-05 03:26:42 +03:00
if [ [ ${ SKIP_ffmpeg } -ne 1 ] ] ; then
2020-11-23 00:51:45 +02:00
# PREPARE PATHS & DEFINE ${INSTALL_PKG_CONFIG_DIR}
LIB_NAME = "ffmpeg"
set_toolchain_paths " ${ LIB_NAME } "
# SET BUILD FLAGS
HOST = $( get_host)
export CFLAGS = $( get_cflags " ${ LIB_NAME } " )
export CXXFLAGS = $( get_cxxflags " ${ LIB_NAME } " )
export LDFLAGS = $( get_ldflags " ${ LIB_NAME } " )
export PKG_CONFIG_LIBDIR = " ${ INSTALL_PKG_CONFIG_DIR } "
cd " ${ BASEDIR } " /src/" ${ LIB_NAME } " 1>>" ${ BASEDIR } " /build.log 2>& 1 || exit 1
LIB_INSTALL_PREFIX = " ${ LIB_INSTALL_BASE } / ${ LIB_NAME } "
2020-08-05 03:53:02 +03:00
# BUILD FFMPEG
2021-12-28 13:32:40 +02:00
source " ${ BASEDIR } " /scripts/apple/ffmpeg.sh
2020-11-23 00:51:45 +02:00
if [ [ $? -ne 0 ] ] ; then
exit 1
fi
2020-08-05 03:26:42 +03:00
else
2020-08-05 03:53:02 +03:00
echo -e "\nffmpeg: skipped"
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
# SKIP TO SPEED UP THE BUILD
2020-08-05 03:26:42 +03:00
if [ [ ${ SKIP_ffmpeg_kit } -ne 1 ] ] ; then
2020-08-05 03:53:02 +03:00
# BUILD FFMPEG
2020-11-23 00:51:45 +02:00
. " ${ BASEDIR } " /scripts/apple/ffmpeg-kit.sh " $@ " || exit 1
2020-08-05 03:26:42 +03:00
else
2020-08-05 03:53:02 +03:00
echo -e "\nffmpeg-kit: skipped"
2020-08-05 03:26:42 +03:00
fi
2020-08-05 03:53:02 +03:00
echo -e " \nINFO: Completed build for ${ ARCH } at $( date) \n " 1>>" ${ BASEDIR } " /build.log 2>& 1