-
Notifications
You must be signed in to change notification settings - Fork 7
/
build-icu.sh
executable file
·118 lines (105 loc) · 3.11 KB
/
build-icu.sh
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
#!/bin/bash
set -e
MINGW=${MINGW:-${ARCH:-x86_64}-w64-mingw32}
PREFIX=${PREFIX:-usr}
WORKSPACE=${WORKSPACE:-$(pwd)}
TARGET=${TARGET:-${WORKSPACE}}
BUILD_NUMBER=${BUILD_NUMBER:-0}
ARCH=${ARCH:-${MINGW%%-*}}
BINDIR=${BINDIR:-${PREFIX}/exe}
LIBDIR=${LIBDIR:-${PREFIX}/exe}
version=
download=0
zip=0
while test $# -gt 0; do
case "$1" in
(-h|--help)
cat<<EOF
$0 [OPTIONS]
OPTIONS:
-h, --help show this help
-z, --zip create zip package
-v, --version specify version string
-d, --download download sources
otherwise sources must be in $(pwd)
VARIABLES:
MINGW mingw parameter (default: $MINGW)
PREFIX relative installation prefix (default: $PREFIX)
WORKSPACE workspace path (default: $WORKSPACE)
TARGET installation target (default: $TARGET)
BUILD_NUMBER build number (default: $BUILD_NUMBER)
ARCH architecture (default: $ARCH)
BINDIR install dir for exe files (default: $BINDIR)
LIBDIR install dir for dll files (default: $LIBDIR)
Builds ICU for Windows
EOF
exit
;;
(-d|--download) download=1;;
(-v|--version) shift; version="$1";;
(-z|--zip) zip=1;;
(*) echo "ERROR: unknown option: $1" 1>&2; exit 1;;
esac
if ! test $# -gt 0; then
echo "ERROR: missing parameter" 1>&2
exit 1
fi
shift
done
set -x
cd ${WORKSPACE}
if test $download -eq 1; then
if test -z "$version"; then
json=$(wget -qO- https://api.github.com/repos/unicode-org/icu/releases/latest)
tag=$(sed -n 's,.*"tag_name": *"\(.*\)".*,\1,p' <<<"$json")
version=${tag#release-}
else
if [[ "$version" =~ ^[0-9.]+$ ]]; then
tag="release-${version}"
else
tag="$version"
version=${version##*[a-z]-}
if ! [[ "$version" =~ ^[0-9.]+$ ]]; then
version=$(date +'%Y-%m-%d')
fi
fi
fi
source=https://github.com/unicode-org/icu/archive/${tag}.tar.gz
wget -qO- $source | tar xz
cd icu-${tag}
elif test -n "${version}" -a -d icu-${version}; then
cd icu-${version}
elif test -n "${version}" -a -d icu-release-${version}; then
cd icu-release-${version}
elif test -z "${version}" -a -d icu-*; then
version=$(ls -d icu-* | sed 's,icu-,,')
cd icu-${version}
else
version=${version:-$(date +'%Y-%m-%d')}
fi
version=${version//-/.}
path=icu-${version}
[[ "$version" =~ ^[0-9.]+$ ]]
echo "Version: $version"
echo "Package: $path"
test -d build-lin || mkdir build-lin
test -d build-win || mkdir build-win
cd build-lin
../icu4c/source/configure
make
cd ../build-win
../icu4c/source/configure \
--host=${MINGW} \
--with-cross-build=$(pwd)/../build-lin \
--prefix="${TARGET}/${PREFIX}" \
--bindir="${TARGET}/$BINDIR" \
--sbindir="${TARGET}/$BINDIR" \
--libdir="${TARGET}/$LIBDIR" \
--libexecdir="${TARGET}/$LIBDIR"
make
make install
chmod -R u+rw "${TARGET}"
if test $zip -eq 1; then
cd "${TARGET}"
zip -r "${path}~windows.${BUILD_NUMBER}_${ARCH}.zip" "${PREFIX}"
fi