support building custom libraries in native build scripts, fixes #28

This commit is contained in:
Taner Sener 2021-12-28 11:32:40 +00:00
parent 3c77c50bf6
commit ed8fd4b4b2
18 changed files with 474 additions and 109 deletions

View File

@ -107,6 +107,14 @@ while [ ! $# -eq 0 ]; do
--enable-gpl)
GPL_ENABLED="yes"
;;
--enable-custom-library-*)
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
CUSTOM_LIBRARY_OPTION_VALUE=$(echo $1 | sed -e 's/^--enable-custom-.*=//g')
echo -e "INFO: Custom library options detected: ${CUSTOM_LIBRARY_OPTION_KEY} ${CUSTOM_LIBRARY_OPTION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1
generate_custom_library_environment_variables "${CUSTOM_LIBRARY_OPTION_KEY}" "${CUSTOM_LIBRARY_OPTION_VALUE}"
;;
--enable-*)
ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g')
@ -180,6 +188,7 @@ print_enabled_libraries
print_reconfigure_requested_libraries
print_rebuild_requested_libraries
print_redownload_requested_libraries
print_custom_libraries
# VALIDATE GPL FLAGS
for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVIDSTAB,$LIBRARY_RUBBERBAND}; do
@ -195,13 +204,13 @@ for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVI
done
echo -n -e "\nDownloading sources: "
echo -e "INFO: Downloading source code of ffmpeg and enabled external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: Downloading the source code of ffmpeg and external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
# DOWNLOAD GNU CONFIG
download_gnu_config
# DOWNLOAD LIBRARY SOURCES
downloaded_enabled_library_sources "${ENABLED_LIBRARIES[@]}"
downloaded_library_sources "${ENABLED_LIBRARIES[@]}"
# SAVE ORIGINAL API LEVEL = NECESSARY TO BUILD 64bit ARCHITECTURES
export ORIGINAL_API=${API}
@ -280,7 +289,7 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then
cd "${BASEDIR}"/android 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
# COPY LICENSES
# COPY LIBRARY LICENSES
LICENSE_BASEDIR="${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/res/raw
rm -f "${LICENSE_BASEDIR}"/*.txt 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
for library in {0..49}; do
@ -300,6 +309,26 @@ if [[ -n ${ANDROID_ARCHITECTURES} ]]; then
fi
done
# COPY CUSTOM LIBRARY LICENSES
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
relative_license_path="CUSTOM_LIBRARY_${custom_library_index}_LICENSE_FILE"
destination_license_path="${LICENSE_BASEDIR}/license_${!library_name}.txt"
cp "${BASEDIR}/src/${!library_name}/${!relative_license_path}" "${destination_license_path}" 1>>"${BASEDIR}"/build.log 2>&1
RC=$?
if [[ ${RC} -ne 0 ]]; then
echo -e "DEBUG: Failed to copy the license file of custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
echo -e "DEBUG: Copied the license file of custom library ${!library_name} successfully\n" 1>>"${BASEDIR}"/build.log 2>&1
done
# COPY LIBRARY LICENSES
if [[ ${GPL_ENABLED} == "yes" ]]; then
cp "${BASEDIR}"/LICENSE.GPLv3 "${LICENSE_BASEDIR}"/license.txt 1>>"${BASEDIR}"/build.log 2>&1

13
ios.sh
View File

@ -116,6 +116,14 @@ while [ ! $# -eq 0 ]; do
--enable-gpl)
GPL_ENABLED="yes"
;;
--enable-custom-library-*)
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
CUSTOM_LIBRARY_OPTION_VALUE=$(echo $1 | sed -e 's/^--enable-custom-.*=//g')
echo -e "INFO: Custom library options detected: ${CUSTOM_LIBRARY_OPTION_KEY} ${CUSTOM_LIBRARY_OPTION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1
generate_custom_library_environment_variables "${CUSTOM_LIBRARY_OPTION_KEY}" "${CUSTOM_LIBRARY_OPTION_VALUE}"
;;
--enable-*)
ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g')
@ -211,6 +219,7 @@ print_enabled_libraries
print_reconfigure_requested_libraries
print_rebuild_requested_libraries
print_redownload_requested_libraries
print_custom_libraries
# VALIDATE GPL FLAGS
for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVIDSTAB,$LIBRARY_RUBBERBAND}; do
@ -226,13 +235,13 @@ for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVI
done
echo -n -e "\nDownloading sources: "
echo -e "INFO: Downloading source code of ffmpeg and enabled external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: Downloading the source code of ffmpeg and external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
# DOWNLOAD GNU CONFIG
download_gnu_config
# DOWNLOAD LIBRARY SOURCES
downloaded_enabled_library_sources "${ENABLED_LIBRARIES[@]}"
downloaded_library_sources "${ENABLED_LIBRARIES[@]}"
# THIS WILL SAVE ARCHITECTURES TO BUILD
TARGET_ARCH_LIST=()

View File

@ -116,6 +116,14 @@ while [ ! $# -eq 0 ]; do
--enable-gpl)
GPL_ENABLED="yes"
;;
--enable-custom-library-*)
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
CUSTOM_LIBRARY_OPTION_VALUE=$(echo $1 | sed -e 's/^--enable-custom-.*=//g')
echo -e "INFO: Custom library options detected: ${CUSTOM_LIBRARY_OPTION_KEY} ${CUSTOM_LIBRARY_OPTION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1
generate_custom_library_environment_variables "${CUSTOM_LIBRARY_OPTION_KEY}" "${CUSTOM_LIBRARY_OPTION_VALUE}"
;;
--enable-*)
ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g')
@ -180,6 +188,7 @@ print_enabled_libraries
print_reconfigure_requested_libraries
print_rebuild_requested_libraries
print_redownload_requested_libraries
print_custom_libraries
# VALIDATE GPL FLAGS
for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVIDSTAB,$LIBRARY_RUBBERBAND}; do
@ -195,13 +204,13 @@ for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVI
done
echo -n -e "\nDownloading sources: "
echo -e "INFO: Downloading source code of ffmpeg and enabled external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: Downloading the source code of ffmpeg and external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
# DOWNLOAD GNU CONFIG
download_gnu_config
# DOWNLOAD LIBRARY SOURCES
downloaded_enabled_library_sources "${ENABLED_LIBRARIES[@]}"
downloaded_library_sources "${ENABLED_LIBRARIES[@]}"
# THIS WILL SAVE ARCHITECTURES TO BUILD
TARGET_ARCH_LIST=()

View File

@ -6,9 +6,6 @@ if [ -z "${HOST_PKG_CONFIG_PATH}" ]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
LIB_NAME="ffmpeg"
echo -e "----------------------------------------------------------------" 1>>"${BASEDIR}"/build.log 2>&1
@ -72,9 +69,9 @@ CONFIGURE_POSTFIX=""
HIGH_PRIORITY_INCLUDES=""
# SET CONFIGURE OPTIONS
for library in {1..62}; do
if [[ ${!library} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name $((library - 1)))
for library in {0..61}; do
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name ${library})
echo -e "INFO: Enabling library ${ENABLED_LIBRARY}\n" 1>>"${BASEDIR}"/build.log 2>&1
@ -311,18 +308,31 @@ for library in {1..62}; do
# THE FOLLOWING LIBRARIES SHOULD BE EXPLICITLY DISABLED TO PREVENT AUTODETECT
# NOTE THAT IDS MUST BE +1 OF THE INDEX VALUE
if [[ ${library} -eq $((LIBRARY_SDL + 1)) ]]; then
if [[ ${library} -eq ${LIBRARY_SDL} ]]; then
CONFIGURE_POSTFIX+=" --disable-sdl2"
elif [[ ${library} -eq $((LIBRARY_ANDROID_ZLIB + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_ANDROID_ZLIB} ]]; then
CONFIGURE_POSTFIX+=" --disable-zlib"
elif [[ ${library} -eq $((LIBRARY_ANDROID_MEDIA_CODEC + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_ANDROID_MEDIA_CODEC} ]]; then
CONFIGURE_POSTFIX+=" --disable-mediacodec"
elif [[ ${library} -eq $((LIBRARY_OPENSSL + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_OPENSSL} ]]; then
CONFIGURE_POSTFIX+=" --disable-openssl"
fi
fi
done
# SET CONFIGURE OPTIONS FOR CUSTOM LIBRARIES
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
pc_file_name="CUSTOM_LIBRARY_${custom_library_index}_PACKAGE_CONFIG_FILE_NAME"
ffmpeg_flag_name="CUSTOM_LIBRARY_${custom_library_index}_FFMPEG_ENABLE_FLAG"
echo -e "INFO: Enabling custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
CFLAGS+=" $(pkg-config --cflags ${!pc_file_name} 2>>"${BASEDIR}"/build.log)"
LDFLAGS+=" $(pkg-config --libs --static ${!pc_file_name} 2>>"${BASEDIR}"/build.log)"
CONFIGURE_POSTFIX+=" --enable-${!ffmpeg_flag_name}"
done
export LDFLAGS+=" -L${ANDROID_NDK_ROOT}/platforms/android-${API}/arch-${TOOLCHAIN_ARCH}/usr/lib"
# LINKING WITH ANDROID LTS SUPPORT LIBRARY IS NECESSARY FOR API < 18

View File

@ -6,9 +6,6 @@ if [ -z "${HOST_PKG_CONFIG_PATH}" ]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
LIB_NAME="ffmpeg"
echo -e "----------------------------------------------------------------" 1>>"${BASEDIR}"/build.log 2>&1
@ -104,9 +101,9 @@ esac
CONFIGURE_POSTFIX=""
# SET CONFIGURE OPTIONS
for library in {1..62}; do
if [[ ${!library} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name $((library - 1)))
for library in {0..61}; do
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name ${library})
echo -e "INFO: Enabling library ${ENABLED_LIBRARY}\n" 1>>"${BASEDIR}"/build.log 2>&1
@ -366,32 +363,45 @@ for library in {1..62}; do
# THE FOLLOWING LIBRARIES SHOULD BE EXPLICITLY DISABLED TO PREVENT AUTODETECT
# NOTE THAT IDS MUST BE +1 OF THE INDEX VALUE
if [[ ${library} -eq $((LIBRARY_SDL + 1)) ]]; then
if [[ ${library} -eq ${LIBRARY_SDL} ]]; then
CONFIGURE_POSTFIX+=" --disable-sdl2"
elif [[ ${library} -eq $((LIBRARY_APPLE_AUDIOTOOLBOX + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_AUDIOTOOLBOX} ]]; then
CONFIGURE_POSTFIX+=" --disable-audiotoolbox"
elif [[ ${library} -eq $((LIBRARY_APPLE_AVFOUNDATION + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_AVFOUNDATION} ]]; then
CONFIGURE_POSTFIX+=" --disable-avfoundation"
elif [[ ${library} -eq $((LIBRARY_APPLE_BZIP2 + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_BZIP2} ]]; then
CONFIGURE_POSTFIX+=" --disable-bzlib"
elif [[ ${library} -eq $((LIBRARY_APPLE_COREIMAGE + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_COREIMAGE} ]]; then
CONFIGURE_POSTFIX+=" --disable-coreimage --disable-appkit"
elif [[ ${library} -eq $((LIBRARY_APPLE_LIBICONV + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_LIBICONV} ]]; then
CONFIGURE_POSTFIX+=" --disable-iconv"
elif [[ ${library} -eq $((LIBRARY_APPLE_OPENCL + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_OPENCL} ]]; then
CONFIGURE_POSTFIX+=" --disable-opencl"
elif [[ ${library} -eq $((LIBRARY_APPLE_OPENGL + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_OPENGL} ]]; then
CONFIGURE_POSTFIX+=" --disable-opengl"
elif [[ ${library} -eq $((LIBRARY_APPLE_VIDEOTOOLBOX + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_VIDEOTOOLBOX} ]]; then
CONFIGURE_POSTFIX+=" --disable-videotoolbox"
elif [[ ${library} -eq $((LIBRARY_APPLE_ZLIB + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_APPLE_ZLIB} ]]; then
CONFIGURE_POSTFIX+=" --disable-zlib"
elif [[ ${library} -eq $((LIBRARY_OPENSSL + 1)) ]]; then
elif [[ ${library} -eq ${LIBRARY_OPENSSL} ]]; then
CONFIGURE_POSTFIX+=" --disable-openssl"
fi
fi
done
# SET CONFIGURE OPTIONS FOR CUSTOM LIBRARIES
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
pc_file_name="CUSTOM_LIBRARY_${custom_library_index}_PACKAGE_CONFIG_FILE_NAME"
ffmpeg_flag_name="CUSTOM_LIBRARY_${custom_library_index}_FFMPEG_ENABLE_FLAG"
echo -e "INFO: Enabling custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
FFMPEG_CFLAGS+=" $(pkg-config --cflags ${!pc_file_name} 2>>"${BASEDIR}"/build.log)"
FFMPEG_LDFLAGS+=" $(pkg-config --libs --static ${!pc_file_name} 2>>"${BASEDIR}"/build.log)"
CONFIGURE_POSTFIX+=" --enable-${!ffmpeg_flag_name}"
done
# ALWAYS BUILD SHARED LIBRARIES
BUILD_LIBRARY_OPTIONS="--enable-shared --disable-static --install-name-dir=@rpath"

View File

@ -50,6 +50,7 @@ under the prebuilt folder.\n"
display_help_common_libraries
display_help_gpl_libraries
display_help_custom_libraries
display_help_advanced_options " --no-archive\t\t\tdo not build Android archive [no]"
}

View File

@ -266,6 +266,27 @@ create_ffmpeg_universal_library() {
fi
done
# COPY CUSTOM LIBRARY LICENSES
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
library_name_uppercase=$(echo "${!library_name}" | tr '[a-z]' '[A-Z]')
relative_license_path="CUSTOM_LIBRARY_${custom_library_index}_LICENSE_FILE"
destination_license_path="${FFMPEG_UNIVERSAL_LIBRARY_DIRECTORY}/LICENSE.${library_name_uppercase}"
cp "${BASEDIR}/src/${!library_name}/${!relative_license_path}" "${destination_license_path}" 1>>"${BASEDIR}"/build.log 2>&1
RC=$?
if [[ ${RC} -ne 0 ]]; then
echo -e "DEBUG: Failed to copy the license file of custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
echo -e "DEBUG: Copied the license file of custom library ${!library_name} successfully\n" 1>>"${BASEDIR}"/build.log 2>&1
done
echo -e "DEBUG: ${LIBRARY_NAME} universal library built for $(get_apple_architecture_variant "${ARCHITECTURE_VARIANT}") platform successfully\n" 1>>"${BASEDIR}"/build.log 2>&1
}
@ -407,6 +428,27 @@ create_ffmpeg_framework() {
[[ ${RC} -ne 0 ]] && exit_universal_library "${LIBRARY_NAME}"
fi
done
# COPY CUSTOM LIBRARY LICENSES
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
library_name_uppercase=$(echo "${!library_name}" | tr '[a-z]' '[A-Z]')
relative_license_path="CUSTOM_LIBRARY_${custom_library_index}_LICENSE_FILE"
destination_license_path="${FFMPEG_LIB_FRAMEWORK_RESOURCE_PATH}/LICENSE.${ENABLED_LIBRARY_NAME_UPPERCASE}"
cp "${BASEDIR}/src/${!library_name}/${!relative_license_path}" "${destination_license_path}" 1>>"${BASEDIR}"/build.log 2>&1
RC=$?
if [[ ${RC} -ne 0 ]]; then
echo -e "DEBUG: Failed to copy the license file of custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "failed\n\nSee build.log for details\n"
exit 1
fi
echo -e "DEBUG: Copied the license file of custom library ${!library_name} successfully\n" 1>>"${BASEDIR}"/build.log 2>&1
done
fi
build_info_plist "${FFMPEG_LIB_FRAMEWORK_RESOURCE_PATH}/Info.plist" "${FFMPEG_LIB}" "com.arthenica.ffmpegkit.${CAPITAL_CASE_FFMPEG_LIB_NAME}" "${FFMPEG_LIB_VERSION}" "${FFMPEG_LIB_VERSION}" "${ARCHITECTURE_VARIANT}"

View File

@ -53,6 +53,7 @@ libraries are created under the prebuilt folder.\n"
display_help_common_libraries
display_help_gpl_libraries
display_help_custom_libraries
if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then
display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]"
else

View File

@ -41,6 +41,7 @@ When compilation ends, libraries are created under the prebuilt folder.\n"
display_help_common_libraries
display_help_gpl_libraries
display_help_custom_libraries
if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then
display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]"
else

View File

@ -41,6 +41,7 @@ set explicitly. When compilation ends, libraries are created under the prebuilt
display_help_common_libraries
display_help_gpl_libraries
display_help_custom_libraries
if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then
display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]"
else

View File

@ -496,6 +496,19 @@ get_host() {
esac
}
#
# 1. key
# 2. value
#
generate_custom_library_environment_variables() {
CUSTOM_KEY=$(echo "CUSTOM_$1" | sed "s/\-/\_/g" | tr '[a-z]' '[A-Z]')
CUSTOM_VALUE="$2"
export "${CUSTOM_KEY}"="${CUSTOM_VALUE}"
echo -e "INFO: Custom library env variable generated: ${CUSTOM_KEY}=${CUSTOM_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1
}
skip_library() {
SKIP_VARIABLE=$(echo "SKIP_$1" | sed "s/\-/\_/g")
@ -797,6 +810,17 @@ display_help_gpl_libraries() {
echo -e " --enable-xvidcore\t\tbuild with xvidcore [no]\n"
}
display_help_custom_libraries() {
echo -e "Custom libraries:"
echo -e " --enable-custom-library-[n]-name=value\t\t\tname of the custom library []"
echo -e " --enable-custom-library-[n]-repo=value\t\t\tgit repository url []"
echo -e " --enable-custom-library-[n]-repo-commit=value\t\t\tgit commit []"
echo -e " --enable-custom-library-[n]-repo-tag=value\t\t\tgit tag []"
echo -e " --enable-custom-library-[n]-package-config-file-name=value\tpackage config file installed by the build script []"
echo -e " --enable-custom-library-[n]-ffmpeg-enable-flag=value\tlibrary name used in ffmpeg configure script to enable the library []"
echo -e " --enable-custom-library-[n]-license-file=value\t\tlicence file path relative to the library source folder []\n"
}
display_help_advanced_options() {
echo -e "Advanced options:"
echo -e " --reconf-LIBRARY\t\trun autoreconf before building LIBRARY [no]"
@ -827,7 +851,11 @@ reconf_library() {
done
if [[ ${library_supported} -ne 1 ]]; then
echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>"${BASEDIR}"/build.log 2>&1
export ${RECONF_VARIABLE}=1
RECONF_LIBRARIES+=($1)
echo -e "INFO: --reconf flag detected for custom library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
else
echo -e "INFO: --reconf flag detected for library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
fi
}
@ -850,7 +878,11 @@ rebuild_library() {
done
if [[ ${library_supported} -ne 1 ]]; then
echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>"${BASEDIR}"/build.log 2>&1
export ${REBUILD_VARIABLE}=1
REBUILD_LIBRARIES+=($1)
echo -e "INFO: --rebuild flag detected for custom library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
else
echo -e "INFO: --rebuild flag detected for library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
fi
}
@ -879,7 +911,11 @@ redownload_library() {
fi
if [[ ${library_supported} -ne 1 ]]; then
echo -e "INFO: --redownload flag detected for library $1 is not supported.\n" 1>>"${BASEDIR}"/build.log 2>&1
export ${REDOWNLOAD_VARIABLE}=1
REDOWNLOAD_LIBRARIES+=($1)
echo -e "INFO: --redownload flag detected for custom library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
else
echo -e "INFO: --redownload flag detected for library $1.\n" 1>>"${BASEDIR}"/build.log 2>&1
fi
}
@ -1464,6 +1500,69 @@ print_redownload_requested_libraries() {
fi
}
print_custom_libraries() {
local counter=0
for index in {1..20}; do
LIBRARY_NAME="CUSTOM_LIBRARY_${index}_NAME"
LIBRARY_REPO="CUSTOM_LIBRARY_${index}_REPO"
LIBRARY_REPO_COMMIT="CUSTOM_LIBRARY_${index}_REPO_COMMIT"
LIBRARY_REPO_TAG="CUSTOM_LIBRARY_${index}_REPO_TAG"
LIBRARY_PACKAGE_CONFIG_FILE_NAME="CUSTOM_LIBRARY_${index}_PACKAGE_CONFIG_FILE_NAME"
LIBRARY_FFMPEG_ENABLE_FLAG="CUSTOM_LIBRARY_${index}_FFMPEG_ENABLE_FLAG"
LIBRARY_LICENSE_FILE="CUSTOM_LIBRARY_${index}_LICENSE_FILE"
if [[ -z "${!LIBRARY_NAME}" ]]; then
echo -e "INFO: Custom library ${index} not detected\n" 1>>"${BASEDIR}"/build.log 2>&1
break
fi
if [[ -z "${!LIBRARY_REPO}" ]]; then
echo -e "INFO: Custom library ${index} repo not set\n" 1>>"${BASEDIR}"/build.log 2>&1
continue
fi
if [[ -z "${!LIBRARY_REPO_COMMIT}" ]] && [[ -z "${!LIBRARY_REPO_TAG}" ]]; then
echo -e "INFO: Custom library ${index} repo source not set. Both commit id and tag are empty\n" 1>>"${BASEDIR}"/build.log 2>&1
continue
fi
if [[ -z "${!LIBRARY_PACKAGE_CONFIG_FILE_NAME}" ]]; then
echo -e "INFO: Custom library ${index} package config file not set\n" 1>>"${BASEDIR}"/build.log 2>&1
continue
fi
if [[ -z "${!LIBRARY_FFMPEG_ENABLE_FLAG}" ]]; then
echo -e "INFO: Custom library ${index} ffmpeg enable flag not set\n" 1>>"${BASEDIR}"/build.log 2>&1
continue
fi
if [[ -z "${!LIBRARY_LICENSE_FILE}" ]]; then
echo -e "INFO: Custom library ${index} license file not set\n" 1>>"${BASEDIR}"/build.log 2>&1
continue
fi
CUSTOM_LIBRARIES+=("${index}")
if [[ ${counter} -eq 0 ]]; then
echo -n "Custom libraries: "
else
echo -n ", "
fi
echo -n "${!LIBRARY_NAME}"
echo -e "INFO: Custom library options found for ${!LIBRARY_NAME}\n" 1>>"${BASEDIR}"/build.log 2>&1
counter=$((${counter} + 1))
done
if [[ ${counter} -gt 0 ]]; then
echo -e "INFO: ${counter} valid custom library definitions found\n" 1>>"${BASEDIR}"/build.log 2>&1
echo ""
fi
}
# 1 - library index
get_external_library_license_path() {
case $1 in
@ -1720,7 +1819,7 @@ is_gpl_licensed() {
echo 1
}
downloaded_enabled_library_sources() {
downloaded_library_sources() {
# DOWNLOAD FFMPEG SOURCE CODE FIRST
DOWNLOAD_RESULT=$(download_library_source "ffmpeg")
@ -1743,6 +1842,18 @@ downloaded_enabled_library_sources() {
fi
done
for custom_library_index in "${CUSTOM_LIBRARIES[@]}"; do
library_name="CUSTOM_LIBRARY_${custom_library_index}_NAME"
echo -e "\nDEBUG: Downloading custom library ${!library_name}\n" 1>>"${BASEDIR}"/build.log 2>&1
DOWNLOAD_RESULT=$(download_custom_library_source "${custom_library_index}")
if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then
echo -e "failed\n"
exit 1
fi
done
echo -e "ok"
}
@ -1819,6 +1930,57 @@ download_library_source() {
fi
}
#
# 1. custom library index
#
download_custom_library_source() {
local LIBRARY_NAME="CUSTOM_LIBRARY_$1_NAME"
local LIBRARY_REPO="CUSTOM_LIBRARY_$1_REPO"
local LIBRARY_REPO_COMMIT="CUSTOM_LIBRARY_$1_REPO_COMMIT"
local LIBRARY_REPO_TAG="CUSTOM_LIBRARY_$1_REPO_TAG"
local SOURCE_REPO_URL=""
local LIB_NAME="${!LIBRARY_NAME}"
local LIB_LOCAL_PATH=${BASEDIR}/src/${LIB_NAME}
local SOURCE_ID=""
local LIBRARY_RC=""
local DOWNLOAD_RC=""
local SOURCE_TYPE=""
echo -e "DEBUG: Downloading custom library source: ${LIB_NAME}\n" 1>>"${BASEDIR}"/build.log 2>&1
SOURCE_REPO_URL=${!LIBRARY_REPO}
if [ -n "${!LIBRARY_REPO_TAG}" ]; then
SOURCE_ID=${!LIBRARY_REPO_TAG}
SOURCE_TYPE="TAG"
else
SOURCE_ID=${!LIBRARY_REPO_COMMIT}
SOURCE_TYPE="COMMIT"
fi
LIBRARY_RC=$(library_is_downloaded "${LIB_NAME}")
if [ ${LIBRARY_RC} -eq 0 ]; then
echo -e "INFO: ${LIB_NAME} already downloaded. Source folder found at ${LIB_LOCAL_PATH}" 1>>"${BASEDIR}"/build.log 2>&1
echo 0
return
fi
if [ "${SOURCE_TYPE}" == "TAG" ]; then
DOWNLOAD_RC=$(clone_git_repository_with_tag "${SOURCE_REPO_URL}" "${SOURCE_ID}" "${LIB_LOCAL_PATH}")
else
DOWNLOAD_RC=$(clone_git_repository_with_commit_id "${SOURCE_REPO_URL}" "${LIB_LOCAL_PATH}" "${SOURCE_ID}")
fi
if [ ${DOWNLOAD_RC} -ne 0 ]; then
echo -e "INFO: Downloading custom library ${LIB_NAME} failed. Can not get library from ${SOURCE_REPO_URL}\n" 1>>"${BASEDIR}"/build.log 2>&1
echo ${DOWNLOAD_RC}
else
echo -e "\nINFO: ${LIB_NAME} custom library downloaded" 1>>"${BASEDIR}"/build.log 2>&1
echo 0
fi
}
download_gnu_config() {
local SOURCE_REPO_URL=""
local LIB_NAME="config"

View File

@ -25,9 +25,6 @@ if [[ -z ${TOOLCHAIN_ARCH} ]]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
echo -e "\nBuilding ${ARCH} platform on API level ${API}\n"
echo -e "\nINFO: Starting new build for ${ARCH} on API level ${API} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1
@ -206,11 +203,46 @@ while [ ${#enabled_library_list[@]} -gt $completed ]; do
done
done
# 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-android.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
# SKIP TO SPEED UP THE BUILD
if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
# BUILD FFMPEG
"${BASEDIR}"/scripts/android/ffmpeg.sh "$@"
source "${BASEDIR}"/scripts/android/ffmpeg.sh
if [[ $? -ne 0 ]]; then
exit 1

View File

@ -20,9 +20,6 @@ if [[ -z ${SDK_PATH} ]]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
echo -e "\nBuilding ${ARCH} platform targeting iOS SDK ${IOS_MIN_VERSION} and Mac Catalyst ${MAC_CATALYST_MIN_VERSION}\n"
echo -e "\nINFO: Starting new build for ${ARCH} targeting iOS SDK ${IOS_MIN_VERSION} and Mac Catalyst ${MAC_CATALYST_MIN_VERSION} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1
@ -176,6 +173,41 @@ while [ ${#enabled_library_list[@]} -gt $completed ]; do
done
done
# 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
# SKIP TO SPEED UP THE BUILD
if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
@ -192,10 +224,10 @@ if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
cd "${BASEDIR}"/src/"${LIB_NAME}" 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
LIB_INSTALL_PREFIX="${LIB_INSTALL_BASE}"/"${LIB_NAME}"
LIB_INSTALL_PREFIX="${LIB_INSTALL_BASE}/${LIB_NAME}"
# BUILD FFMPEG
source "${BASEDIR}"/scripts/apple/ffmpeg.sh "$@"
source "${BASEDIR}"/scripts/apple/ffmpeg.sh
if [[ $? -ne 0 ]]; then
exit 1

View File

@ -20,9 +20,6 @@ if [[ -z ${SDK_PATH} ]]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
echo -e "\nBuilding ${ARCH} platform targeting macOS SDK ${MACOS_MIN_VERSION}\n"
echo -e "\nINFO: Starting new build for ${ARCH} targeting macOS SDK ${MACOS_MIN_VERSION} at $(date)\n" 1>>"${BASEDIR}"/build.log 2>&1
@ -175,6 +172,41 @@ while [ ${#enabled_library_list[@]} -gt $completed ]; do
done
done
# 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
# SKIP TO SPEED UP THE BUILD
if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
@ -191,10 +223,10 @@ if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
cd "${BASEDIR}"/src/"${LIB_NAME}" 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
LIB_INSTALL_PREFIX="${LIB_INSTALL_BASE}"/"${LIB_NAME}"
LIB_INSTALL_PREFIX="${LIB_INSTALL_BASE}/${LIB_NAME}"
# BUILD FFMPEG
source "${BASEDIR}"/scripts/apple/ffmpeg.sh "$@"
source "${BASEDIR}"/scripts/apple/ffmpeg.sh
if [[ $? -ne 0 ]]; then
exit 1

View File

@ -20,9 +20,6 @@ if [[ -z ${SDK_PATH} ]]; then
exit 1
fi
# ENABLE COMMON FUNCTIONS
source "${BASEDIR}"/scripts/function-"${FFMPEG_KIT_BUILD_TYPE}".sh 1>>"${BASEDIR}"/build.log 2>&1 || exit 1
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
@ -174,6 +171,41 @@ while [ ${#enabled_library_list[@]} -gt $completed ]; do
done
done
# 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
# SKIP TO SPEED UP THE BUILD
if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
@ -193,7 +225,7 @@ if [[ ${SKIP_ffmpeg} -ne 1 ]]; then
LIB_INSTALL_PREFIX="${LIB_INSTALL_BASE}/${LIB_NAME}"
# BUILD FFMPEG
source "${BASEDIR}"/scripts/apple/ffmpeg.sh "$@"
source "${BASEDIR}"/scripts/apple/ffmpeg.sh
if [[ $? -ne 0 ]]; then
exit 1

View File

@ -21,6 +21,9 @@ REBUILD_LIBRARIES=()
# ARRAY OF LIBRARIES THAT WILL BE RE-DOWNLOADED
REDOWNLOAD_LIBRARIES=()
# ARRAY OF CUSTOM LIBRARIES
CUSTOM_LIBRARIES=()
# ARCH INDEXES
ARCH_ARM_V7A=0 # android
ARCH_ARM_V7A_NEON=1 # android

52
src/.gitignore vendored
View File

@ -1,51 +1 @@
chromaprint
cpu-features
dav1d
expat
ffmpeg
fontconfig
freetype
fribidi
giflib
gmp
gnutls
harfbuzz
jpeg
kvazaar
lame
leptonica
libaom
libass
libiconv
libilbc
libogg
libpng
libsamplerate
libsndfile
libtheora
libuuid
libvidstab
libvorbis
libvpx
libwebp
libxml2
nettle
opencore-amr
openh264
openssl
opus
rubberband
sdl
shine
snappy
soxr
speex
srt
tesseract
tiff
twolame
vo-amrwbenc
x264
x265
xvidcore
zimg
/*

13
tvos.sh
View File

@ -116,6 +116,14 @@ while [ ! $# -eq 0 ]; do
--enable-gpl)
GPL_ENABLED="yes"
;;
--enable-custom-library-*)
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
CUSTOM_LIBRARY_OPTION_VALUE=$(echo $1 | sed -e 's/^--enable-custom-.*=//g')
echo -e "INFO: Custom library options detected: ${CUSTOM_LIBRARY_OPTION_KEY} ${CUSTOM_LIBRARY_OPTION_VALUE}\n" 1>>"${BASEDIR}"/build.log 2>&1
generate_custom_library_environment_variables "${CUSTOM_LIBRARY_OPTION_KEY}" "${CUSTOM_LIBRARY_OPTION_VALUE}"
;;
--enable-*)
ENABLED_LIBRARY=$(echo $1 | sed -e 's/^--[A-Za-z]*-//g')
@ -191,6 +199,7 @@ print_enabled_libraries
print_reconfigure_requested_libraries
print_rebuild_requested_libraries
print_redownload_requested_libraries
print_custom_libraries
# VALIDATE GPL FLAGS
for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVIDSTAB,$LIBRARY_RUBBERBAND}; do
@ -206,13 +215,13 @@ for gpl_library in {$LIBRARY_X264,$LIBRARY_XVIDCORE,$LIBRARY_X265,$LIBRARY_LIBVI
done
echo -n -e "\nDownloading sources: "
echo -e "INFO: Downloading source code of ffmpeg and enabled external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
echo -e "INFO: Downloading the source code of ffmpeg and external libraries.\n" 1>>"${BASEDIR}"/build.log 2>&1
# DOWNLOAD GNU CONFIG
download_gnu_config
# DOWNLOAD LIBRARY SOURCES
downloaded_enabled_library_sources "${ENABLED_LIBRARIES[@]}"
downloaded_library_sources "${ENABLED_LIBRARIES[@]}"
# THIS WILL SAVE ARCHITECTURES TO BUILD
TARGET_ARCH_LIST=()