forked from topameng/tolua_runtime
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build_ios.sh
executable file
·95 lines (83 loc) · 2.61 KB
/
build_ios.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
luacdir="lua53"
luajitdir="luajit-2.1"
luapath=""
lualibname=""
linkpath=""
outpath=""
while :
do
echo "Please choose (1)luajit; (2)lua5.3"
read input
case $input in
"1")
luapath=$luajitdir
lualibname="libluajit"
outpath="Plugins"
linkpath="iOS"
break
;;
"2")
luapath=$luacdir
lualibname="liblua"
outpath="Plugins53"
linkpath="iOS53"
break
;;
*)
echo "Please enter 1 or 2!!"
continue
;;
esac
done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LIPO="xcrun -sdk iphoneos lipo"
STRIP="xcrun -sdk iphoneos strip"
SRCDIR=$DIR/$luapath/
DESTDIR=$DIR/$linkpath
IXCODE=`xcode-select -print-path`
ISDK=$IXCODE/Platforms/iPhoneOS.platform/Developer
ISDKD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/
ISDKVER=iPhoneOS.sdk
ISDKP=$IXCODE/usr/bin/
if [ ! -e $ISDKP/ar ]; then
sudo cp $ISDKD/usr/bin/ar $ISDKP
fi
if [ ! -e $ISDKP/ranlib ]; then
sudo cp $ISDKD/usr/bin/ranlib $ISDKP
fi
if [ ! -e $ISDKP/strip ]; then
sudo cp $ISDKD/usr/bin/strip $ISDKP
fi
rm "$DESTDIR"/*.a
case $luapath in
$luacdir)
cd $DESTDIR/lua53/
xcodebuild clean
xcodebuild -configuration=Release
cp -f ./build/Release-iphoneos/$lualibname.a "$DESTDIR"/$lualibname.a
cd ../
;;
$luajitdir)
cd $SRCDIR
make clean
ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER -miphoneos-version-min=8.0 -fembed-bitcode"
make HOST_CC="gcc -m32" TARGET_FLAGS="$ISDKF" TARGET=armv7 TARGET_SYS=iOS BUILDMODE=static
mv "$SRCDIR"/src/$lualibname.a "$DESTDIR"/$lualibname-armv7.a
make clean
ISDKF="-arch armv7s -isysroot $ISDK/SDKs/$ISDKVER -miphoneos-version-min=8.0 -fembed-bitcode"
make HOST_CC="gcc -m32" TARGET_FLAGS="$ISDKF" TARGET=armv7s TARGET_SYS=iOS BUILDMODE=static
mv "$SRCDIR"/src/$lualibname.a "$DESTDIR"/$lualibname-armv7s.a
make clean
ISDKF="-arch arm64 -isysroot $ISDK/SDKs/$ISDKVER -miphoneos-version-min=8.0 -fembed-bitcode"
make HOST_CC="gcc " TARGET_FLAGS="$ISDKF" TARGET=arm64 TARGET_SYS=iOS BUILDMODE=static
mv "$SRCDIR"/src/$lualibname.a "$DESTDIR"/$lualibname-arm64.a
make clean
cd ../$linkpath
$LIPO -create "$DESTDIR"/$lualibname-*.a -output "$DESTDIR"/$lualibname.a
$STRIP -S "$DESTDIR"/$lualibname.a
;;
esac
xcodebuild clean
xcodebuild -configuration=Release
cp -f ./build/Release-iphoneos/libtolua.a ../$outpath/iOS/