This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathbuild-icu.sh
More file actions
executable file
·231 lines (198 loc) · 7.34 KB
/
Copy pathbuild-icu.sh
File metadata and controls
executable file
·231 lines (198 loc) · 7.34 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
source "${BASEDIR}/scripts/platform.inc"
source "${BASEDIR}/scripts/lib_versions.inc"
# Configuration flags
ICU_CONFIG="--disable-shared --enable-static --prefix=/ --with-data-packaging=static --disable-samples --disable-tests --disable-extras"
ICU_CFLAGS="-DU_USING_ICU_NAMESPACE=0 -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
ICU_VERSION_ALT=$(echo "${ICU_VERSION}" | sed 's/\./_/g')
# Grab the source for the library
ICU_TGZ="icu-${ICU_VERSION}.tar.gz"
ICU_SRC="icu-${ICU_VERSION}"
cd "${BUILDDIR}"
# Needed for cross-compiles
case $(uname) in
Linux*)
HOST_ICU_DIR="${BUILDDIR}/icu-${ICU_VERSION}-linux-x86_64"
;;
Darwin*)
HOST_ICU_DIR="${BUILDDIR}/icu-${ICU_VERSION}-mac-i386"
;;
CYGWIN*)
HOST_ICU_DIR="${BUILDDIR}/icu-${ICU_VERSION}-win32-i386"
;;
esac
if [ ! -d "$ICU_SRC" ] ; then
if [ ! -e "$ICU_TGZ" ] ; then
echo "Fetching ICU source"
curl http://download.icu-project.org/files/icu4c/${ICU_VERSION}/icu4c-${ICU_VERSION_ALT}-src.tgz -o "${ICU_TGZ}"
if [ $? != 0 ] ; then
echo " failed"
if [ -e "${ICU_TGZ}" ] ; then
rm ${ICU_TGZ}
fi
exit
fi
fi
echo "Unpacking ICU source"
tar -xf "${ICU_TGZ}"
mv icu "${ICU_SRC}"
fi
function buildICU {
local SUBPLATFORM_INDEX=$1
for ARCH in ${ARCHS}
do
# Platform-specific options for ICU
case "${PLATFORM}" in
mac)
CONFIG_TYPE="MacOSX"
if [ "${ARCH}" == "ppc" -o "${ARCH}" == "ppc64" ] ; then
echo "WARNING: cross-compiled ICU data for PPC does not work"
CONFIG_TYPE+=" --host=${ARCH}-apple-darwin --with-cross-build=${HOST_ICU_DIR}"
fi
;;
linux)
CONFIG_TYPE="Linux"
if [ "${ARCH}" == "x86_64" ] ; then
CONFIG_TYPE+=" --with-library-bits=64"
elif [ "${ARCH}" == "armv6-hf" ] ; then
CONFIG_TYPE+=" --host=arm-linux-gnueabihf --with-cross-build=${HOST_ICU_DIR}"
else
CONFIG_TYPE+=" --with-library-bits=32"
fi
;;
android)
CONFIG_TYPE="Linux --host=arm-linux-androideabi --with-cross-build=${HOST_ICU_DIR} --disable-tools"
export ANDROID_CFLAGS="-D__STDC_INT64__ -DU_HAVE_NL_LANGINFO_CODESET=0"
export ANDROID_CXXFLAGS="${ANDROID_CFLAGS}"
;;
ios)
CONFIG_TYPE=
CONFIG_FLAGS="--host=arm-apple-darwin --with-cross-build=${HOST_ICU_DIR} --disable-tools"
;;
win32)
CONFIG_TYPE="Cygwin/MSVC"
;;
esac
# Utility for displaying platform name
if [ ! -z "${SUBPLATFORM_INDEX}" ] ; then
local SUBPLATFORM="${IOS_SUBPLATFORM[$SUBPLATFORM_INDEX]}${IOS_VERSION[$SUBPLATFORM_INDEX]}"
local NAME="${PLATFORM}/${SUBPLATFORM}/${ARCH}"
local PLATFORM_NAME=${SUBPLATFORM}
else
local NAME="${PLATFORM}/${ARCH}"
local PLATFORM_NAME=${PLATFORM}
fi
ICU_ARCH_SRC="${ICU_SRC}-${PLATFORM_NAME}-${ARCH}"
ICU_ARCH_LOG="${ICU_ARCH_SRC}.log"
# Copy the source to a target-specific directory
if [ ! -d "${ICU_ARCH_SRC}" ] ; then
echo "Creating ICU build directory for ${NAME}"
mkdir "${ICU_ARCH_SRC}"
fi
# Get the command used to build a previous copy, if any
if [ -e "${ICU_ARCH_SRC}/config.cmd" ] ; then
ICU_ARCH_CURRENT_CONFIG=`cat ${ICU_ARCH_SRC}/config.cmd`
else
ICU_ARCH_CURRENT_CONFIG=
fi
ICU_ARCH_CONFIG="${CONFIG_TYPE} ${ICU_CONFIG} ${CONFIG_FLAGS}"
# Re-configure and re-build, if required
if [ "${ICU_ARCH_CONFIG}" != "${ICU_ARCH_CURRENT_CONFIG}" ] ; then
cd "${ICU_ARCH_SRC}"
echo "Configuring ICU for ${NAME}"
setCCForArch "${ARCH}" "${SUBPLATFORM_INDEX}"
# Method for configuration depends on the platform
if [ -z "${CONFIG_TYPE}" ] ; then
"../${ICU_SRC}/source/configure" ${ICU_CONFIG} ${CONFIG_FLAGS} > "${ICU_ARCH_LOG}" 2>&1
else
"../${ICU_SRC}/source/runConfigureICU" ${CONFIG_TYPE} ${ICU_CONFIG} ${CONFIG_FLAGS} > "${ICU_ARCH_LOG}" 2>&1
fi
# Disable C++11 support on platforms where we can't guarantee a compatible runtime
case "${PLATFORM}" in
android|linux)
sed -i -e "s/\(^CXXFLAGS.*\)--std=c++0x/\1/" icudefs.mk
;;
esac
echo "Building ICU for ${NAME}"
export VERBOSE=1
make clean >> "${ICU_ARCH_LOG}" 2>&1 && make ${MAKEFLAGS} >> "${ICU_ARCH_LOG}" 2>&1 && make DESTDIR="${INSTALL_DIR}/${NAME}" install >> "${ICU_ARCH_LOG}" 2>&1
RESULT=$?
cd ..
# Save the configuration for this build
if [ $RESULT == 0 ] ; then
echo "${ICU_ARCH_CONFIG}" > "${ICU_ARCH_SRC}/config.cmd"
else
echo " failed"
exit
fi
else
echo "Found existing ICU build for ${NAME}"
fi
# Generate the minimal data library
ORIGINAL_DIR=`pwd`
if [ ! -e "${ICU_ARCH_SRC}/custom-data/icudt${ICU_VERSION_MAJOR}l.dat" ] ; then
mkdir -p "${ICU_ARCH_SRC}/custom-data"
cd "${ICU_ARCH_SRC}/custom-data"
curl http://downloads.livecode.com/prebuilts/icudata/minimal/icudt${ICU_VERSION_MAJOR}l.dat -o "icudt${ICU_VERSION_MAJOR}l.dat"
else
cd "${ICU_ARCH_SRC}/custom-data"
fi
if [ ! -d "extracted" ] ; then
mkdir -p "extracted"
"${HOST_ICU_DIR}/bin/icupkg" --list --outlist "icudt${ICU_VERSION_MAJOR}.lst" "icudt${ICU_VERSION_MAJOR}l.dat"
"${HOST_ICU_DIR}/bin/icupkg" --extract "icudt${ICU_VERSION_MAJOR}.lst" --destdir "./extracted" "icudt${ICU_VERSION_MAJOR}l.dat"
fi
if [ ! -d "out-${PLATFORM}-${ARCH}" ] ; then
mkdir -p "temp"
mkdir -p "out-${PLATFORM}-${ARCH}"
"${HOST_ICU_DIR}/bin/pkgdata" --bldopt "../../${ICU_ARCH_SRC}/data/icupkg.inc" --quiet --copyright --sourcedir "./extracted" --destdir "./out-${PLATFORM}-${ARCH}" --entrypoint icudt${ICU_VERSION_MAJOR} --tempdir "./temp" --name "icudt${ICU_VERSION_MAJOR}l" --mode static --revision "${ICU_VERSION}" --libname icudata "icudt${ICU_VERSION_MAJOR}.lst"
# Copy the data
rm -r "${INSTALL_DIR}/${NAME}/lib/libicudata.a"
cp -v "out-${PLATFORM}-${ARCH}/libicudata.a" "${INSTALL_DIR}/${NAME}/lib/libicudata.a"
fi
cd "${ORIGINAL_DIR}"
for L in data i18n io le lx tu uc ; do
if [ -f "${INSTALL_DIR}/${NAME}/lib/libicu${L}.a" ] ; then
if [ "${PLATFORM}" == "mac" -o "${PLATFORM}" == "ios" ] ; then
VAR="ICU${L}_LIBS"
eval "$VAR+=\"${INSTALL_DIR}/${NAME}/lib/libicu${L}.a \""
else
mkdir -p "${OUTPUT_DIR}/lib/${NAME}"
cp "${INSTALL_DIR}/${NAME}/lib/libicu${L}.a" "${OUTPUT_DIR}/lib/${NAME}/libicu${L}.a"
fi
fi
done
done
# Create the universal libraries
if [ "${PLATFORM}" == "mac" -o "${PLATFORM}" == "ios" ] ; then
echo "Creating ICU ${PLATFORM_NAME} universal libraries"
mkdir -p "${OUTPUT_DIR}/lib/${PLATFORM}/${SUBPLATFORM}"
for L in data i18n io le lx tu uc ; do
VAR="ICU${L}_LIBS"
eval VALUE=\$$VAR
if [ ! -z "${VALUE}" ] ; then
lipo -create $VALUE -output "${OUTPUT_DIR}/lib/${PLATFORM}/${SUBPLATFORM}/libicu${L}.a"
fi
eval "$VAR="
done
fi
# Copy over the headers, if it has not yet been done
if [ ! -e "${OUTPUT_DIR}/include/unicode" ] ; then
echo "Copying ICU headers"
mkdir -p "${OUTPUT_DIR}/include"
cp -r "${INSTALL_DIR}/${NAME}/include"/* "${OUTPUT_DIR}/include/"
# Some header massaging is required in order to avoid Win32 link errors
sed -i "" -e 's/define U_IMPORT __declspec(dllimport)/define U_IMPORT/g' "${OUTPUT_DIR}/include/unicode/platform.h"
sed -i "" -e 's/define U_EXPORT __declspec(dllexport)/define U_EXPORT/g' "${OUTPUT_DIR}/include/unicode/platform.h"
fi
}
# If building for iOS, a number of sub-platforms need to be build
if [ "${PLATFORM}" == "ios" ] ; then
for (( INDEX=0; INDEX<$IOS_COUNT; INDEX++ ))
do
setArchs ${INDEX}
buildICU ${INDEX}
done
else
buildICU
fi