Skip to content

Commit a901b80

Browse files
committed
add debug and release mode to luajit and openssl in a more elegant way
1 parent d8f2991 commit a901b80

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

build/ios/build.sh

Lines changed: 19 additions & 12 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

@@ -229,41 +233,44 @@ do
229233
cp $top_dir/contrib/$install_library_path/$arch/lib/libz.a z/prebuilt/libz-$arch.a
230234
fi
231235

232-
if [ $lib = "png" ]; then
236+
if [ $lib = "png" ] || [ $lib = "freetype2" ]; then
233237
echo "copying libz..."
234238
mkdir -p z/prebuilt/
235239
cp $top_dir/contrib/$install_library_path/$arch/lib/libz.a z/prebuilt/libz-$arch.a
236240
fi
237241

238242
echo "Copying needed heder files"
239243
if [ $lib = "png" ]; then
240-
cp $top_dir/contrib/$install_library_path/$arch/include/png*.h $library_name/include/
244+
cp $top_dir/contrib/$install_library_path/$arch/include/png*.h $archive_name/include/
241245
fi
242246

243247
if [ $lib = "luajit" ]; then
244-
cp -r $top_dir/contrib/$install_library_path/$arch/include/luajit-2.0/ $library_name/include/
248+
cp -r $top_dir/contrib/$install_library_path/$arch/include/luajit-2.0/ $archive_name/include/
245249
fi
246250

247251
if [ $lib = "curl" ]; then
248-
cp -r $top_dir/contrib/$install_library_path/$arch/include/curl/ $library_name/include/
252+
cp -r $top_dir/contrib/$install_library_path/$arch/include/curl/ $archive_name/include/
253+
fi
254+
255+
if [ $lib = "freetype2" ]; then
256+
cp -r $top_dir/contrib/$install_library_path/$arch/include/freetype2 $archive_name/include
249257
fi
250258

251259
# TODO: add more header files decides here
252260

253261
echo "cleaning up"
254-
rm -rf $top_dir/contrib/$install_library_path
255-
rm -rf $top_dir/contrib/$build_library_path-$arch
262+
# rm -rf $top_dir/contrib/$install_library_path
263+
# rm -rf $top_dir/contrib/$build_library_path-$arch
256264
done
257265

258266
create_fat_library $archive_name
259267

260268
if [ $lib = "curl" ]; then
261269
create_fat_library ssl
262270
create_fat_library crypto
263-
create_fat_library z
264271
fi
265272

266-
if [ $lib = "png" ]; then
273+
if [ $lib = "png" ] || [ $lib = "curl" ] || [ $lib = "freetype2" ]; then
267274
create_fat_library z
268275
fi
269276

contrib/build_ios.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ echo "EXTRA_CFLAGS = ${EXTRA_CFLAGS}" >> config.mak
219219
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
220220
echo "IOS_ARCH := ${ARCH}" >> config.mak
221221
echo "BUILD_MODE := ${BUILD_MODE}" >> config.mak
222+
echo "OPTIM := ${OPTIM}" >> config.mak
222223

223224
make fetch
224225
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/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/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 $@

0 commit comments

Comments
 (0)