Embed Bitcode in framework based on obj files

Suppress annoying warnings about missing Bitcode in *.o files.
This commit is contained in:
Davide De Rosa 2021-11-24 15:42:58 +01:00
parent 702ad59cf4
commit 88a5f17eff
1 changed files with 20 additions and 7 deletions

View File

@ -25,7 +25,8 @@ fi
ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator") ALL_SYSTEMS=("iPhoneOS" "iPhoneSimulator" "AppleTVOS" "AppleTVSimulator" "MacOSX" "Catalyst" "WatchOS" "WatchSimulator")
function check_bitcode() { function check_bitcode() {
local FWDIR=$1 local BITCODE_PATH=$1
local IS_VERBOSE=$2
if [[ $FWTYPE == "dynamic" ]]; then if [[ $FWTYPE == "dynamic" ]]; then
BITCODE_PATTERN="__LLVM" BITCODE_PATTERN="__LLVM"
@ -33,10 +34,16 @@ function check_bitcode() {
BITCODE_PATTERN="__bitcode" BITCODE_PATTERN="__bitcode"
fi fi
if otool -l "$FWDIR/$FWNAME" | grep "${BITCODE_PATTERN}" >/dev/null; then if otool -l "$BITCODE_PATH" | grep "${BITCODE_PATTERN}" >/dev/null; then
echo "INFO: $FWDIR contains Bitcode" if $IS_VERBOSE; then
echo "INFO: $BITCODE_PATH contains Bitcode"
fi
BITCODE_ENABLED=1
else else
echo "INFO: $FWDIR doesn't contain Bitcode" if $IS_VERBOSE; then
echo "INFO: $BITCODE_PATH doesn't contain Bitcode"
fi
BITCODE_ENABLED=0
fi fi
} }
@ -168,9 +175,15 @@ if [ $FWTYPE == "dynamic" ]; then
ar -x ../lib/libssl.a ar -x ../lib/libssl.a
cd .. cd ..
BUNDLE_BITCODE=""
check_bitcode "obj/a_bitstr.o" false
if [[ $BITCODE_ENABLED == 1 ]]; then
BUNDLE_BITCODE="-bitcode_bundle"
fi
ld obj/*.o \ ld obj/*.o \
-dylib \ -dylib \
-bitcode_bundle \ $BUNDLE_BITCODE \
-lSystem \ -lSystem \
-arch $ARCH \ -arch $ARCH \
$MIN_SDK \ $MIN_SDK \
@ -202,7 +215,7 @@ if [ $FWTYPE == "dynamic" ]; then
-e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \ -e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \
-i '' "$FWDIR/Info.plist" -i '' "$FWDIR/Info.plist"
echo "Created $FWDIR" echo "Created $FWDIR"
check_bitcode $FWDIR check_bitcode "$FWDIR/$FWNAME" true
else else
echo "Skipped framework for $SYS" echo "Skipped framework for $SYS"
fi fi
@ -232,7 +245,7 @@ else
-e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \ -e "s/\\\$(OPENSSL_VERSION)/$OPENSSL_VERSION/g" \
-i '' "$FWDIR/Info.plist" -i '' "$FWDIR/Info.plist"
echo "Created $FWDIR" echo "Created $FWDIR"
check_bitcode $FWDIR check_bitcode "$FWDIR/$FWNAME" true
else else
echo "Skipped framework for $SYS" echo "Skipped framework for $SYS"
fi fi