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 ${IOS_MIN_VERSION} ]]; then
|
2020-08-05 03:53:02 +03:00
|
|
|
echo -e "\n(*) IOS_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 ${TARGET_SDK} ]]; then
|
|
|
|
echo -e "\n(*) TARGET_SDK 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
|
|
|
|
|
|
|
|
# ENABLE COMMON FUNCTIONS
|
2020-08-05 03:53:02 +03:00
|
|
|
. "${BASEDIR}"/scripts/function-ios.sh
|
2020-08-05 03:26:42 +03:00
|
|
|
|
|
|
|
echo -e "\nBuilding ${ARCH} platform\n"
|
2020-08-05 03:53:02 +03:00
|
|
|
echo -e "\nINFO: Starting new build for ${ARCH} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
|
|
|
|
# SET BASE INSTALLATION DIRECTORY FOR THIS ARCHITECTURE
|
2020-08-05 03:26:42 +03:00
|
|
|
INSTALL_BASE="${BASEDIR}/prebuilt/$(get_target_build_directory)"
|
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
# CREATE PACKAGE CONFIG DIRECTORY FOR THIS ARCHITECTURE
|
2020-08-05 03:26:42 +03:00
|
|
|
PKG_CONFIG_DIRECTORY="${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=()
|
2020-08-05 03:53:02 +03:00
|
|
|
for library in {1..46}; do
|
|
|
|
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)
|
|
|
|
if [[ -n $OK_expat ]] && [[ -n $OK_freetype ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
freetype)
|
|
|
|
if [[ -n $OK_libpng ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
gnutls)
|
|
|
|
if [[ -n $OK_nettle ]] && [[ -n $OK_gmp ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
leptonica)
|
|
|
|
if [[ -n $OK_giflib ]] && [[ -n $OK_jpeg ]] && [[ -n $OK_libpng ]] && [[ -n $OK_tiff ]] && [[ -n $OK_libwebp ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
libass)
|
|
|
|
if [[ -n $OK_expat ]] && [[ -n $OK_freetype ]] && [[ -n $OK_fribidi ]] && [[ -n $OK_fontconfig ]] && [[ -n $OK_libpng ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
libtheora)
|
|
|
|
if [[ -n $OK_libvorbis ]] && [[ -n $OK_libogg ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
libvorbis)
|
|
|
|
if [[ -n $OK_libogg ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
libwebp)
|
|
|
|
if [[ -n $OK_giflib ]] && [[ -n $OK_jpeg ]] && [[ -n $OK_libpng ]] && [[ -n $OK_tiff ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
nettle)
|
|
|
|
if [[ -n $OK_gmp ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
rubberband)
|
|
|
|
if [[ -n $OK_libsndfile ]] && [[ -n $OK_libsamplerate ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
tesseract)
|
|
|
|
if [[ -n $OK_leptonica ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
tiff)
|
|
|
|
if [[ -n $OK_jpeg ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
twolame)
|
|
|
|
if [[ -n $OK_libsndfile ]]; then
|
|
|
|
run=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
run=1
|
|
|
|
;;
|
|
|
|
esac
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
# DEFINE SOME FLAGS TO MANAGE DEPENDENCIES AND REBUILD OPTIONS
|
|
|
|
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-08-05 03:53:02 +03:00
|
|
|
if [ $run -eq 1 ] && [[ -z ${!BUILD_COMPLETED_FLAG} ]]; then
|
|
|
|
ENABLED_LIBRARY_PATH="${INSTALL_BASE}/${library}"
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
LIBRARY_IS_INSTALLED=$(library_is_installed ${INSTALL_BASE} ${library})
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
echo -e "INFO: Flags detected for ${library}: already installed=${LIBRARY_IS_INSTALLED}, rebuild=${!REBUILD_FLAG}, dependency rebuilt=${!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
|
|
|
|
if [[ ${LIBRARY_IS_INSTALLED} -ne 0 ]] || [[ ${!REBUILD_FLAG} -eq 1 ]] || [[ ${!DEPENDENCY_REBUILT_FLAG} -eq 1 ]]; then
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
echo -e "----------------------------------------------------------------" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
echo -e "\nINFO: Building $library with the following environment variables\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
env 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
echo -e "----------------------------------------------------------------\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
echo -e "INFO: System information\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
echo -e "INFO: $(uname -a)\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
echo -e "----------------------------------------------------------------\n" 1>>"${BASEDIR}"/build.log 2>&1
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
echo -n "${library}: "
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
# DELETE THE PREVIOUS BUILD OF THE LIBRARY
|
|
|
|
if [ -d ${ENABLED_LIBRARY_PATH} ]; then
|
|
|
|
rm -rf "${INSTALL_BASE}"/"${library}" || exit 1
|
|
|
|
fi
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
SCRIPT_PATH="${BASEDIR}/scripts/objc/${library}.sh"
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
cd "${BASEDIR}"
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
# EXECUTE BUILD SCRIPT OF EACH ENABLED LIBRARY
|
|
|
|
${SCRIPT_PATH} 1>>"${BASEDIR}"/build.log 2>&1
|
2020-08-05 03:26:42 +03:00
|
|
|
|
2020-08-05 03:53:02 +03:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
((completed += 1))
|
|
|
|
declare "$BUILD_COMPLETED_FLAG=1"
|
|
|
|
check_if_dependency_rebuilt "${library}"
|
|
|
|
echo "ok"
|
2020-08-05 03:26:42 +03:00
|
|
|
else
|
2020-08-05 03:53:02 +03:00
|
|
|
echo "failed"
|
|
|
|
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
|
|
|
|
echo -e "INFO: Skipping $library, run=$run, completed=${!BUILD_COMPLETED_FLAG}\n" 1>>"${BASEDIR}"/build.log 2>&1
|
|
|
|
fi
|
|
|
|
done
|
2020-08-05 03:26:42 +03:00
|
|
|
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-08-05 03:53:02 +03:00
|
|
|
# BUILD FFMPEG
|
|
|
|
. "${BASEDIR}"/scripts/objc/ffmpeg.sh "$@" || exit 1
|
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 KIT
|
|
|
|
. "${BASEDIR}"/scripts/objc/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
|