-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathiOS-build
executable file
·143 lines (121 loc) · 3.99 KB
/
iOS-build
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# The MIT License (MIT)
#
# Copyright (c) 2013 Pi
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
###########################################################################
# HELPER FUNCTIONS
###########################################################################
iOS_SDK_MIN=6.1
cib_check_build_enviroment()
{
if [ ! \( -e "`whereis make`" \) ] ; then
echo "The 'Command Line Tools' of Xcode could not be found. Install this component in Xcode first."
exit 1
fi
NCPU=`sysctl -n hw.ncpu`
if test x$NJOB = x; then
NJOB=$NCPU
fi
XCODE_PATH=`xcode-select --print-path`
if [ -z "$XCODE_PATH" ]; then
echo "Could not find XCode location (use xcode-select -switch to set the correct path)"
exit 1
fi
iOS_SDK=`xcodebuild -showsdks | grep iphoneos | sed "s|.*iphoneos||"`
}
#cib_download_and_extract tar_url tar_name
cib_download_and_extract()
{
URL=$1
TAR=$2
mkdir -p "${BUILD_TARBALLS_PATH}"
set -e
if [ ! -e ${BUILD_TARBALLS_PATH}/${TAR} ]; then
echo "Downloading '${TAR}'"
if /bin/sh -c "wget -V > /dev/null 2>&1"; then
wget --no-check-certificate ${URL} -O "${BUILD_TARBALLS_PATH}/${TAR}"
else
if /bin/sh -c "curl -V > /dev/null 2>&1"; then
curl -L ${URL} -o "${BUILD_TARBALLS_PATH}/${TAR}"
else
echo "NOT found command 'curl' or 'wget' for download tarball, exit"
exit 1
fi
fi
else
echo "Using ${TAR}"
fi
mkdir -p "${BUILD_SRC_PATH}"
tar xf "${BUILD_TARBALLS_PATH}/${TAR}" -C "${BUILD_SRC_PATH}"
}
#check and load require file FILE_PATH
cib_load_required_file()
{
FILE_PATH=$1
if [ -f $FILE_PATH ]
then
echo "require '$FILE_PATH' successful. "
. $FILE_PATH
else
echo "require '$FILE_PATH' not exist."
return 1;
fi
return 0;
}
#usage_print
cib_usage_print()
{
echo "usage: $0 lua|curl|openssl|uv"
}
# cib_module_lib_create "name1 name2"
cib_module_lib_create()
{
libs=$1
mkdir -p ${CURRENTPATH}/lib
for lib_name in ${libs}; do
lipo -create \
`find ${BUILD_ROOT_PATH} -name lib${lib_name}.a` \
-output ${CURRENTPATH}/lib/lib${lib_name}.a
done
}
# cib_module_inc_copy "name1 name2"
cib_module_inc_copy()
{
includes=$1
mkdir -p ${CURRENTPATH}/include
for inc in ${includes}; do
cp -R ${BUILD_ROOT_PATH}/iPhoneSimulator-i386.sdk/include/${inc} ${CURRENTPATH}/include
done
}
###########################################################################
#Build stage
###########################################################################
cib_check_build_enviroment
CURRENTPATH=`pwd`
BUILD_TARBALLS_PATH=${CURRENTPATH}/build/tarballs
BUILD_SRC_PATH=${CURRENTPATH}/build/src
BUILD_ROOT_PATH=${CURRENTPATH}/build/bin
MODULE=$1
if ! cib_load_required_file ./packages/$MODULE; then
cib_usage_print;
exit 1;
fi
#begin download and build
module_building