Skip to content

Commit 2423869

Browse files
author
minggo
committed
Merge pull request #12 from andyque/testScripts
Make all the supported 3rd party libraries working on iOS platform
2 parents fd4aba1 + 0316475 commit 2423869

File tree

10 files changed

+66
-49
lines changed

10 files changed

+66
-49
lines changed

build/ios/build.sh

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function contains() {
8888
}
8989

9090
all_arches=("armv7" "arm64" "i386" "x86_64" "armv7s")
91-
all_libraries=("png" "zlib" "lua" "luajit" "websockets" "curl" "box2d" "chipmunk" "freetype2" "jpeg" "protobuf" "tiff" "webp")
91+
all_libraries=("png" "zlib" "lua" "luajit" "websockets" "curl" "freetype2" "jpeg" "tiff" "webp")
9292

9393
# TODO: we only build a fat library with armv7, arm64, i386 and x86_64 arch. If you want to build armv7s into the fat lib, please add it into the following array.
9494
if [ $build_arches = "all" ]; then
@@ -99,7 +99,7 @@ fi
9999

100100
if [ $build_library = "all" ]; then
101101
# TODO: more libraries need to be added here
102-
declare -a build_library=("png" "zlib" "lua" "luajit" "websockets" "curl" "box2d" "chipmunk" "freetype2" "jpeg" "protobuf" "tiff" "webp")
102+
declare -a build_library=("png" "zlib" "lua" "luajit" "websockets" "curl" "freetype2" "jpeg" "tiff" "webp")
103103
else
104104
build_library=(${build_library//,/ })
105105
fi
@@ -163,8 +163,8 @@ function create_fat_library()
163163

164164
rm $all_static_libs
165165

166-
# remove debugging info
167-
$STRIP -S $library_name/prebuilt/lib$library_name.a
166+
# remove debugging info don't strip
167+
# $STRIP -S $library_name/prebuilt/lib$library_name.a
168168
$LIPO -info $library_name/prebuilt/lib$library_name.a
169169
}
170170

@@ -186,6 +186,10 @@ do
186186
archive_name=z
187187
fi
188188

189+
if [ $lib = "freetype2" ]; then
190+
archive_name=freetype
191+
fi
192+
189193
mkdir -p $archive_name/prebuilt/
190194
mkdir -p $archive_name/include/
191195

@@ -200,6 +204,7 @@ do
200204
continue
201205
fi
202206

207+
203208
is_simulator=""
204209
install_library_path="install-ios-OS"
205210
build_library_path="iPhoneOS"
@@ -229,28 +234,57 @@ do
229234
cp $top_dir/contrib/$install_library_path/$arch/lib/libz.a z/prebuilt/libz-$arch.a
230235
fi
231236

232-
if [ $lib = "png" ]; then
237+
if [ $lib = "png" ] || [ $lib = "freetype2" ] || [ $lib = "websockets" ]; then
233238
echo "copying libz..."
234239
mkdir -p z/prebuilt/
235240
cp $top_dir/contrib/$install_library_path/$arch/lib/libz.a z/prebuilt/libz-$arch.a
236241
fi
237242

238243
echo "Copying needed heder files"
239244
if [ $lib = "png" ]; then
240-
cp $top_dir/contrib/$install_library_path/$arch/include/png*.h $library_name/include/
245+
cp $top_dir/contrib/$install_library_path/$arch/include/png*.h $archive_name/include/
241246
fi
242247

243248
if [ $lib = "luajit" ]; then
244-
cp -r $top_dir/contrib/$install_library_path/$arch/include/luajit-2.0/ $library_name/include/
249+
cp -r $top_dir/contrib/$install_library_path/$arch/include/luajit-2.0/ $archive_name/include/
250+
fi
251+
252+
if [ $lib = "lua" ]; then
253+
cp -r $top_dir/contrib/$install_library_path/$arch/include/l*.h* $archive_name/include/
245254
fi
246255

247256
if [ $lib = "curl" ]; then
248-
cp -r $top_dir/contrib/$install_library_path/$arch/include/curl/ $library_name/include/
257+
cp -r $top_dir/contrib/$install_library_path/$arch/include/curl/ $archive_name/include/
258+
fi
259+
260+
if [ $lib = "freetype2" ]; then
261+
cp -r $top_dir/contrib/$install_library_path/$arch/include/freetype2 $archive_name/include
262+
fi
263+
264+
if [ $lib = "jpeg" ]; then
265+
cp -r $top_dir/contrib/$install_library_path/$arch/include/j*.h $archive_name/include/
266+
fi
267+
268+
if [ $lib = "tiff" ]; then
269+
cp -r $top_dir/contrib/$install_library_path/$arch/include/tif*.h $archive_name/include/
270+
fi
271+
272+
if [ $lib = "webp" ]; then
273+
cp -r $top_dir/contrib/$install_library_path/$arch/include/webp/ $archive_name/include/
274+
fi
275+
276+
if [ $lib = "websockets" ]; then
277+
cp -r $top_dir/contrib/$install_library_path/$arch/include/libwebsockets.h $archive_name/include/
278+
fi
279+
280+
if [ $lib = "zlib" ]; then
281+
cp -r $top_dir/contrib/$install_library_path/$arch/include/z*.h $archive_name/include/
249282
fi
250283

251284
# TODO: add more header files decides here
252285

253286
echo "cleaning up"
287+
# FIXME: uncomment it for debug purpose
254288
rm -rf $top_dir/contrib/$install_library_path
255289
rm -rf $top_dir/contrib/$build_library_path-$arch
256290
done
@@ -260,10 +294,9 @@ do
260294
if [ $lib = "curl" ]; then
261295
create_fat_library ssl
262296
create_fat_library crypto
263-
create_fat_library z
264297
fi
265298

266-
if [ $lib = "png" ]; then
299+
if [ $lib = "png" ] || [ $lib = "curl" ] || [ $lib = "freetype2" ] || [ $lib = "websockets" ]; then
267300
create_fat_library z
268301
fi
269302

contrib/build_ios.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,6 @@ fi
174174
export LDFLAGS="-L${SDKROOT}/usr/lib -arch ${ARCH} -isysroot ${SDKROOT} -miphoneos-version-min=${SDK_MIN}"
175175

176176
EXTRA_CFLAGS=""
177-
# if [ "$PLATFORM" = "OS" ]; then
178-
# EXTRA_CFLAGS="-arch ${ARCH}"
179-
# if [ "$ARCH" != "arm64" ]; then
180-
# EXTRA_CFLAGS+=" -mcpu=cortex-a8"
181-
# fi
182-
# EXTRA_LDFLAGS="-arch ${ARCH}"
183-
# else
184-
# EXTRA_CFLAGS="-arch ${ARCH}"
185-
# EXTRA_LDFLAGS="-arch ${ARCH}"
186-
# fi
187-
188-
# EXTRA_CFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
189-
# EXTRA_LDFLAGS+=" -miphoneos-version-min=${SDK_MIN}"
190177

191178
info "LD FLAGS SELECTED = '${LDFLAGS}'"
192179

@@ -219,6 +206,7 @@ echo "EXTRA_CFLAGS = ${EXTRA_CFLAGS}" >> config.mak
219206
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
220207
echo "IOS_ARCH := ${ARCH}" >> config.mak
221208
echo "BUILD_MODE := ${BUILD_MODE}" >> config.mak
209+
echo "OPTIM := ${OPTIM}" >> config.mak
222210

223211
make fetch
224212
make list

contrib/build_ios_without_export.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ fi
175175
echo "EXTRA_CFLAGS = ${EXTRA_CFLAGS}" >> config.mak
176176
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
177177
echo "IOS_ARCH := ${ARCH}" >> config.mak
178+
echo "OPTIM := ${OPTIM}" >> config.mak
179+
echo "BUILD_MODE := ${BUILD_MODE}" >> config.mak
180+
178181
make fetch
179182
make list
180183
make

contrib/src/curl/rules.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DEPS_curl = zlib $(DEPS_zlib)
1818
DEPS_curl = openssl $(DEPS_openssl)
1919

2020
.curl: curl .zlib .openssl
21-
cd $< && $(HOSTVARS) ./configure $(HOSTCONF) \
21+
cd $< && $(HOSTVARS_PIC) ./configure $(HOSTCONF) \
2222
--with-ssl \
2323
--with-zlib \
2424
cd $< && $(MAKE)

contrib/src/lua/lua-ios-support.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ diff -ru lua/Makefile lua-f/Makefile
33
+++ lua-f/Makefile 2012-03-21 13:58:30.000000000 +0100
44
@@ -38,7 +38,7 @@
55
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
6-
6+
77
# Convenience platforms targets.
88
-PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
99
+PLATS= aix ansi bsd freebsd generic linux ios macosx mingw posix solaris
10-
10+
1111
# What to install.
1212
TO_BIN= lua luac
1313
diff -ru lua/src/Makefile lua-f/src/Makefile
@@ -16,9 +16,9 @@ diff -ru lua/src/Makefile lua-f/src/Makefile
1616
@@ -98,6 +98,9 @@
1717
linux:
1818
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl"
19-
19+
2020
+ios:
21-
+ $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX
21+
+ $(MAKE) all
2222
+
2323
macosx:
2424
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"

contrib/src/lua/rules.mak

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ lua: lua-$(LUA_VERSION).tar.gz .sum-lua
5151
ifdef HAVE_DARWIN_OS
5252
(cd $(UNPACK_DIR) && \
5353
sed -e 's%gcc%$(CC)%' \
54-
-e 's%LDFLAGS=%LDFLAGS=$(EXTRA_CFLAGS) $(EXTRA_LDFLAGS)%' \
55-
-i.orig src/Makefile)
56-
endif
57-
ifdef HAVE_SOLARIS
58-
(cd $(UNPACK_DIR) && \
59-
sed -e 's%LIBS="-ldl"$$%LIBS="-ldl" MYLDFLAGS="$(EXTRA_LDFLAGS)"%' \
54+
-e 's%LDFLAGS=%LDFLAGS=$(LDFLAGS)%' \
55+
-e 's%CFLAGS= -O2 -Wall $(MYCFLAGS)%CFLAGS=$(MYCFLAGS)%' \
56+
-e 's%MYCFLAGS=%MYCFLAGS=$(CFLAGS)%' \
6057
-i.orig src/Makefile)
6158
endif
59+
6260
ifdef HAVE_WIN32
6361
cd $(UNPACK_DIR) && sed -i.orig -e 's/lua luac/lua.exe luac.exe/' Makefile
6462
endif
@@ -70,7 +68,7 @@ endif
7068
$(MOVE)
7169

7270
.lua: lua
73-
cd $< && $(HOSTVARS_PIC) $(MAKE) $(LUA_TARGET)
71+
cd $< && $(HOSTVARS_PIC) $(MAKE) VERBOS=1 $(LUA_TARGET)
7472
ifdef HAVE_WIN32
7573
cd $</src && $(HOSTVARS) $(MAKE) liblua.a
7674
endif

contrib/src/luajit/rules.mak

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ endif
1717

1818
#FIXME: arm64 is not supported
1919
ifeq ($(IOS_ARCH),armv7)
20-
LUAJIT_TARGET_FLAGS="-arch armv7 -isysroot $(IOS_SDK)"
20+
LUAJIT_TARGET_FLAGS="-arch armv7 -isysroot $(IOS_SDK) $(OPTIM)"
2121
LUAJIT_HOST_CC="gcc -m32 -arch i386"
2222
endif
2323

2424
ifeq ($(IOS_ARCH),armv7s)
25-
LUAJIT_TARGET_FLAGS="-arch armv7s -isysroot $(IOS_SDK)"
25+
LUAJIT_TARGET_FLAGS="-arch armv7s -isysroot $(IOS_SDK) $(OPTIM)"
2626
LUAJIT_HOST_CC="gcc -m32 -arch i386"
2727
endif
2828

@@ -36,7 +36,7 @@ endif
3636

3737
.luajit: luajit
3838
ifdef HAVE_ANDROID
39-
cd $< && $(MAKE) HOST_CC="gcc -m32" CROSS=$(HOST)- TARGET_SYS=Linux TARGET_FLAGS="${ANDROID_ARCH} ${NDKF}" TARGET_LDFLAGS=$(LUAJIT_LDFLAGS)
39+
cd $< && $(MAKE) HOST_CC="gcc -m32 $(OPTIM)" CROSS=$(HOST)- TARGET_SYS=Linux TARGET_FLAGS="${ANDROID_ARCH} ${NDKF}" TARGET_LDFLAGS=$(LUAJIT_LDFLAGS)
4040
endif
4141
ifdef HAVE_MACOSX
4242
cd $< && $(MAKE) HOST_CC="$(CC)" HOST_CFLAGS="$(CFLAGS)"
@@ -49,7 +49,7 @@ ifeq ($(IOS_ARCH),armv7s)
4949
cd $< && make HOST_CC=$(LUAJIT_HOST_CC) TARGET_FLAGS=$(LUAJIT_TARGET_FLAGS) TARGET=arm TARGET_SYS=iOS
5050
endif
5151
ifeq ($(IOS_ARCH),i386)
52-
cd $< && make CC="gcc -m32 -arch i386"
52+
cd $< && make CC="gcc -m32 -arch i386 $(OPTIM)"
5353
endif
5454
endif
5555
cd $< && make install PREFIX=$(PREFIX)

contrib/src/main.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ endif
164164
cppcheck = $(shell $(CC) $(CFLAGS) -E -dM - < /dev/null | grep -E $(1))
165165

166166
EXTRA_CFLAGS += -I$(PREFIX)/include
167-
CPPFLAGS := $(CPPFLAGS) $(EXTRA_CFLAGS)
167+
CPPFLAGS := $(CPPFLAGS) $(CFLAGS)
168168
CFLAGS := $(CFLAGS) $(EXTRA_CFLAGS)
169-
CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS)
169+
CXXFLAGS := $(CXXFLAGS) $(CFLAGS)
170170
EXTRA_LDFLAGS += -L$(PREFIX)/lib
171171
LDFLAGS := $(LDFLAGS) $(EXTRA_LDFLAGS)
172172
# Do not export those! Use HOSTVARS.

contrib/src/openssl/rules.mak

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,10 @@ endif
5050
cd $< && $(HOSTVARS) ./Configure $(OPENSSL_CONFIG_VARS) --prefix=$(PREFIX) $(OPENSSL_COMPILER)
5151
ifdef HAVE_IOS
5252
cd $< && perl -i -pe "s|^CC= xcrun clang|CC= xcrun cc -arch ${IOS_ARCH} -miphoneos-version-min=6.0 |g" Makefile
53-
ifeq ($(BUILD_MODE),release)
54-
cd $< && perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${IOS_SDK} -O3 -DNDEBUG |g" Makefile
55-
endif
56-
ifeq ($(BUILD_MODE),debug)
57-
cd $< && perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${IOS_SDK} -O0 -g -DNDEBUG |g" Makefile
58-
endif
53+
cd $< && perl -i -pe "s|^CFLAG= (.*)|CFLAG= -isysroot ${IOS_SDK} ${OPTIM} |g" Makefile
5954
endif
6055
ifdef HAVE_ANDROID
61-
cd $< && perl -i -pe "s|^CFLAG= (.*)|CFLAG= ${ANDROID_ARCH} -O3 |g" Makefile
56+
cd $< && perl -i -pe "s|^CFLAG= (.*)|CFLAG= ${ANDROID_ARCH} ${OPTIM} |g" Makefile
6257
endif
6358
cd $< && $(MAKE) install
6459
touch $@

contrib/src/websockets/rules.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ endif
2727
DEPS_websockets = zlib $(DEPS_zlib)
2828

2929
.websockets: websockets .zlib toolchain.cmake
30-
cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) $(EX_ECFLAGS)" $(CMAKE) -DCMAKE_BUILD_TYPE=Release -DLWS_WITH_SSL=0 -DLWS_WITHOUT_TEST_PING=1
30+
cd $< && $(HOSTVARS) CFLAGS="$(CFLAGS) $(EX_ECFLAGS)" $(CMAKE) -DLWS_WITH_SSL=0 -DLWS_WITHOUT_TEST_PING=1
3131
cd $< && $(MAKE) VERBOSE=1 install
3232
touch $@

0 commit comments

Comments
 (0)