allow disabling bitcode in ios and tvos, fixes #614

This commit is contained in:
Taner Sener 2022-11-06 20:33:01 +00:00
parent a69ea8c844
commit a48591b802
6 changed files with 45 additions and 12 deletions

3
ios.sh
View File

@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do
skip_library "${SKIP_LIBRARY}" skip_library "${SKIP_LIBRARY}"
;; ;;
--no-bitcode)
export NO_BITCODE="1"
;;
--no-framework) --no-framework)
NO_FRAMEWORK="1" NO_FRAMEWORK="1"
;; ;;

View File

@ -98,6 +98,10 @@ x86-64-mac-catalyst)
;; ;;
esac esac
if [ ! -z $NO_BITCODE ]; then
BITCODE_FLAGS=""
fi
CONFIGURE_POSTFIX="" CONFIGURE_POSTFIX=""
HIGH_PRIORITY_LDFLAGS="" HIGH_PRIORITY_LDFLAGS=""

View File

@ -55,9 +55,9 @@ libraries are created under the prebuilt folder.\n"
display_help_gpl_libraries display_help_gpl_libraries
display_help_custom_libraries display_help_custom_libraries
if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then
display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]" display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]" " --no-bitcode\t\t\tdo not enable bitcode in bundles [no]"
else else
display_help_advanced_options " --no-framework\t\tdo not build framework bundles [no]" display_help_advanced_options " --no-framework\t\tdo not build framework bundles [no]" " --no-bitcode\t\t\tdo not enable bitcode in bundles [no]"
fi fi
} }
@ -105,16 +105,19 @@ get_common_cflags() {
fi fi
local BUILD_DATE="-DFFMPEG_KIT_BUILD_DATE=$(date +%Y%m%d 2>>"${BASEDIR}"/build.log)" local BUILD_DATE="-DFFMPEG_KIT_BUILD_DATE=$(date +%Y%m%d 2>>"${BASEDIR}"/build.log)"
if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode"
fi
case ${ARCH} in case ${ARCH} in
i386 | x86-64 | arm64-simulator) i386 | x86-64 | arm64-simulator)
echo "-fstrict-aliasing -DIOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing -DIOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
*-mac-catalyst) *-mac-catalyst)
echo "-fstrict-aliasing -fembed-bitcode -DMACOSX ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing ${BITCODE_FLAGS} -DMACOSX ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
*) *)
echo "-fstrict-aliasing -fembed-bitcode -DIOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing ${BITCODE_FLAGS} -DIOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
esac esac
} }
@ -278,7 +281,9 @@ get_cxxflags() {
local BITCODE_FLAGS="" local BITCODE_FLAGS=""
case ${ARCH} in case ${ARCH} in
armv7 | armv7s | arm64 | arm64e | *-mac-catalyst) armv7 | armv7s | arm64 | arm64e | *-mac-catalyst)
local BITCODE_FLAGS="-fembed-bitcode" if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode"
fi
;; ;;
esac esac
@ -384,12 +389,15 @@ get_ldflags() {
local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}" local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}"
fi fi
local COMMON_FLAGS=$(get_common_ldflags) local COMMON_FLAGS=$(get_common_ldflags)
if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode -Wc,-fembed-bitcode"
fi
case $1 in case $1 in
ffmpeg-kit) ffmpeg-kit)
case ${ARCH} in case ${ARCH} in
armv7 | armv7s | arm64 | arm64e | *-mac-catalyst) armv7 | armv7s | arm64 | arm64e | *-mac-catalyst)
echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} -fembed-bitcode -Wc,-fembed-bitcode ${OPTIMIZATION_FLAGS}" echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${BITCODE_FLAGS} ${OPTIMIZATION_FLAGS}"
;; ;;
*) *)
echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${OPTIMIZATION_FLAGS}" echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${OPTIMIZATION_FLAGS}"

View File

@ -43,9 +43,9 @@ set explicitly. When compilation ends, libraries are created under the prebuilt
display_help_gpl_libraries display_help_gpl_libraries
display_help_custom_libraries display_help_custom_libraries
if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then if [[ -n ${FFMPEG_KIT_XCF_BUILD} ]]; then
display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]" display_help_advanced_options " --no-framework\t\tdo not build xcframework bundles [no]" " --no-bitcode\t\t\tdo not enable bitcode in bundles [no]"
else else
display_help_advanced_options " --no-framework\t\tdo not build framework bundles [no]" display_help_advanced_options " --no-framework\t\tdo not build framework bundles [no]" " --no-bitcode\t\t\tdo not enable bitcode in bundles [no]"
fi fi
} }
@ -79,10 +79,13 @@ get_common_cflags() {
fi fi
local BUILD_DATE="-DFFMPEG_KIT_BUILD_DATE=$(date +%Y%m%d 2>>"${BASEDIR}"/build.log)" local BUILD_DATE="-DFFMPEG_KIT_BUILD_DATE=$(date +%Y%m%d 2>>"${BASEDIR}"/build.log)"
if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode"
fi
case ${ARCH} in case ${ARCH} in
arm64) arm64)
echo "-fstrict-aliasing -fembed-bitcode -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" echo "-fstrict-aliasing ${BITCODE_FLAGS} -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}"
;; ;;
x86-64 | arm64-simulator) 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}"
@ -254,7 +257,9 @@ get_cxxflags() {
local BITCODE_FLAGS="" local BITCODE_FLAGS=""
case ${ARCH} in case ${ARCH} in
arm64) arm64)
local BITCODE_FLAGS="-fembed-bitcode" if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode"
fi
;; ;;
esac esac
@ -320,9 +325,13 @@ get_size_optimization_ldflags() {
} }
get_arch_specific_ldflags() { get_arch_specific_ldflags() {
if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode"
fi
case ${ARCH} in case ${ARCH} in
arm64) arm64)
echo "-arch arm64 -march=armv8-a+crc+crypto -fembed-bitcode" echo "-arch arm64 -march=armv8-a+crc+crypto ${BITCODE_FLAGS}"
;; ;;
arm64-simulator) arm64-simulator)
echo "-arch arm64 -march=armv8-a+crc+crypto" echo "-arch arm64 -march=armv8-a+crc+crypto"
@ -342,12 +351,15 @@ get_ldflags() {
local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}" local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}"
fi fi
local COMMON_FLAGS=$(get_common_ldflags) local COMMON_FLAGS=$(get_common_ldflags)
if [ -z $NO_BITCODE ]; then
local BITCODE_FLAGS="-fembed-bitcode -Wc,-fembed-bitcode"
fi
case $1 in case $1 in
ffmpeg-kit) ffmpeg-kit)
case ${ARCH} in case ${ARCH} in
arm64) arm64)
echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} -fembed-bitcode -Wc,-fembed-bitcode ${OPTIMIZATION_FLAGS}" echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${BITCODE_FLAGS} ${OPTIMIZATION_FLAGS}"
;; ;;
*) *)
echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${OPTIMIZATION_FLAGS}" echo "${ARCH_FLAGS} ${LINKED_LIBRARIES} ${COMMON_FLAGS} ${OPTIMIZATION_FLAGS}"

View File

@ -927,6 +927,9 @@ display_help_advanced_options() {
if [ -n "$1" ]; then if [ -n "$1" ]; then
echo -e "$1" echo -e "$1"
fi fi
if [ -n "$2" ]; then
echo -e "$2"
fi
echo -e "" echo -e ""
} }

View File

@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do
skip_library "${SKIP_LIBRARY}" skip_library "${SKIP_LIBRARY}"
;; ;;
--no-bitcode)
export NO_BITCODE="1"
;;
--no-framework) --no-framework)
NO_FRAMEWORK="1" NO_FRAMEWORK="1"
;; ;;