Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a83f6aa

Browse files
committed
[[ Module Lcext ]] Implement lcext linking with auxc output script
1 parent 503345d commit a83f6aa

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

tools/build-module-lcext-ios.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
AUXC_FILE=$1
6+
DEPS_FILE=$2
7+
LCEXT_OUTPUT=$3
8+
MODULE_NAME=$4
9+
IOS_MODULE_OUTPUT=$5
10+
11+
LIBRARIES=""
12+
13+
for LIB in "${@:6}"; do
14+
LIBRARIES+="$LIB -force_load $LIB "
15+
done
16+
17+
if [ -e $PLATFORM_DEVELOPER_BIN_DIR/g++ ]; then
18+
BIN_DIR=$PLATFORM_DEVELOPER_BIN_DIR
19+
else
20+
BIN_DIR=$DEVELOPER_BIN_DIR
21+
fi
22+
23+
# MW-2011-09-19: Updated to build universal binary version of lcext - by passing
24+
# the process through g++ we get it all for free!
25+
# MW-2013-06-26: [[ CloneAndRun ]] When in 'Debug' mode, don't strip all global symbols.
26+
if [ $CONFIGURATION = "Debug" ]; then
27+
STRIP_OPTIONS="-Wl,-r"
28+
else
29+
STRIP_OPTIONS="-Wl,-r -Wl,-x"
30+
fi
31+
32+
# Only executed if the binaries have a FAT header, and we need an architecture-specific
33+
# linking
34+
LCEXT_FILE_LIST=""
35+
36+
# Link architecture-specifically the libraries
37+
for ARCH in $(echo $ARCHS | tr " " "\n")
38+
do
39+
LCEXT_FILE="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.lcext_${ARCH}"
40+
41+
42+
if [ "$EFFECTIVE_PLATFORM_NAME" = "-iphonesimulator" ]; then
43+
MIN_OS_VERSION="-mios-simulator-version-min="
44+
else
45+
MIN_OS_VERSION="-miphoneos-version-min="
46+
fi
47+
48+
# arm64 is only from iOS 7.0.0
49+
if [ ${ARCH} = "arm64" -o ${ARCH} = "x86_64" ]; then
50+
MIN_OS_VERSION+="7.0.0"
51+
else
52+
MIN_OS_VERSION+="6.0.0"
53+
fi
54+
55+
OUTPUT=$($BIN_DIR/g++ -stdlib=libc++ -nodefaultlibs $STRIP_OPTIONS -arch ${ARCH} $MIN_OS_VERSION -isysroot $SDKROOT -o "${LCEXT_FILE}" "$AUXC_FILE" $LIBRARIES -Wl,-sectcreate -Wl,__MISC -Wl,__deps -Wl,"$DEPS_FILE")
56+
57+
if [ $? -ne 0 ]; then
58+
echo "Linking ""${LCEXT_FILE}""failed:"
59+
echo $OUTPUT
60+
exit $?
61+
fi
62+
63+
LCEXT_FILE_LIST+=" ${LCEXT_FILE}"
64+
done
65+
66+
# Lipo the generated libs
67+
lipo -create ${LCEXT_FILE_LIST} -output "$LCEXT_OUTPUT"
68+
69+
# Cleanup the lcext_$ARCH files generated
70+
rm ${LCEXT_FILE_LIST}
71+
72+
# Create ios module file
73+
echo -n "$MODULE_NAME" > "$IOS_MODULE_OUTPUT"

0 commit comments

Comments
 (0)