-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathdownload_libs.sh
executable file
·509 lines (462 loc) · 17 KB
/
download_libs.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
#!/usr/bin/env bash
set -e
VER=latest
PLATFORM=""
ARCH=""
OVERWRITE=1
LEGACY=0
SILENT_ARGS=""
NO_SSL=""
BLEEDING_EDGE=0
DL_VERSION=2.6.7
TAG=""
printHelp(){
cat << EOF
Usage: download_libs.sh [OPTIONS]
Options:
-v, --version VERSION OF version to download the libraries for. Defaults to master
-p, --platform PLATFORM Platorm among: android, emscritpen, ios, linux, linux64, linuxarmv6l, linuxarmv7l, msys2, osx, tvos, vs
If not specified tries to autodetect the platform.
-a, --arch ARCH Architecture:
vs: 64
msys2: 64
android: armv7, arm64, and x86 (if not specified will download all)
linux: 64gcc6, armv6l or armv7l
-n, --no-overwrite Merge new libraries with existing ones, use only to download same version for different platforms
If not set deletes any existing libraries
-s, --silent Silent download progress
-h, --help Shows this message
-k, --no-ssl Allow no SSL validation
-t, --tag tag release for libraries
EOF
}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ ! -d "$SCRIPT_DIR" ]]; then SCRIPT_DIR="$PWD"; fi
. "$SCRIPT_DIR/downloader.sh"
download(){
echo ' -----'
#echo " Downloading $1"
# downloader ci.openframeworks.cc/libs/$1 $SILENT_ARGS
COMMAND=" "
if [[ $BLEEDING_EDGE = 1 ]] ; then
REPO="latest"
else
REPO="nightly"
fi
#FIXME: remove later, now forcing "latest"
REPO="latest"
if [[ $TAG != "" ]] ; then
REPO="$TAG"
fi
for PKG in $1; do
COMMAND+="https://github.com/openframeworks/apothecary/releases/download/$REPO/$PKG "
done
# echo $COMMAND;
downloader $COMMAND $SILENT_ARGS $NO_SSL
}
# trap any script errors and exit
trap 'trapError ${LINENO}' ERR
trap "trapError" SIGINT SIGTERM
trapError() {
local parent_lineno="$1"
if [[ "$#" = "3" ]] ; then
local message="$2"
local code="${3:-1}"
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
else
local code="${2:-1}"
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
fi
if [ -e openFrameworksLibs* ]; then
echo "removing packages"
rm openFrameworksLibs*
fi
exit "${code}"
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-v|--version)
VER="$2"
shift # past argument
;;
-p|--platform)
PLATFORM="$2"
shift # past argument
;;
-a|--arch)
ARCH="$2"
shift # past argument
;;
-n|--no-overwrite)
OVERWRITE=0
;;
-b|--bleeding-edge)
BLEEDING_EDGE=1
;;
-s|--silent)
SILENT_ARGS=1
;;
-k|--no-ssl)
NO_SSL=1
;;
-m|--msystem)
MSYSTEM="$2"
shift # past argument
;;
-t|--tag)
TAG="$2"
shift # past argument
;;
-l|--legacy)
LEGACY=1
;;
-h|--help)
printHelp
exit 0
;;
*)
echo "Error: invalid argument: $key"
printHelp
# exit 1
;;
esac
shift # past argument or value
done
if [[ "$TARGET" != "" ]] && [[ "$PLATFORM" == "" ]]; then
PLATFORM=$TARGET
fi
if [ "$PLATFORM" == "" ]; then
OS=$(uname)
if [ "$OS" == "Linux" ]; then
PLATFORM="linux"
elif [ "$OS" == "Darwin" ]; then
PLATFORM="osx"
elif [ "${OS:0:5}" == "MINGW" ]; then
PLATFORM="msys2"
else
# otherwise we are on windows and will download 32bit msys2
PLATFORM="msys2"
fi
fi
if [ "$ARCH" == "" ]; then
if [ "$PLATFORM" == "linux" ]; then
ARCH=$(uname -m)
if [ "$ARCH" == "x86_64" ]; then
if command -v gcc &> /dev/null
then
GCC_VERSION=$(gcc -dumpversion | cut -f1 -d.)
else
GCC_VERSION=6
fi
if [ $GCC_VERSION -eq 4 ]; then
ARCH=64gcc6
elif [ $GCC_VERSION -eq 5 ]; then
ARCH=64gcc6
else
ARCH=64gcc6
fi
elif [ "$ARCH" == "armv7l" ]; then
# Check for Raspberry Pi
if [ -f /opt/vc/include/bcm_host.h ]; then
ARCH=armv6l
fi
elif [ "$ARCH" == "i686" ] || [ "$ARCH" == "i386" ]; then
cat << EOF
32bit linux is not officially supported anymore but compiling
the libraries using the build script in apothecary/scripts
should compile all the dependencies without problem
EOF
exit 1
fi
elif [ "$PLATFORM" == "msys2" ]; then
if [ "$MSYSTEM" == "MINGW64" ] || [ "$MSYSTEM" == "mingw64" ]; then
ARCH=mingw64
elif [ "$MSYSTEM" == "CLANGARM64" ] || [ "$MSYSTEM" == "clangarm64" ]; then
ARCH=clangarm64
elif [ "$MSYSTEM" == "UCRT64" ]; then
ARCH=ucrt64
elif [ "$MSYSTEM" == "CLANG64" ]; then
ARCH=clang64
else
ARCH=clang64
fi
fi
if [ "$PLATFORM" == "osx" ]; then
ARCH=x86_64
fi
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
if [[ $BLEEDING_EDGE = 1 ]] ; then
VER=latest
fi
if [[ $TAG != "" ]] && [[ $TAG != "nightly" ]] ; then
VER="$TAG"
fi
if [ "$PLATFORM" == "linux" ] && [ "$ARCH" == "64" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
ARCH=64_gcc6
else
ARCH=64gcc6
fi
fi
echo " openFrameworks download_libs.sh v$DL_VERSION args=$@"
if [ "$PLATFORM" == "emscripten" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
if [[ $ARCH = "" ]] ; then
ARCH="32"
fi
fi
fi
if [ "$PLATFORM" == "msys2" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}.zip"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}.zip"
fi
elif [ "$ARCH" == "" ] && [ "$PLATFORM" == "vs" ]; then
if [[ $BLEEDING_EDGE = 1 ]]; then
if [[ $LEGACY == 1 ]]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_2019_64_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_2019_64_2.zip"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_64_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_64_2.zip \
openFrameworksLibs_${VER}_${PLATFORM}_arm64_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_arm64_2.zip \
openFrameworksLibs_${VER}_${PLATFORM}_arm64ec_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_arm64ec_2.zip"
fi
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_64_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_64_2.zip \
openFrameworksLibs_${VER}_${PLATFORM}_64_3.zip \
openFrameworksLibs_${VER}_${PLATFORM}_64_4.zip"
fi
elif [ "$PLATFORM" == "vs" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
if [[ $LEGACY == 1 ]]; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_2019_64_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_2019_64_2.zip"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_2.zip"
fi
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_1.zip \
openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_2.zip \
openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_3.zip \
openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}_4.zip"
fi
elif [[ "$PLATFORM" =~ ^(osx|ios|tvos|xros|catos|watchos|macos)$ ]]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_1.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}_2.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}_3.tar.bz2"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}1.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}2.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}3.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}4.tar.bz2"
fi
elif [ "$ARCH" == "" ] && [ "$PLATFORM" == "android" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_armv7.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}_arm64.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}_x86_64.tar.bz2"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}armv7.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}arm64.tar.bz2 \
openFrameworksLibs_${VER}_${PLATFORM}x86.tar.bz2"
fi
elif [ "$PLATFORM" == "emscripten" ]; then
if [[ $BLEEDING_EDGE = 1 ]] ; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}_${ARCH}.tar.bz2"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2"
fi
else # Linux
if [[ $BLEEDING_EDGE = 1 ]] ; then
PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2"
else
PKGS="openFrameworksLibs_${VER}_${PLATFORM}${ARCH}.tar.bz2"
fi
fi
cd ../../
mkdir -p libs
cd libs
mkdir -p download
cd download
# IFS=' ' read -r -a PKGS_DATA <<< "$PKGS"
# if [ $OVERWRITE -eq 1 ]; then
# for ((i = 0; i < ${#PKGS_DATA[@]}; i++)); do
# FILE_CHECK="${PKGS_DATA[$i]}"
# # Check if the file exists
# if [ -e "${FILE_CHECK}" ]; then
# echo " Removing Prior Download:[${FILE_CHECK}]"
# # Remove the file or directory
# rm -rf "${FILE_CHECK}"
# fi
# done
# fi
download "${PKGS[@]}"
cd ../ # back to libs
libs=("cairo" "curl" "FreeImage" "brotli" "fmod" "freetype" "glew" "glfw" "json" "libpng" "openssl" "pixman" "poco" "rtAudio" "tess2" "uriparser" "utf8" "videoInput" "zlib" "opencv" "ippicv" "assimp" "libxml2" "svgtiny" "fmt")
if [ $OVERWRITE -eq 1 ]; then
echo " "
echo " Overwrite - Removing prior libraries for [$PLATFORM]"
for ((i=0;i<${#libs[@]};++i)); do
if [ -e "${libs[i]}/lib/$PLATFORM" ]; then
echo " Removing: [${libs[i]}/lib/$PLATFORM]"
rm -rf "${libs[i]}/lib/$PLATFORM"
fi
if [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
if [ -e "${libs[i]}/bin" ]; then
echo " Removing: [${libs[i]}/bin]"
rm -rf "${libs[i]}/bin"
fi
fi
if [ -e "${libs[i]}/include" ]; then
echo " Removing: [${libs[i]}/include]"
rm -rf "${libs[i]}/include"
fi
done
fi
if [ "$PLATFORM" == "osx" ]; then
echo " "
echo " Overwrite - Removing prior libraries for [$PLATFORM]"
for ((i=0;i<${#libs[@]};++i)); do
xcframework_path="${libs[i]}/lib/macos/${libs[i]}.xcframework/macos-arm64_x86_64"
if [ $OVERWRITE -eq 1 ]; then
if [ -e "$xcframework_path" ]; then
echo " Removing: [$xcframework_path]"
rm -rf "$xcframework_path"
fi
fi
info_plist_path="${libs[i]}/lib/macos/${libs[i]}.xcframework/Info.plist"
if [ -e "$info_plist_path" ]; then
#echo " Backing up: [${info_plist_path}] to [${info_plist_path}.bak]"
cp "$info_plist_path" "${info_plist_path}.bak"
fi
done
fi
echo " ------ "
for PKG in $PKGS; do
echo " Uncompressing libraries [${PLATFORM}] from [$PKG]"
if [ "$PLATFORM" == "msys2" ] || [ "$PLATFORM" == "vs" ]; then
unzip -qo download/$PKG
# rm -r download/$PKG
else
# FIXME: this if can be removed after this is fixed properly on apothecary, see:
# https://github.com/openframeworks/openFrameworks/issues/8206
if [ "$PLATFORM" == "linux" ] && { [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "armv7l" ] || [ "$ARCH" == "armv6l" ]; }; then
echo "tar xjfv download/$PKG --strip-components=1"
tar xf download/$PKG --strip-components=1 > /dev/null 2>&1
else
tar xf download/$PKG > /dev/null 2>&1
fi
# rm -r download/$PKG
fi
echo " Deployed libraries from [download/$PKG] to [/libs]"
done
if [ "$PLATFORM" == "osx" ]; then
echo " "
for ((i=0;i<${#libs[@]};++i)); do
info_plist_path="${libs[i]}/lib/macos/${libs[i]}.xcframework/Info.plist"
if [ -e "${info_plist_path}.bak" ]; then
#echo " Restoring: [${info_plist_path}.bak] to [${info_plist_path}]"
mv "${info_plist_path}.bak" "$info_plist_path" 2>/dev/null
fi
done
fi
if [[ $BLEEDING_EDGE = 1 ]] ; then
if [ "$PLATFORM" == "osx" ]; then
addonslibs=("opencv" "ippicv" "libusb" "assimp" "libxml2" "svgtiny" "poco")
addons=("ofxOpenCv" "ofxOpenCv" "ofxKinect" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco" )
elif [ "$PLATFORM" == "vs" ]; then
addonslibs=("opencv" "ippicv" "libusb" "assimp" "libxml2" "svgtiny" "poco")
addons=("ofxOpenCv" "ofxOpenCv" "ofxKinect" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
elif [ "$PLATFORM" == "ios" ] || [ "$PLATFORM" == "tvos" ]; then
addonslibs=("opencv" "ippicv" "assimp" "libxml2" "svgtiny" "poco" )
addons=("ofxOpenCv" "ofxOpenCv" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
else
addonslibs=("opencv" "ippicv" "assimp" "libxml2" "svgtiny" "poco")
addons=("ofxOpenCv" "ofxOpenCv" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
fi
else
if [ "$PLATFORM" == "osx" ]; then
addonslibs=("opencv" "ippicv" "libusb" "assimp" "libxml2" "svgtiny" "poco" "openssl")
addons=("ofxOpenCv" "ofxOpenCv" "ofxKinect" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco" "ofxPoco")
elif [ "$PLATFORM" == "vs" ]; then
addonslibs=("opencv" "ippicv" "libusb" "assimp" "libxml2" "svgtiny" "poco")
addons=("ofxOpenCv" "ofxOpenCv" "ofxKinect" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
elif [ "$PLATFORM" == "ios" ] || [ "$PLATFORM" == "tvos" ]; then
addonslibs=("opencv" "ippicv" "assimp" "libxml2" "svgtiny" "poco" )
addons=("ofxOpenCv" "ofxOpenCv" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
else
addonslibs=("opencv" "ippicv" "assimp" "libxml2" "svgtiny" "poco")
addons=("ofxOpenCv" "ofxOpenCv" "ofxAssimpModelLoader" "ofxSvg" "ofxSvg" "ofxPoco")
fi
fi
echo " ------ "
if [ "$PLATFORM" == "osx" ]; then
if [ $OVERWRITE -eq 1 ]; then
echo " Overwrite - addon xCFramework: [${addons[i]} - ${addonslibs[i]}]"
xcframework_path="../addons/${addons[i]}/libs/${addonslibs[i]}/lib/macos/${addonslibs[i]}.xcframework/macos-arm64_x86_64"
if [ -e "$xcframework_path" ]; then
echo " Removing: [$xcframework_path]"
rm -rf "$xcframework_path"
fi
fi
info_plist_path="../addons/${addons[i]}/libs/${addonslibs[i]}/lib/macos/${addonslibs[i]}.xcframework/Info.plist"
if [ -e "$info_plist_path" ]; then
cp "$info_plist_path" "${info_plist_path}.bak"
fi
fi
if [ $OVERWRITE -eq 1 ]; then
for ((i=0;i<${#addonslibs[@]};++i)); do
if [ -e ${addonslibs[i]} ] ; then
echo " Overwrite - addon: [${addons[i]} - ${addonslibs[i]}]"
if [ -e ../addons/${addons[i]}/libs/${addonslibs[i]}/lib/$PLATFORM ]; then
echo " Remove binaries: [${addons[i]}/libs/${addonslibs[i]}/lib/$PLATFORM]"
rm -rf ../addons/${addons[i]}/libs/${addonslibs[i]}/lib/$PLATFORM
fi
if [ -e ../addons/${addons[i]}/libs/${addonslibs[i]}/bin ]; then
echo " Remove binaries: [${addons[i]}/libs/${addonslibs[i]}/bin]"
rm -rf ../addons/${addons[i]}/libs/${addonslibs[i]}/bin
fi
if [ -e ../addons/${addons[i]}/libs/${addonslibs[i]}/include ]; then
echo " Remove include: [${addons[i]}/libs/include]"
rm -rf ../addons/${addons[i]}/libs/${addonslibs[i]}/include
fi
fi
done
echo " ------ "
fi
for ((i=0;i<${#addonslibs[@]};++i)); do
if [ -e "${addonslibs[i]}" ]; then
echo " Deploying [${addonslibs[i]}] to [../addons/${addons[i]}/libs]"
mkdir -p ../addons/${addons[i]}/libs/${addonslibs[i]}
if ! command -v rsync &> /dev/null
then
cp -a ${addonslibs[i]}/* ../addons/${addons[i]}/libs/${addonslibs[i]}
else
rsync -azp ${addonslibs[i]}/ ../addons/${addons[i]}/libs/${addonslibs[i]}/
fi
rm -rf ${addonslibs[i]}
fi
done
if [ "$PLATFORM" == "osx" ]; then
echo " "
for ((i=0;i<${#addonslibs[@]};++i)); do
if [ -e ${addonslibs[i]} ] ; then
info_plist_path="../addons/${addons[i]}/libs/${addonslibs[i]}/lib/macos/${addonslibs[i]}.xcframework/Info.plist"
if [ -e "${info_plist_path}.bak" ]; then
mv "${info_plist_path}.bak" "$info_plist_path" 2>/dev/null
fi
fi
done
fi
echo " ------ "
echo " openFrameworks download_libs and install complete!"