|
| 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 | + |
1 | 85 | current_dir=`pwd`
|
2 | 86 | library_name=png
|
3 | 87 | rm -rf $library_name
|
@@ -82,5 +166,3 @@ rm $library_name/prebuilt/lib$library_name-x86_64.a
|
82 | 166 | #remove debugging info
|
83 | 167 | $STRIP -S $library_name/prebuilt/lib$library_name.a
|
84 | 168 | $LIPO -info $library_name/prebuilt/lib$library_name.a
|
85 |
| - |
86 |
| - |
|
0 commit comments