Skip to content

Commit 7c6b8c2

Browse files
committed
add more options to build_png
1 parent 71c69ec commit 7c6b8c2

File tree

3 files changed

+88
-6
lines changed

3 files changed

+88
-6
lines changed

build/ios/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ fi
207207
--host=${TARGET} \
208208
--prefix=${PREFIX} > ${out}
209209

210-
echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
211-
echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
210+
echo "EXTRA_CFLAGS = ${EXTRA_CFLAGS}" >> config.mak
211+
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
212212
echo "IOS_ARCH := ${ARCH}" >> config.mak
213213
make fetch
214214
make list

build/ios/build_png.sh

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,87 @@
1+
#!/bin/sh
2+
3+
#
4+
# A script to build png static library for iOS
5+
#
6+
7+
build_arches="all"
8+
build_mode="release"
9+
10+
function usage()
11+
{
12+
echo "You should follow the instructions here to build static library for iOS"
13+
echo "If you want to build a fat, you should pass 'all' to --arch param"
14+
echo ""
15+
echo "./build_png.sh"
16+
echo "\t-h --help"
17+
echo "\t--arch=[all | armv7,arm64,i386,x86_64]"
18+
echo "\t--mode=[release | debug]"
19+
echo ""
20+
}
21+
22+
23+
while [ "$1" != "" ]; do
24+
PARAM=`echo $1 | awk -F= '{print $1}'`
25+
VALUE=`echo $1 | awk -F= '{print $2}'`
26+
case $PARAM in
27+
-h | --help)
28+
usage
29+
exit
30+
;;
31+
--arch)
32+
build_arches=$VALUE
33+
;;
34+
--mode)
35+
build_mode=$VALUE
36+
;;
37+
*)
38+
echo "ERROR: unknown parameter \"$PARAM\""
39+
usage
40+
exit 1
41+
;;
42+
esac
43+
shift
44+
done
45+
46+
# 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.
47+
if [ $build_arches = "all" ]; then
48+
declare -a build_arches=( "armv7" "arm64" "i386" "x86_64" )
49+
else
50+
build_arches=(${build_arches//,/ })
51+
fi
52+
53+
#check invalid arch type
54+
function check_invalid_arch_type()
55+
{
56+
for arch in "${build_arches[@]}"
57+
do
58+
if [ $arch != "armv7" ] && [ $arch != "arm64" ] && [ $arch != "armv7s" ] && [ $arch != "i386" ] && [ $arch != "x86_64" ]; then
59+
echo "Invalid arch! Only armv7, armv7s, arm64, i386 and x86_64 is acceptable."
60+
exit 1
61+
fi
62+
done
63+
}
64+
65+
check_invalid_arch_type
66+
67+
#check invalid build mode, only debug and release is acceptable
68+
if [ $build_mode != "release" ] && [ $build_mode != "debug" ]; then
69+
echo "invalid build mode, only: debug and release is acceptabl"
70+
usage
71+
exit
72+
fi
73+
74+
75+
for arch in "${build_arches[@]}"
76+
do
77+
echo $arch
78+
done
79+
80+
echo "build mode is $build_mode"
81+
82+
exit
83+
84+
185
current_dir=`pwd`
286
library_name=png
387
rm -rf $library_name
@@ -82,5 +166,3 @@ rm $library_name/prebuilt/lib$library_name-x86_64.a
82166
#remove debugging info
83167
$STRIP -S $library_name/prebuilt/lib$library_name.a
84168
$LIPO -info $library_name/prebuilt/lib$library_name.a
85-
86-

build/ios/build_without_export.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ fi
162162
--host=${TARGET} \
163163
--prefix=${PREFIX} > ${out}
164164

165-
echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
166-
echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
165+
echo "EXTRA_CFLAGS = ${EXTRA_CFLAGS}" >> config.mak
166+
echo "EXTRA_LDFLAGS = ${EXTRA_LDFLAGS}" >> config.mak
167167
echo "IOS_ARCH := ${ARCH}" >> config.mak
168168
make fetch
169169
make list

0 commit comments

Comments
 (0)