forked from omega-gg/MotionBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
319 lines (210 loc) · 6.65 KB
/
build.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/bin/sh
set -e
#--------------------------------------------------------------------------------------------------
# Settings
#--------------------------------------------------------------------------------------------------
MotionBox="../.."
external="$PWD/../3rdparty"
#--------------------------------------------------------------------------------------------------
Qt4_version="4.8.7"
Qt5_version="5.14.2"
#--------------------------------------------------------------------------------------------------
make_arguments="-j 4"
#--------------------------------------------------------------------------------------------------
# Windows
ProgramFiles="/c/Program Files (x86)"
BuildTools="$ProgramFiles/Microsoft Visual Studio/2019/BuildTools"
#--------------------------------------------------------------------------------------------------
MinGW_version="7.3.0"
jom_version="1.1.3"
MSVC_version="14"
WindowsKit_version="10"
#--------------------------------------------------------------------------------------------------
# Android
NDK_version="21"
#--------------------------------------------------------------------------------------------------
# Functions
#--------------------------------------------------------------------------------------------------
getOs()
{
os=`uname`
case $os in
MINGW*) os="windows";;
Darwin*) os="macOS";;
Linux*) os="linux";;
*) os="other";;
esac
type=`uname -m`
if [ $type = "x86_64" ]; then
if [ $os = "windows" ]; then
echo win64
else
echo $os
fi
elif [ $os = "windows" ]; then
echo win32
else
echo $os
fi
}
getPath()
{
echo $(ls "$1" | grep $2 | tail -1)
}
#--------------------------------------------------------------------------------------------------
# Syntax
#--------------------------------------------------------------------------------------------------
if [ $# != 2 -a $# != 3 ] \
|| \
[ $1 != "qt4" -a $1 != "qt5" -a $1 != "clean" ] \
|| \
[ $2 != "win32" -a $2 != "win64" -a $2 != "win32-msvc" -a $2 != "win64-msvc" -a \
$2 != "macOS" -a $2 != "linux" -a $2 != "android" ] \
|| \
[ $# = 3 -a "$3" != "deploy" ]; then
echo "Usage: build <qt4 | qt5 | clean>"
echo " <win32 | win64 | win32-msvc | win64-msvc | macOS | linux | android>"
echo " [deploy]"
exit 1
fi
#--------------------------------------------------------------------------------------------------
# Configuration
#--------------------------------------------------------------------------------------------------
host=$(getOs)
external="$external/$2"
if [ $2 = "win32" -o $2 = "win64" -o $2 = "win32-msvc" -o $2 = "win64-msvc" ]; then
os="windows"
if [ $2 = "win32" -o $2 = "win64" ]; then
compiler="mingw"
MinGW="$external/MinGW/$MinGW_version/bin"
else
compiler="msvc"
jom="$external/jom/$jom_version"
MSVC_version=$(getPath "$BuildTools/VC/Tools/MSVC" $MSVC_version)
MSVC="$BuildTools/VC/Tools/MSVC/$MSVC_version"
WindowsKit="$ProgramFiles/Windows Kits/$WindowsKit_version"
WindowsKit_version=$(getPath "$WindowsKit/bin" $WindowsKit_version)
echo "MSVC version $MSVC_version"
echo ""
echo "WindowsKit version $WindowsKit_version"
echo ""
if [ $2 = "win32-msvc" ]; then
target="x86"
else
target="x64"
fi
fi
elif [ $2 = "android" ]; then
if [ $host != "linux" ]; then
echo "You have to cross-compile $2 from Linux (preferably Ubuntu)."
exit 1
fi
os="default"
compiler="default"
abi="armeabi-v7a arm64-v8a x86 x86_64"
else
os="default"
compiler="default"
fi
if [ $1 = "qt4" ]; then
Qt="$external/Qt/$Qt4_version"
else
Qt="$external/Qt/$Qt5_version"
fi
if [ $os = "windows" -o $2 = "macOS" -o $2 = "android" ]; then
qmake="$Qt/bin/qmake"
else
qmake="qmake"
fi
#--------------------------------------------------------------------------------------------------
# Clean
#--------------------------------------------------------------------------------------------------
if [ $1 = "clean" ]; then
echo "CLEANING"
# NOTE: We have to remove the folder to delete .qmake.stash.
rm -rf build
mkdir build
touch build/.gitignore
exit 0
fi
#--------------------------------------------------------------------------------------------------
# Build MotionBox
#--------------------------------------------------------------------------------------------------
echo "BUILDING MotionBox"
echo "------------------"
if [ $1 = "qt4" ]; then
export QT_SELECT=qt4
config="CONFIG+=release"
else
export QT_SELECT=qt5
config="CONFIG+=release qtquickcompiler"
fi
if [ $compiler = "mingw" ]; then
spec=win32-g++
PATH="$Qt/bin:$MinGW:$PATH"
elif [ $compiler = "msvc" ]; then
if [ $1 = "qt4" ]; then
spec=win32-msvc2015
else
spec=win32-msvc
fi
PATH="$jom:$MSVC/bin/Host$target/$target:\
$WindowsKit/bin/$WindowsKit_version/$target:\
$Qt/bin:$PATH"
export INCLUDE="$MSVC/include:\
$WindowsKit/Include/$WindowsKit_version/ucrt:\
$WindowsKit/Include/$WindowsKit_version/um:\
$WindowsKit/Include/$WindowsKit_version/shared"
export LIB="$MSVC/lib/$target:\
$WindowsKit/Lib/$WindowsKit_version/ucrt/$target:\
$WindowsKit/Lib/$WindowsKit_version/um/$target"
elif [ $2 = "macOS" ]; then
spec=macx-clang
export PATH=$Qt/bin:$PATH
elif [ $2 = "linux" ]; then
if [ -d "/usr/lib/x86_64-linux-gnu" ]; then
spec=linux-g++-64
else
spec=linux-g++-32
fi
elif [ $2 = "android" ]; then
spec=android-clang
export ANDROID_NDK_ROOT="$external/NDK/$NDK_version"
fi
$qmake --version
echo ""
cd content
if [ "$3" = "deploy" ]; then
sh generate.sh $QT_SELECT $2 deploy
else
sh generate.sh $QT_SELECT $2
fi
echo ""
cd ../build
if [ "$3" = "deploy" ]; then
config="$config deploy"
fi
if [ $2 = "android" ]; then
$qmake -r -spec $spec "$config" "ANDROID_ABIS=$abi" ..
else
$qmake -r -spec $spec "$config" ..
fi
if [ $compiler = "mingw" ]; then
mingw32-make $make_arguments
elif [ $compiler = "msvc" ]; then
jom
else
make $make_arguments
fi
cd ..
echo "------------------"
#--------------------------------------------------------------------------------------------------
# Deploying MotionBox
#--------------------------------------------------------------------------------------------------
if [ "$3" = "deploy" ]; then
echo ""
echo "DEPLOYING MotionBox"
echo "-------------------"
sh deploy.sh $1 $2
echo "-------------------"
fi