support arm64-simulator on tvos

This commit is contained in:
Taner Sener 2021-02-27 12:33:12 +00:00
parent 21821a8a51
commit d14a9f0c6f
6 changed files with 92 additions and 20 deletions

View File

@ -91,6 +91,36 @@ disable_ios_architecture_not_supported_on_detected_sdk_version() {
fi fi
} }
#
# 1. architecture index
# 2. detected sdk version
#
disable_tvos_architecture_not_supported_on_detected_sdk_version() {
local ARCH_NAME=$(get_arch_name $1)
case ${ARCH_NAME} in
arm64-simulator)
# INTRODUCED IN TVOS SDK 14
if [[ $2 == 14* ]]; then
local SUPPORTED=1
else
local SUPPORTED=0
fi
;;
*)
local SUPPORTED=1
;;
esac
if [[ ${SUPPORTED} -ne 1 ]]; then
if [[ -z ${BUILD_FORCE} ]]; then
echo -e "INFO: Disabled ${ARCH_NAME} architecture which is not supported on SDK $2\n" 1>>"${BASEDIR}"/build.log 2>&1
disable_arch "${ARCH_NAME}"
fi
fi
}
# #
# 1. architecture index # 1. architecture index
# 2. detected sdk version # 2. detected sdk version
@ -925,7 +955,7 @@ get_apple_architectures_for_variant() {
done done
;; ;;
"${ARCH_VAR_TVOS}") "${ARCH_VAR_TVOS}")
for index in ${ARCH_ARM64} ${ARCH_X86_64}; do for index in ${ARCH_ARM64} ${ARCH_X86_64} ${ARCH_ARM64_SIMULATOR}; do
ARCHITECTURES+=" $(get_full_arch_name "${index}") " ARCHITECTURES+=" $(get_full_arch_name "${index}") "
done done
;; ;;
@ -935,7 +965,7 @@ get_apple_architectures_for_variant() {
done done
;; ;;
"${ARCH_VAR_APPLETVSIMULATOR}") "${ARCH_VAR_APPLETVSIMULATOR}")
for index in ${ARCH_X86_64}; do for index in ${ARCH_X86_64} ${ARCH_ARM64_SIMULATOR}; do
ARCHITECTURES+=" $(get_full_arch_name "${index}") " ARCHITECTURES+=" $(get_full_arch_name "${index}") "
done done
;; ;;
@ -1140,9 +1170,19 @@ get_sdk_name() {
;; ;;
esac esac
;; ;;
i386 | arm64-simulator) i386)
echo "iphonesimulator" echo "iphonesimulator"
;; ;;
arm64-simulator)
case ${FFMPEG_KIT_BUILD_TYPE} in
ios)
echo "iphonesimulator"
;;
tvos)
echo "appletvsimulator"
;;
esac
;;
*-mac-catalyst) *-mac-catalyst)
echo "macosx" echo "macosx"
;; ;;
@ -1180,9 +1220,19 @@ get_min_version_cflags() {
;; ;;
esac esac
;; ;;
i386 | arm64-simulator) i386)
echo "-mios-simulator-version-min=$(get_min_sdk_version)" echo "-mios-simulator-version-min=$(get_min_sdk_version)"
;; ;;
arm64-simulator)
case ${FFMPEG_KIT_BUILD_TYPE} in
ios)
echo "-mios-simulator-version-min=$(get_min_sdk_version)"
;;
tvos)
echo "-mappletvsimulator-version-min=$(get_min_sdk_version)"
;;
esac
;;
*-mac-catalyst) *-mac-catalyst)
echo "-miphoneos-version-min=$(get_min_sdk_version)" echo "-miphoneos-version-min=$(get_min_sdk_version)"
;; ;;

View File

@ -18,8 +18,8 @@ display_help() {
COMMAND=$(echo "$0" | sed -e 's/\.\///g') COMMAND=$(echo "$0" | sed -e 's/\.\///g')
echo -e "\n'$COMMAND' builds FFmpegKit for iOS platform. By default nine architectures (armv7, armv7s, arm64, \ echo -e "\n'$COMMAND' builds FFmpegKit for iOS platform. By default nine architectures (armv7, armv7s, arm64, \
arm64-simulator, arm64-mac-catalyst, arm64e, i386, x86-64 and x86-64-mac-catalyst) are built without any external \ arm64-mac-catalyst, arm64-simulator, arm64e, i386, x86-64 and x86-64-mac-catalyst) are enabled without any external \
libraries enabled. Options can be used to disable architectures and/or enable external libraries. Please note that GPL \ libraries. 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, \ libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. When compilation ends, \
libraries are created under the prebuilt folder.\n" libraries are created under the prebuilt folder.\n"
echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Usage: ./$COMMAND [OPTION]...\n"
@ -32,8 +32,8 @@ libraries are created under the prebuilt folder.\n"
echo -e " --disable-armv7\t\tdo not build armv7 architecture [yes]" echo -e " --disable-armv7\t\tdo not build armv7 architecture [yes]"
echo -e " --disable-armv7s\t\tdo not build armv7s architecture [yes]" echo -e " --disable-armv7s\t\tdo not build armv7s architecture [yes]"
echo -e " --disable-arm64\t\tdo not build arm64 architecture [yes]" echo -e " --disable-arm64\t\tdo not build arm64 architecture [yes]"
echo -e " --disable-arm64-simulator\tdo not build arm64-simulator architecture [yes]"
echo -e " --disable-arm64-mac-catalyst\tdo not build arm64-mac-catalyst architecture [yes]" echo -e " --disable-arm64-mac-catalyst\tdo not build arm64-mac-catalyst architecture [yes]"
echo -e " --disable-arm64-simulator\tdo not build arm64-simulator architecture [yes]"
echo -e " --disable-arm64e\t\tdo not build arm64e architecture [yes]" echo -e " --disable-arm64e\t\tdo not build arm64e architecture [yes]"
echo -e " --disable-i386\t\tdo not build i386 architecture [yes]" echo -e " --disable-i386\t\tdo not build i386 architecture [yes]"
echo -e " --disable-x86-64\t\tdo not build x86-64 architecture [yes]" echo -e " --disable-x86-64\t\tdo not build x86-64 architecture [yes]"

View File

@ -10,8 +10,8 @@ enable_default_macos_architectures() {
display_help() { display_help() {
COMMAND=$(echo "$0" | sed -e 's/\.\///g') COMMAND=$(echo "$0" | sed -e 's/\.\///g')
echo -e "\n'$COMMAND' builds FFmpegKit for macOS platform. By default two architectures (arm64 and x86-64) are built \ echo -e "\n'$COMMAND' builds FFmpegKit for macOS platform. By default two architectures (arm64 and x86-64) are \
without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. \ enabled without any external libraries. 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. \ Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. \
When compilation ends, libraries are created under the prebuilt folder.\n" When compilation ends, libraries are created under the prebuilt folder.\n"
echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Usage: ./$COMMAND [OPTION]...\n"

View File

@ -5,15 +5,16 @@ source "${BASEDIR}/scripts/function-apple.sh"
enable_default_tvos_architectures() { enable_default_tvos_architectures() {
ENABLED_ARCHITECTURES[ARCH_ARM64]=1 ENABLED_ARCHITECTURES[ARCH_ARM64]=1
ENABLED_ARCHITECTURES[ARCH_X86_64]=1 ENABLED_ARCHITECTURES[ARCH_X86_64]=1
ENABLED_ARCHITECTURES[ARCH_ARM64_SIMULATOR]=1
} }
display_help() { display_help() {
COMMAND=$(echo "$0" | sed -e 's/\.\///g') COMMAND=$(echo "$0" | sed -e 's/\.\///g')
echo -e "\n'$COMMAND' builds FFmpegKit for tvOS platform. By default two architectures (arm64 and x86-64) are built \ echo -e "\n'$COMMAND' builds FFmpegKit for tvOS platform. By default three architectures (arm64, arm64-simulator \
without any external libraries enabled. Options can be used to disable architectures and/or enable external libraries. \ and x86-64) are enabled without any external libraries. Options can be used to disable architectures and/or enable \
Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. \ external libraries. Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be \
When compilation ends, libraries are created under the prebuilt folder.\n" set explicitly. When compilation ends, libraries are created under the prebuilt folder.\n"
echo -e "Usage: ./$COMMAND [OPTION]...\n" echo -e "Usage: ./$COMMAND [OPTION]...\n"
echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n" echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n"
@ -23,6 +24,7 @@ When compilation ends, libraries are created under the prebuilt folder.\n"
echo -e "Architectures:" echo -e "Architectures:"
echo -e " --disable-arm64\t\tdo not build arm64 architecture [yes]" echo -e " --disable-arm64\t\tdo not build arm64 architecture [yes]"
echo -e " --disable-arm64-simulator\tdo not build arm64-simulator architecture [yes]"
echo -e " --disable-x86-64\t\tdo not build x86-64 architecture [yes]\n" echo -e " --disable-x86-64\t\tdo not build x86-64 architecture [yes]\n"
echo -e "Libraries:" echo -e "Libraries:"
@ -73,7 +75,7 @@ get_common_cflags() {
arm64) arm64)
echo "-fstrict-aliasing -fembed-bitcode -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing -fembed-bitcode -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
x86-64) x86-64 | arm64-simulator)
echo "-fstrict-aliasing -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
esac esac
@ -84,6 +86,9 @@ get_arch_specific_cflags() {
arm64) arm64)
echo "-arch arm64 -target $(get_target) -march=armv8-a+crc+crypto -mcpu=generic -DFFMPEG_KIT_ARM64" echo "-arch arm64 -target $(get_target) -march=armv8-a+crc+crypto -mcpu=generic -DFFMPEG_KIT_ARM64"
;; ;;
arm64-simulator)
echo "-arch arm64 -target $(get_target) -march=armv8-a+crc+crypto -mcpu=generic -DFFMPEG_KIT_ARM64_SIMULATOR"
;;
x86-64) x86-64)
echo "-arch x86_64 -target $(get_target) -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DFFMPEG_KIT_X86_64" echo "-arch x86_64 -target $(get_target) -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DFFMPEG_KIT_X86_64"
;; ;;
@ -107,7 +112,7 @@ get_size_optimization_cflags() {
;; ;;
esac esac
;; ;;
x86-64) x86-64 | arm64-simulator)
case $1 in case $1 in
x264 | ffmpeg) x264 | ffmpeg)
ARCH_OPTIMIZATION="-O2 -Wno-ignored-optimization-argument" ARCH_OPTIMIZATION="-O2 -Wno-ignored-optimization-argument"
@ -134,7 +139,7 @@ get_size_optimization_asm_cflags() {
arm64) arm64)
ARCH_OPTIMIZATION="-Oz" ARCH_OPTIMIZATION="-Oz"
;; ;;
x86-64) x86-64 | arm64-simulator)
ARCH_OPTIMIZATION="-O2" ARCH_OPTIMIZATION="-O2"
;; ;;
esac esac
@ -307,6 +312,9 @@ get_arch_specific_ldflags() {
arm64) arm64)
echo "-arch arm64 -march=armv8-a+crc+crypto -fembed-bitcode" echo "-arch arm64 -march=armv8-a+crc+crypto -fembed-bitcode"
;; ;;
arm64-simulator)
echo "-arch arm64 -march=armv8-a+crc+crypto"
;;
x86-64) x86-64)
echo "-arch x86_64 -march=x86-64" echo "-arch x86_64 -march=x86-64"
;; ;;
@ -367,7 +375,7 @@ set_toolchain_paths() {
LOCAL_ASMFLAGS="$(get_asmflags "$1")" LOCAL_ASMFLAGS="$(get_asmflags "$1")"
case ${ARCH} in case ${ARCH} in
arm64) arm64*)
if [ "$1" == "x265" ]; then if [ "$1" == "x265" ]; then
export AS="${LOCAL_GAS_PREPROCESSOR}" export AS="${LOCAL_GAS_PREPROCESSOR}"
export AS_ARGUMENTS="-arch aarch64" export AS_ARGUMENTS="-arch aarch64"

View File

@ -16,7 +16,7 @@ get_arch_name() {
9) echo "x86-64" ;; # android, ios, macos, tvos 9) echo "x86-64" ;; # android, ios, macos, tvos
10) echo "x86-64-mac-catalyst" ;; # ios 10) echo "x86-64-mac-catalyst" ;; # ios
11) echo "arm64-mac-catalyst" ;; # ios 11) echo "arm64-mac-catalyst" ;; # ios
12) echo "arm64-simulator" ;; # ios 12) echo "arm64-simulator" ;; # ios, tvos
esac esac
} }
@ -427,7 +427,11 @@ get_target() {
fi fi
;; ;;
arm64-simulator) arm64-simulator)
if [[ ${FFMPEG_KIT_BUILD_TYPE} == "ios" ]]; then
echo "$(get_target_cpu)-apple-ios$(get_min_sdk_version)-simulator" echo "$(get_target_cpu)-apple-ios$(get_min_sdk_version)-simulator"
elif [[ ${FFMPEG_KIT_BUILD_TYPE} == "tvos" ]]; then
echo "$(get_target_cpu)-apple-tvos$(get_min_sdk_version)-simulator"
fi
;; ;;
x86-64) x86-64)
if [[ ${FFMPEG_KIT_BUILD_TYPE} == "android" ]]; then if [[ ${FFMPEG_KIT_BUILD_TYPE} == "android" ]]; then
@ -451,9 +455,16 @@ get_host() {
arm-v7a | arm-v7a-neon) arm-v7a | arm-v7a-neon)
echo "arm-linux-androideabi" echo "arm-linux-androideabi"
;; ;;
armv7 | armv7s | arm64e | i386 | *-mac-catalyst | arm64-simulator) armv7 | armv7s | arm64e | i386 | *-mac-catalyst)
echo "$(get_target_cpu)-ios-darwin" echo "$(get_target_cpu)-ios-darwin"
;; ;;
arm64-simulator)
if [[ ${FFMPEG_KIT_BUILD_TYPE} == "ios" ]]; then
echo "$(get_target_cpu)-ios-darwin"
elif [[ ${FFMPEG_KIT_BUILD_TYPE} == "tvos" ]]; then
echo "$(get_target_cpu)-tvos-darwin"
fi
;;
arm64-v8a) arm64-v8a)
echo "aarch64-linux-android" echo "aarch64-linux-android"
;; ;;

View File

@ -157,6 +157,9 @@ if [[ -n ${DISPLAY_HELP} ]]; then
exit 0 exit 0
fi fi
# DISABLE NOT SUPPORTED ARCHITECTURES
disable_tvos_architecture_not_supported_on_detected_sdk_version "${ARCH_ARM64_SIMULATOR}" "${DETECTED_TVOS_SDK_VERSION}"
# CHECK SOME RULES FOR .xcframework BUNDLES # CHECK SOME RULES FOR .xcframework BUNDLES
# 1. DO NOT ALLOW --lts AND --xcframework OPTIONS TOGETHER # 1. DO NOT ALLOW --lts AND --xcframework OPTIONS TOGETHER