Skip to content

Commit

Permalink
allow disabling bitcode in ios and tvos, fixes #614
Browse files Browse the repository at this point in the history
  • Loading branch information
tanersener committed Nov 19, 2022
1 parent fd719cd commit e0eb57b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do

skip_library "${SKIP_LIBRARY}"
;;
--no-bitcode)
export NO_BITCODE="1"
;;
--no-framework)
NO_FRAMEWORK="1"
;;
Expand Down
4 changes: 4 additions & 0 deletions scripts/apple/ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ x86-64-mac-catalyst)
;;
esac

if [ ! -z $NO_BITCODE ]; then
BITCODE_FLAGS=""
fi

CONFIGURE_POSTFIX=""
HIGH_PRIORITY_LDFLAGS=""

Expand Down
20 changes: 14 additions & 6 deletions scripts/function-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}"
Expand Down
24 changes: 18 additions & 6 deletions scripts/function-tvos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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}"
Expand Down
3 changes: 3 additions & 0 deletions scripts/function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

Expand Down
3 changes: 3 additions & 0 deletions tvos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ while [ ! $# -eq 0 ]; do

skip_library "${SKIP_LIBRARY}"
;;
--no-bitcode)
export NO_BITCODE="1"
;;
--no-framework)
NO_FRAMEWORK="1"
;;
Expand Down

0 comments on commit e0eb57b

Please sign in to comment.