Skip to content

Commit eae0465

Browse files
Initial support for packaging iOS engines
1 parent 300186a commit eae0465

File tree

4 files changed

+92
-42
lines changed

4 files changed

+92
-42
lines changed

config/ios.gypi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
'mobile': 1,
55
'target_sdk%': 'iphoneos8.3',
66
'host_sdk%': 'macosx',
7+
8+
'output_dir': '../ios-bin/<(target_sdk)',
79
},
810

911
'xcode_config_file': '../version',
@@ -40,6 +42,12 @@
4042
'variables':
4143
{
4244
'ios_external_symbol_list': '',
45+
46+
'app_bundle_suffix': '.ios-engine',
47+
'ext_bundle_suffix': '.ios-extension',
48+
'exe_suffix': '',
49+
'lib_suffix': '.dylib',
50+
'ext_suffix': '.so',
4351
},
4452

4553
'defines':

engine/bind-ios-standalone.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
#!/bin/bash
22

3+
set -e
4+
echo $1
5+
6+
case "${SDKROOT}" in
7+
iphonesimulator*)
8+
case "$1" in
9+
*-community.lcext)
10+
ln -sf standalone-mobile-community.app/standalone-mobile-community "$BUILT_PRODUCTS_DIR/standalone-mobile-community.ios-engine"
11+
;;
12+
*-commercial.lcext)
13+
ln -sf standalone-mobile-commercial.app/standalone-mobile-commercial "$BUILT_PRODUCTS_DIR/standalone-mobile-commercial.ios-engine"
14+
;;
15+
*)
16+
echo "Unexpected filename $1" >&2
17+
exit 1
18+
;;
19+
esac
20+
exit
21+
;;
22+
esac
23+
324
if [ -e "${PLATFORM_DEVELOPER_BIN_DIR}/g++" ] ; then
425
BIN_DIR="${PLATFORM_DEVELOPER_BIN_DIR}"
526
else
@@ -14,3 +35,16 @@ fi
1435

1536
"${BIN_DIR}/g++" -nodefaultlibs -Wl,-r ${STRIP_FLAG} -arch ${ARCHS//\ /\ -arch\ } -isysroot "${SDKROOT}" -o $@ -Wl,-sectcreate -Wl,-__MISC -Wl,__deps -Wl,"${SRCROOT}/standalone.ios" -Wl,-exported_symbol -Wl,_main -Wl,-exported_symbol -Wl,_load_module -Wl,-exported_symbol -Wl,_resolve_symbol
1637

38+
case "$1" in
39+
*-community.lcext)
40+
ln -sf "$1" "$BUILT_PRODUCTS_DIR/standalone-mobile-community.ios-engine"
41+
;;
42+
*-commercial.lcext)
43+
ln -sf "$1" "$BUILT_PRODUCTS_DIR/standalone-mobile-commercial.ios-engine"
44+
;;
45+
*)
46+
echo "Unexpected filename $1" >&2
47+
exit 1
48+
;;
49+
esac
50+

engine/engine.gyp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,13 @@
266266
{
267267
'dist_files': [ '<(PRODUCT_DIR)/<(_product_name)>(lib_suffix)' ],
268268
},
269+
],
270+
[
271+
'OS != "android"',
269272
{
270273
'dist_files': [ '<(PRODUCT_DIR)/<(_product_name)>(app_bundle_suffix)' ],
271-
},
272-
]
274+
}
275+
],
273276
],
274277
},
275278
},

tools/build-extension-ios.sh

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,58 +71,63 @@ if [ -z "$FAT_INFO" -o $BUILD_DYLIB -eq 1 ]; then
7171

7272
if [ $? -ne 0 ]; then
7373
exit $?
74-
else
75-
# Success
76-
exit 0
7774
fi
78-
fi
75+
else
7976

80-
# Only executed if the binaries have a FAT header, and we need an architecture-specific
81-
# linking
82-
LCEXT_FILE_LIST=""
83-
DYLIB_FILE_LIST=""
77+
# Only executed if the binaries have a FAT header, and we need an architecture-specific
78+
# linking
79+
LCEXT_FILE_LIST=""
80+
DYLIB_FILE_LIST=""
81+
82+
# Link architecture-specifically the libraries
83+
for ARCH in $(echo $ARCHS | tr " " "\n")
84+
do
85+
LCEXT_FILE="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.lcext_${ARCH}"
86+
DYLIB_FILE="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib_${ARCH}"
87+
88+
# arm64 is only from iOS 7.0.0
89+
if [ ${ARCH} = "arm64" -o ${ARCH} = "x86_64" ]; then
90+
MIN_VERSION="7.0.0"
91+
else
92+
MIN_VERSION="5.1.1"
93+
fi
94+
95+
if [ $BUILD_DYLIB -eq 1 ]; then
96+
OUTPUT=$($BIN_DIR/g++ -stdlib=libc++ -dynamiclib -arch ${ARCH} -miphoneos-version-min=${MIN_VERSION} -isysroot $SDKROOT -L"$SOLUTION_DIR/prebuilt/lib/ios/$SDK_NAME" -o "${DYLIB_FILE}" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" -dead_strip -Wl,-x $SYMBOLS $DEPS)
97+
if [ $? -ne 0 ]; then
98+
echo "Linking ""${DYLIB_FILE}""failed:"
99+
echo $OUTPUT
100+
exit $?
101+
fi
102+
fi
84103

85-
# Link architecture-specifically the libraries
86-
for ARCH in $(echo $ARCHS | tr " " "\n")
87-
do
88-
LCEXT_FILE="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.lcext_${ARCH}"
89-
DYLIB_FILE="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib_${ARCH}"
104+
OUTPUT=$($BIN_DIR/g++ -stdlib=libc++ -nodefaultlibs $STRIP_OPTIONS -arch ${ARCH} -miphoneos-version-min=${MIN_VERSION} -isysroot $SDKROOT -L"$SOLUTION_DIR/prebuilt/lib/ios/$SDK_NAME" -o "${LCEXT_FILE}" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" -Wl,-sectcreate -Wl,__MISC -Wl,__deps -Wl,"$SRCROOT/$PRODUCT_NAME.ios" -Wl,-exported_symbol -Wl,___libinfoptr_$PRODUCT_NAME $STATIC_DEPS)
90105

91-
# arm64 is only from iOS 7.0.0
92-
if [ ${ARCH} = "arm64" -o ${ARCH} = "x86_64" ]; then
93-
MIN_VERSION="7.0.0"
94-
else
95-
MIN_VERSION="5.1.1"
96-
fi
97-
98-
if [ $BUILD_DYLIB -eq 1 ]; then
99-
OUTPUT=$($BIN_DIR/g++ -stdlib=libc++ -dynamiclib -arch ${ARCH} -miphoneos-version-min=${MIN_VERSION} -isysroot $SDKROOT -L"$SOLUTION_DIR/prebuilt/lib/ios/$SDK_NAME" -o "${DYLIB_FILE}" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" -dead_strip -Wl,-x $SYMBOLS $DEPS)
100106
if [ $? -ne 0 ]; then
101-
echo "Linking ""${DYLIB_FILE}""failed:"
107+
echo "Linking ""${LCEXT_FILE}""failed:"
102108
echo $OUTPUT
103109
exit $?
104110
fi
105-
fi
106111

107-
OUTPUT=$($BIN_DIR/g++ -stdlib=libc++ -nodefaultlibs $STRIP_OPTIONS -arch ${ARCH} -miphoneos-version-min=${MIN_VERSION} -isysroot $SDKROOT -L"$SOLUTION_DIR/prebuilt/lib/ios/$SDK_NAME" -o "${LCEXT_FILE}" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" -Wl,-sectcreate -Wl,__MISC -Wl,__deps -Wl,"$SRCROOT/$PRODUCT_NAME.ios" -Wl,-exported_symbol -Wl,___libinfoptr_$PRODUCT_NAME $STATIC_DEPS)
112+
LCEXT_FILE_LIST+=" ${LCEXT_FILE}"
113+
DYLIB_FILE_LIST+=" ${DYLIB_FILE}"
114+
done
108115

109-
if [ $? -ne 0 ]; then
110-
echo "Linking ""${LCEXT_FILE}""failed:"
111-
echo $OUTPUT
112-
exit $?
113-
fi
116+
# Lipo the generated libs
117+
lipo -create ${LCEXT_FILE_LIST} -output "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.lcext"
114118

115-
LCEXT_FILE_LIST+=" ${LCEXT_FILE}"
116-
DYLIB_FILE_LIST+=" ${DYLIB_FILE}"
117-
done
119+
# Cleanup the lcext_$ARCH files generated
120+
rm ${LCEXT_FILE_LIST}
118121

119-
# Lipo the generated libs
120-
lipo -create ${LCEXT_FILE_LIST} -output "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.lcext"
121-
122-
# Cleanup the lcext_$ARCH files generated
123-
rm ${LCEXT_FILE_LIST}
122+
if [ $BUILD_DYLIB -eq 1 ]; then
123+
lipo -create ${DYLIB_FILE_LIST} -output "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib"
124+
rm ${DYLIB_FILE_LIST}
125+
fi
126+
fi
124127

125128
if [ $BUILD_DYLIB -eq 1 ]; then
126-
lipo -create ${DYLIB_FILE_LIST} -output "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.dylib"
127-
rm ${DYLIB_FILE_LIST}
129+
ln -sf "$PRODUCT_NAME.dylib" "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.ios-extension"
130+
else
131+
ln -sf "$PRODUCT_NAME.lcext" "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.ios-extension"
128132
fi
133+

0 commit comments

Comments
 (0)