-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.bash
More file actions
168 lines (142 loc) · 3.55 KB
/
build.bash
File metadata and controls
168 lines (142 loc) · 3.55 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
#!/bin/bash
# Client decompfile third party downloader
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <platform> <arch> <output dir>"
exit 1
fi
is_windows=0
if [[ "$CYGWIN" || "$MSYSTEM" ]]; then
is_windows=1
if [[ $MSYSTEM == "MSYS" ]]; then
echo "Do not use an MSYS terminal! Please use a Mingw terminal"
exit 1
fi
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ndk_osname=linux-x86_64
elif [[ "$OSTYPE" == "darwin"* ]]; then
ndk_osname=darwin-x86_64
else
ndk_osname=windows-x86_64
fi
## utilities
# function: download_file
# argument 1: output directory
# argument 2: filename to download
# argument 3: url to download without the filename
# argument 4: sha256 of the file
download_file()
{
outfile=$1/$2
url=$3$2
if [[ -f "$outfile" ]]; then
return 0
fi
echo Downloading $2...
wget -O "$outfile" -o /dev/null $url
if [[ $? -ne "0" ]]; then
return 1
fi
cd $1
echo "$4 $2" | sha256sum --check --status
if [[ $? -ne "0" ]]; then
#rm -rf $outfile
echo "SHA-256 verification failed for $2"
return 1
fi
cd $root_script_dir
return 0
}
# function: run_unzip
# argument 1: output directory
# argument 2: filename to extract
# argument 3: directory where the file is found
# argument 4: extra args
run_unzip()
{
7z x "$3/$2" "-o$1" -y $4 >> /dev/null
if [[ $? -ne "0" ]]; then
echo "Unzip failed for $2"
return 1
fi
return 0
}
# function: run_untar
# argument 1: output directory
# argument 2: filename to extract
# argument 3: directory where the file is found
# argument 4: extra args
run_untar()
{
tar -C "$1" -xf "$3/$2"
if [[ $? -ne "0" ]]; then
echo "Untar failed for $2"
return 1
fi
return 0
}
# function: run_ndkbuild
# argument 1: ndk root path
# argument 2: extra args
run_ndkbuild()
{
if [[ $is_windows -eq "1" ]]; then
new_ndk_path=$(cygpath -w "$1")
cmd //K "$new_ndk_path\\ndk-build.cmd" $2 \&\& exit
if [[ $? -ne "0" ]]; then
return 1
fi
else
"$1/ndk-build" $2
if [[ $? -ne "0" ]]; then
return 1
fi
fi
return 0
}
android_sdk=$ANDROID_SDK
if type "cygpath" > /dev/null; then
android_sdk=$(cygpath -u "$ANDROID_SDK")
fi
android_ndk_bf=$android_sdk/ndk/21.0.6113669
root_script_dir=${PWD}
platform=$1
arch=$2
output_dir=$root_script_dir/$3
libraries=(libcurl openssl libjpeg zlib libxml2 libpng libtiff)
for lib in "${libraries[@]}"
do
src_script=$root_script_dir/$lib/$platform-$arch.bash
rootmk_dir=$root_script_dir/$lib/build/$platform-$arch
tar_dir=$rootmk_dir/tarball
build_dir=$rootmk_dir/build
if ! [[ -f "$build_dir/.installed" ]]; then
if ! [[ -f "$src_script" ]]; then
echo "Cannot find configuration $lib for $platform $arch"
exit 1
fi
mkdir -p $tar_dir
mkdir -p $build_dir
source $src_script
# argument 1: tarball dir
download_dep $tar_dir
if [[ $? -ne "0" ]]; then
exit 1
fi
echo Extracting and building $lib...
# argument 1: tarball dir
# argument 2: build directory
build_dep $tar_dir $build_dir
if [[ $? -ne "0" ]]; then
exit 1
fi
echo Installing $lib...
# argument 1: build directory
# argument 2: output install directory
install_dep $build_dir $output_dir
if [[ $? -ne "0" ]]; then
exit 1
fi
touch $build_dir/.installed
fi
done