From 24bb7fb6b9c9100ba15f734032110af47e0d6b7d Mon Sep 17 00:00:00 2001 From: Taner Sener Date: Sun, 6 Nov 2022 20:33:01 +0000 Subject: [PATCH] allow disabling bitcode in ios and tvos, fixes #614 --- ios.sh | 3 +++ scripts/apple/ffmpeg.sh | 4 ++++ scripts/function-ios.sh | 20 ++++++++++++++------ scripts/function-tvos.sh | 24 ++++++++++++++++++------ scripts/function.sh | 3 +++ tvos.sh | 3 +++ 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ios.sh b/ios.sh index 0f28538..17ed291 100755 --- a/ios.sh +++ b/ios.sh @@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do skip_library "${SKIP_LIBRARY}" ;; + --no-bitcode) + export NO_BITCODE="1" + ;; --no-framework) NO_FRAMEWORK="1" ;; diff --git a/scripts/apple/ffmpeg.sh b/scripts/apple/ffmpeg.sh index 4ca30ec..0b3a614 100755 --- a/scripts/apple/ffmpeg.sh +++ b/scripts/apple/ffmpeg.sh @@ -98,6 +98,10 @@ x86-64-mac-catalyst) ;; esac +if [ ! -z $NO_BITCODE ]; then + BITCODE_FLAGS="" +fi + CONFIGURE_POSTFIX="" HIGH_PRIORITY_LDFLAGS="" diff --git a/scripts/function-ios.sh b/scripts/function-ios.sh index 2853c96..02ae7c3 100755 --- a/scripts/function-ios.sh +++ b/scripts/function-ios.sh @@ -55,9 +55,9 @@ libraries are created under the prebuilt folder.\n" 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]" + 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 - 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 } @@ -105,16 +105,19 @@ get_common_cflags() { fi 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 i386 | x86-64 | arm64-simulator) echo "-fstrict-aliasing -DIOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" ;; *-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 } @@ -278,7 +281,9 @@ get_cxxflags() { local BITCODE_FLAGS="" case ${ARCH} in armv7 | armv7s | arm64 | arm64e | *-mac-catalyst) - local BITCODE_FLAGS="-fembed-bitcode" + if [ -z $NO_BITCODE ]; then + local BITCODE_FLAGS="-fembed-bitcode" + fi ;; esac @@ -384,12 +389,15 @@ get_ldflags() { local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}" fi local COMMON_FLAGS=$(get_common_ldflags) + if [ -z $NO_BITCODE ]; then + local BITCODE_FLAGS="-fembed-bitcode -Wc,-fembed-bitcode" + fi case $1 in ffmpeg-kit) case ${ARCH} in 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}" diff --git a/scripts/function-tvos.sh b/scripts/function-tvos.sh index 98dc5b6..f36f0f6 100755 --- a/scripts/function-tvos.sh +++ b/scripts/function-tvos.sh @@ -43,9 +43,9 @@ set explicitly. When compilation ends, libraries are created under the prebuilt 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]" + 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 - 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 } @@ -79,10 +79,13 @@ get_common_cflags() { fi 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 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) echo "-fstrict-aliasing -DTVOS ${LTS_BUILD_FLAG}${BUILD_DATE} -isysroot ${SDK_PATH}" @@ -254,7 +257,9 @@ get_cxxflags() { local BITCODE_FLAGS="" case ${ARCH} in arm64) - local BITCODE_FLAGS="-fembed-bitcode" + if [ -z $NO_BITCODE ]; then + local BITCODE_FLAGS="-fembed-bitcode" + fi ;; esac @@ -320,9 +325,13 @@ get_size_optimization_ldflags() { } get_arch_specific_ldflags() { + if [ -z $NO_BITCODE ]; then + local BITCODE_FLAGS="-fembed-bitcode" + fi + case ${ARCH} in arm64) - echo "-arch arm64 -march=armv8-a+crc+crypto -fembed-bitcode" + echo "-arch arm64 -march=armv8-a+crc+crypto ${BITCODE_FLAGS}" ;; arm64-simulator) echo "-arch arm64 -march=armv8-a+crc+crypto" @@ -342,12 +351,15 @@ get_ldflags() { local OPTIMIZATION_FLAGS="${FFMPEG_KIT_DEBUG}" fi local COMMON_FLAGS=$(get_common_ldflags) + if [ -z $NO_BITCODE ]; then + local BITCODE_FLAGS="-fembed-bitcode -Wc,-fembed-bitcode" + fi case $1 in ffmpeg-kit) case ${ARCH} in 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}" diff --git a/scripts/function.sh b/scripts/function.sh index 6595a7e..421cb80 100755 --- a/scripts/function.sh +++ b/scripts/function.sh @@ -927,6 +927,9 @@ display_help_advanced_options() { if [ -n "$1" ]; then echo -e "$1" fi + if [ -n "$2" ]; then + echo -e "$2" + fi echo -e "" } diff --git a/tvos.sh b/tvos.sh index ac097a8..1165963 100755 --- a/tvos.sh +++ b/tvos.sh @@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do skip_library "${SKIP_LIBRARY}" ;; + --no-bitcode) + export NO_BITCODE="1" + ;; --no-framework) NO_FRAMEWORK="1" ;;