-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuildVLCMediaLibraryKit.sh
More file actions
executable file
·931 lines (811 loc) · 29.8 KB
/
buildVLCMediaLibraryKit.sh
File metadata and controls
executable file
·931 lines (811 loc) · 29.8 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
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
#!/bin/sh
ARCH="all"
CLEAN=no
SDK_MIN=9.0
PLATFORM_NAME="iPhone"
PLATFORM_NAME_LOWERCASE="iphone"
VERBOSE=no
ROOT_DIR=default
SIMULATOR=no
NO_NETWORK=no
SKIP_LIBVLC_TOOLS=no
VLCKIT_BASEURL="https://download.videolan.org/cocoapods/prod/"
VLCKIT_NAME="MobileVLCKit"
VLCKIT_RELEASE="3.4.0-8da19f3b-426513d8"
VLCKIT_SHASUM256_IOS="e80bad21b716bba06b6ff3e40a998214f250352b37e8c4fdc79d71cc2293cdee"
VLCKIT_SHASUM256_TVOS="4597b0773eaffe077ece0276d1d2fe49a9fa793ce078d244440ead6ac4a1c072"
BUILD_TYPE="Release"
TESTED_HASH="a2bce106"
CUSTOM_VLCKIT_PATH=~
SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
SKIP_MEDIALIBRARY=no
SKIP_DEPENDENCIES=no
COMPILE_FOR_TVOS=no
BITCODE=no
OSVERSIONMINCFLAG=mios
OSVERSIONMINLDFLAG=ios
BUILTJPEGLIBSSIM=
BUILTJPEGLIBSDEVICE=
BUILTSQLITELIBSSIM=
BUILTSQLITELIBSDEVICE=
BUILTMEDIALIBRARYLIBSSIM=
BUILTMEDIALIBRARYLIBSDEVICE=
PKG_CONFIG_PATH=
CREATE_XCFRAMEWORK=no
if [ -z "$MAKEFLAGS" ]; then
MAKEFLAGS="-j$(sysctl -n machdep.cpu.core_count || nproc)";
fi
set -e
usage()
{
cat << EOF
usage: $0
OPTIONS
-v Be more verbose
-d Enable debug mode
-m Skip medialibrary compilation
-n Skip script steps requiring network interaction
-c Clean all target build
-s Enable medialibrary build for simulators
-x Skip medialibrary dependencies build
-a Build for specific architecture(all|i386|x86_64|armv7|armv7s|aarch64)
-p Path to VLCKit xcframework binary (name of the framework not included in the path)
-l Skip libvlc tools compilation (not recommended)
-t Compile for tvOS
-f Create xcframework
EOF
}
while getopts "hvfdlmncstxa:p:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
v)
VERBOSE=yes
MAKEFLAGS=""
;;
d)
BUILD_TYPE="Debug"
;;
m)
SKIP_MEDIALIBRARY=yes
;;
n)
NO_NETWORK=yes
;;
c)
CLEAN=yes
;;
s)
SIMULATOR=yes
;;
x)
SKIP_DEPENDENCIES=yes
;;
a)
ARCH=$OPTARG
;;
p)
CUSTOM_VLCKIT_PATH=$OPTARG
;;
l)
SKIP_LIBVLC_TOOLS=yes
;;
t)
COMPILE_FOR_TVOS=yes
OSVERSIONMINCFLAG=mtvos
OSVERSIONMINLDFLAG=tvos
SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
SDK_MIN=10.2
BITCODE=yes
VLCKIT_NAME="TVVLCKit"
PLATFORM_NAME="AppleTV"
PLATFORM_NAME_LOWERCASE="appletv"
;;
f)
CREATE_XCFRAMEWORK=yes
;;
?)
usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
ROOT_DIR="$(pwd)"
MEDIALIBRARY_DIR="${ROOT_DIR}/medialibrary"
DEPENDENCIES_DIR="${MEDIALIBRARY_DIR}/dependencies"
VLC_DIR=""
VLCKIT_DIR=""
LIBJPEG_DIR="${DEPENDENCIES_DIR}/libjpeg-turbo"
LIBJPEG_BUILD_DIR=""
LIBJPEG_INCLUDE_DIR=""
SQLITE_RELEASE="sqlite-autoconf-3340100"
SQLITE_SHA1="c20286e11fe5c2e3712ce74890e1692417de6890"
SQLITE_DIR="${DEPENDENCIES_DIR}/${SQLITE_RELEASE}"
SQLITE_INCLUDE_DIR=""
SQLITE_BUILD_DIR=""
VLCKIT_DIR="${DEPENDENCIES_DIR}/${VLCKIT_NAME}"
LIBVLC_TOOLS_DIR="${DEPENDENCIES_DIR}/LibVLCTools"
VLCKIT_PKGCONFIG_DIR="${VLCKIT_DIR}/pkgconfig"
# Helpers
spushd()
{
pushd "$1" 2>&1> /dev/null
}
spopd()
{
popd 2>&1> /dev/null
}
log()
{
local green="\033[1;32m"
local orange="\033[1;91m"
local red="\033[1;31m"
local normal="\033[0m"
local color=$green
local msgType=$1
if [ "$msgType" = "warning" ]; then
color=$orange
msgType="warning"
elif [ "$msgType" = "error" ]; then
color=$red
msgType="error"
fi
echo "[${color}${msgType}${normal}] $2"
}
getActualArch()
{
local architecture=$1
if [ "$architecture" = "aarch64" ]; then
echo "arm64"
else
echo "$architecture"
fi
}
isSimulatorArch() {
local architecture=$1
if [ "$architecture" = "i386" -o "$architecture" = "x86_64" ];then
return 0
else
return 1
fi
}
locateVLCKit()
{
log "info" "Looking for VLCKit..."
local path=$CUSTOM_VLCKIT_PATH
if [ "$CUSTOM_VLCKIT_PATH" == ~ ]; then
log "error" "VLCKit path not provided but requested"
exit 1
fi
VLC_DIR=""
VLCKIT_DIR="${path}"
log "info" "Using custom VLCKit at ${path}"
}
exportPKG()
{
local os=$1
local platform=$2
local architecture=$3
PKG_CONFIG_PATH="${VLCKIT_PKGCONFIG_DIR}/${architecture}-${platform}:"
PKG_CONFIG_PATH+="${LIBJPEG_BUILD_DIR}/pkgconfig:"
PKG_CONFIG_PATH+="${SQLITE_BUILD_DIR}/${os}${platform}/${architecture}"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
log "info" "PKG_CONFIG_PATH set to ${PKG_CONFIG_PATH}"
}
getCPUFamily() {
local cpuname=$1
if [ "$cpuname" = "i386" ]; then
echo "x86"
else
echo "$cpuname"
fi
}
generateCrossFile()
{
local os=$1
local platform=$2
local architecture=$3
local crossfilesDir="${ROOT_DIR}/buildsystem/crossfiles"
local crossfileName="$os-$architecture-$platform.crossfile"
mkdir -p "$crossfilesDir" && spushd "$crossfilesDir"
if [ -f "$crossfileName" ]; then
log "warning" "$crossfileName already exists, skipping generation..."
spopd #crossfilesDir
return
fi
local extraThreadFlags=""
if [ "$architecture" = "i386" ]; then
extraThreadFlags=" + ['-Dthread_local=']"
fi
local minimalVersionFlag=""
if [ "$platform" = "Simulator" ]; then
minimalVersionFlag="-m${PLATFORM_NAME_LOWERCASE}simulator-version-min"
else
minimalVersionFlag="-m${PLATFORM_NAME_LOWERCASE}os-version-min"
fi
touch "$crossfileName"
echo "# This file is autogenerated by $(basename $0)\n" >> "$crossfileName"
echo "[constants]" >> "$crossfileName"
echo "common_flags = ['-arch', '$architecture', '${minimalVersionFlag}=${SDK_MIN}', '-isysroot', '${SDKROOT}']\n" >> "$crossfileName"
echo "[binaries]" >> "$crossfileName"
echo "c = 'clang'" >> "$crossfileName"
echo "cpp = 'clang++'" >> "$crossfileName"
echo "objc = 'clang'" >> "$crossfileName"
echo "objcpp = 'clang++'" >> "$crossfileName"
echo "ar = 'ar'" >> "$crossfileName"
echo "strip = 'strip'" >> "$crossfileName"
echo "pkgconfig = 'pkg-config'\n" >> "$crossfileName"
echo "[built-in options]" >> "$crossfileName"
echo "c_args = common_flags${extraThreadFlags}" >> "$crossfileName"
echo "c_link_args = common_flags" >> "$crossfileName"
echo "cpp_args = common_flags${extraThreadFlags}" >> "$crossfileName"
echo "cpp_link_args = common_flags" >> "$crossfileName"
echo "objc_args = common_flags${extraThreadFlags}" >> "$crossfileName"
echo "objc_link_args = common_flags" >> "$crossfileName"
echo "objcpp_args = common_flags${extraThreadFlags}" >> "$crossfileName"
echo "objcpp_link_args = common_flags\n" >> "$crossfileName"
echo "[host_machine]" >> "$crossfileName"
echo "system = 'darwin'" >> "$crossfileName"
echo "cpu_family = '`getCPUFamily $architecture`'" >> "$crossfileName"
echo "endian = 'little'" >> "$crossfileName"
echo "cpu = '$architecture'" >> "$crossfileName"
spopd #crossfilesDir
}
generateVLCKitPkgConfigFile()
{
local arch=$1
local platform=$2
log "info" "Creating pkgconfig for $arch/$platform..."
mkdir -p "$VLCKIT_PKGCONFIG_DIR" && spushd "$VLCKIT_PKGCONFIG_DIR"
mkdir -p "$arch-$platform" && spushd "$arch-$platform"
if [ "$COMPILE_FOR_TVOS" = "no" ]; then
if [ "$platform" = "Simulator" ]; then
local PCPREFIX="${VLCKIT_DIR}/MobileVLCKit.xcframework/ios-arm64_i386_x86_64-simulator/MobileVLCKit.framework"
else
local PCPREFIX="${VLCKIT_DIR}/MobileVLCKit.xcframework/ios-arm64_armv7_armv7s/MobileVLCKit.framework"
fi
else
if [ "$platform" = "Simulator" ]; then
local PCPREFIX="${VLCKIT_DIR}/TVVLCKit.xcframework/tvos-arm64_x86_64-simulator/TVVLCKit.framework"
else
local PCPREFIX="${VLCKIT_DIR}/TVVLCKit.xcframework/tvos-arm64/TVVLCKit.framework"
fi
fi
rm -f libvlc.pc
touch libvlc.pc
echo "prefix=$PCPREFIX" >> libvlc.pc
echo "exec_prefix=\${prefix}" >> libvlc.pc
echo "libdir=\${exec_prefix}" >> libvlc.pc
echo "includedir=\${prefix}/Headers" >> libvlc.pc
echo "" >> libvlc.pc
echo "Name: ${VLCKIT_NAME} libvlc" >> libvlc.pc
echo "Description: VLC media player external control library through ${VLCKIT_NAME}" >> libvlc.pc
echo "Version: 3.0.18" >> libvlc.pc
echo "Cflags: -I\${includedir}" >> libvlc.pc
echo "Libs: -L\${libdir} -lvlc" >> libvlc.pc
echo "Libs.private: -lvlccore" >> libvlc.pc
spopd # $architecture-$platform
spopd # $VLCKIT_PKGCONFIG_DIR
}
fetchPrebuiltVLCKit()
{
local actualArch=$1
local platform=$2
if [ ! -d "${VLCKIT_DIR}" ]; then
mkdir -p "$VLCKIT_DIR" && spushd "$VLCKIT_DIR"
log "info" "Downloading prebuilt VLCKit from ${VLCKIT_BASEURL}${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz"
curl -O ${VLCKIT_BASEURL}${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz
local vlckitshasum=""
if [ "$COMPILE_FOR_TVOS" = "no" ]; then
vlckitshasum=$VLCKIT_SHASUM256_IOS
else
vlckitshasum=$VLCKIT_SHASUM256_TVOS
fi
if [ ! "`shasum -a 256 ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz`" = "${vlckitshasum} ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz" ]; then
log "error" "Wrong sha256 for ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz"
log "error" "Expected ${vlckitshasum}, received `shasum -a 256 ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz`"
exit 1
fi
tar -xozf ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz
rm -f ${VLCKIT_NAME}-${VLCKIT_RELEASE}.tar.xz
mv ${VLCKIT_NAME}-binary/${VLCKIT_NAME}.xcframework ${VLCKIT_NAME}.xcframework
rm -rf ${VLCKIT_NAME}-binary
spopd # VLCKIT_DIR
fi
if [ "$SKIP_LIBVLC_TOOLS" = "no" ]; then
if [ ! -d "${LIBVLC_TOOLS_DIR}" ]; then
mkdir -p "$LIBVLC_TOOLS_DIR" && spushd "$LIBVLC_TOOLS_DIR"
git init
git remote add -f origin https://code.videolan.org/videolan/vlc.git
git config core.sparseCheckout true
echo "extras/tools/" >> .git/info/sparse-checkout
git pull origin 3.0.x
spushd ${LIBVLC_TOOLS_DIR}/extras/tools
./bootstrap && make
spopd # ${LIBVLC_TOOLS_DIR}/extras/tools
spopd # LIBVLC_TOOLS_DIR
fi
fi
generateVLCKitPkgConfigFile $actualArch $platform
}
# Retrieve medialibrary
fetchMedialibrary()
{
log "info" "Fetching Medialibrary..."
if [ "$NO_NETWORK" = "no" ]; then
if [ -d ${MEDIALIBRARY_DIR} ]; then
spushd ${MEDIALIBRARY_DIR}
git fetch --all
git reset --hard ${TESTED_HASH}
else
git clone https://code.videolan.org/videolan/medialibrary.git --branch 0.11.x --single-branch medialibrary
spushd ${MEDIALIBRARY_DIR}
git checkout -B localBranch ${TESTED_HASH}
fi
git submodule update --init
spushd libvlcpp
git am $ROOT_DIR/Resources/patches/*.patch
spopd #libvlcpp
spopd #medialibrary
fi
}
buildLibJpeg()
{
local arch=$1
local target=$2
local platform=${PLATFORM_NAME}$3
local libjpegRelease="1.5.3"
local prefix="${LIBJPEG_DIR}/install/${platform}/${arch}"
if [ ! -d "${LIBJPEG_DIR}" ]; then
if [ "$NO_NETWORK" = "no" ]; then
log "warning" "libjpeg source not found! Starting download..."
git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git
spushd libjpeg-turbo
git checkout tags/${libjpegRelease}
spopd
fi
fi
log "info" "Starting libjpeg configuration..."
spushd libjpeg-turbo
if [ ! -d "configure" ]; then
autoreconf --install
fi
if [ ! -d "build" ]; then
mkdir build
fi
spushd build
if [ ! -d "$platform" ]; then
mkdir $platform
fi
if [ ! -d "$platform/$arch" ]; then
mkdir $platform/$arch
fi
spushd $platform/$arch
${LIBJPEG_DIR}/configure \
--host=$target \
--prefix=$prefix \
--disable-shared
log "info" "Starting libjpeg make..."
make ${MAKEFLAGS}
if [ ! -d "${prefix}" ]; then
mkdir -p $prefix
fi
make install
LIBJPEG_BUILD_DIR="${prefix}/lib/"
LIBJPEG_INCLUDE_DIR="${prefix}/include/"
log "info" "libjpeg armed and ready for ${arch}!"
spopd
spopd
spopd
}
buildSqlite()
{
local arch=$1
local target=$2
local prefix="${SQLITE_DIR}/build/${PLATFORM_NAME_LOWERCASE}${arch}/install-dir"
if [ ! -d "${SQLITE_DIR}" ]; then
if [ "$NO_NETWORK" = "no" ]; then
log "warning" "sqlite source not found! Starting download..."
curl -O https://download.videolan.org/pub/contrib/sqlite/${SQLITE_RELEASE}.tar.gz
if [ ! "`shasum ${SQLITE_RELEASE}.tar.gz`" = "${SQLITE_SHA1} ${SQLITE_RELEASE}.tar.gz" ]; then
log "error" "Wrong sha1 for ${SQLITE_RELEASE}.tar.gz"
exit 1
fi
tar -xozf ${SQLITE_RELEASE}.tar.gz
rm -f ${SQLITE_RELEASE}.tar.gz
fi
fi
log "info" "Starting sqlite configuration..."
spushd ${SQLITE_RELEASE}
if [ ! -e "configure" ]; then
log "warning" "Found configure file, launching autoreconf..."
autoreconf --install
fi
if [ ! -d "build" ]; then
mkdir build
fi
spushd build
if [ ! -d "${PLATFORM_NAME}$platform" ]; then
mkdir ${PLATFORM_NAME}$platform
fi
if [ ! -d "${PLATFORM_NAME}$platform/$arch" ]; then
mkdir ${PLATFORM_NAME}$platform/$arch
fi
spushd ${PLATFORM_NAME}$platform/$arch
${SQLITE_DIR}/configure \
--host=$target \
--disable-shared \
--disable-readline
log "info" "Starting sqlite make..."
make ${MAKEFLAGS} libsqlite3.la
SQLITE_BUILD_DIR="${SQLITE_DIR}/build/"
SQLITE_INCLUDE_DIR="${SQLITE_DIR}"
log "info" "sqlite armed and ready for ${arch}!"
spopd # $arch
spopd # build
spopd # $SQLITE_RELEASE
}
buildDependencies()
{
local actualArch=$1
local target=$2
local platform=$3
log "info" "Starting build for medialibrary dependencies..."
spushd $DEPENDENCIES_DIR
buildLibJpeg $actualArch $target $platform
buildSqlite $actualArch $target $platform
spopd
}
buildMedialibrary()
{
log "info" "Starting Medialibrary build..."
local os=$1
local arch=$2
local platform=$3
local makeOptions=""
spushd ${MEDIALIBRARY_DIR}
if [ ! -d build ]; then
mkdir build
fi
spushd build
local actualArch="`getActualArch ${arch}`"
local currentDir="`pwd`"
local prefix="${currentDir}/${os}${platform}-install/${actualArch}"
local buildDir="${currentDir}/${os}${platform}-build/${actualArch}"
local target="${arch}-apple-darwin16.5.0" #xcode 8.3 clang version
local medialibraryOptimization="3"
local medialibraryNDebug="true"
log "info" "Building ${arch} with SDK version ${SDK_VERSION} for platform: ${PLATFORM_NAME}${platform}"
if [ ! -d "${DEPENDENCIES_DIR}" ]; then
mkdir -p $DEPENDENCIES_DIR
fi
fetchPrebuiltVLCKit $actualArch $platform
SDKROOT=`xcode-select -print-path`/Platforms/${os}${platform}.platform/Developer/SDKs/${os}${platform}${SDK_VERSION}.sdk
if [ ! -d "${SDKROOT}" ]; then
log "error" "${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually."
exit 1
fi
if [ "$BUILD_TYPE" = "Debug" ]; then
medialibraryOptimization="0"
medialibraryNDebug="false"
fi
CFLAGS="-isysroot ${SDKROOT} -arch ${actualArch}"
LDFLAGS="-isysroot ${SDKROOT} -arch ${actualArch}"
# there is no thread_local in the C++ i386 runtime
if [ "$actualArch" = "i386" ]; then
CFLAGS+=" -D__thread="
fi
if [ "$platform" = "Simulator" ]; then
CFLAGS+=" -${OSVERSIONMINCFLAG}-simulator-version-min=${SDK_MIN}"
LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG}_simulator_version_min,${SDK_MIN}"
else
CFLAGS+=" -${OSVERSIONMINCFLAG}-version-min=${SDK_MIN}"
LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG}_version_min,${SDK_MIN}"
fi
if [ "$BITCODE" = "yes" ]; then
CFLAGS+=" -fembed-bitcode"
fi
EXTRA_CFLAGS="${CFLAGS}"
EXTRA_LDFLAGS="${LDFLAGS}"
export CFLAGS="${CFLAGS}"
export CXXFLAGS="${CFLAGS}"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS=${LDFLAGS}
if [ "$SKIP_LIBVLC_TOOLS" = "no" ]; then
export PATH="${LIBVLC_TOOLS_DIR}/extras/tools/build/bin:${PATH}"
else
export PATH="${PATH}"
fi
log "info" "PATH set to ${PATH}"
if [ "${SKIP_DEPENDENCIES}" != "yes" ]; then
buildDependencies $actualArch $target $platform
else
log "warning" "Build of medialibrary dependencies skipped..."
LIBJPEG_BUILD_DIR="${LIBJPEG_DIR}/build/${arch}-${platform}"
LIBJPEG_INCLUDE_DIR="${LIBJPEG_DIR}/install/${platform}/${arch}/include/"
SQLITE_BUILD_DIR="${SQLITE_DIR}/build/"
SQLITE_INCLUDE_DIR="${SQLITE_DIR}"
fi
if [ "$VERBOSE" = "yes" ]; then
makeOptions="${makeOptions} V=1"
else
makeOptions=${MAKEFLAGS}
fi
exportPKG ${os} ${platform} ${actualArch}
generateCrossFile ${os} ${platform} ${actualArch}
local currentXcode="/Application/Xcode.app/Contents/Developer/Platforms/${os}${platform}.platform/Developer/SDKs/${os}${platform}.sdk/usr"
mkdir -p $buildDir
spopd #build
if [ ! -d "${buildDir}" -o ! -f "${buildDir}/build.ninja" ]; then
meson \
-Ddebug=true \
-Doptimization="${medialibraryOptimization}" \
-Db_ndebug="${medialibraryNDebug}" \
--cross-file "${ROOT_DIR}/buildsystem/crossfiles/$os-$actualArch-$platform.crossfile" \
--prefix "${prefix}" \
-Ddefault_library=static \
-Dtests=disabled \
-Dforce_attachment_api=true \
$buildDir
fi
spushd $buildDir
ninja
ninja install
if [ $? -ne 0 ]; then
log "error" "medialibrary build failed!"
exit 1
fi
log "info" "medialibrary armed and ready for ${arch}!"
spopd #$buildDir
spopd #medialibrary
}
# from buildMobileVLCKit.sh
buildXcodeproj()
{
local xcproject="$1"
local target="$2"
local platform="$3"
log "info" "Starting build $xcproject ($target, ${BUILD_TYPE}, $platform)..."
local architectures=""
if [ "$ARCH" == "all" ]; then
if [ "$COMPILE_FOR_TVOS" = "no" ]; then
if [ "$platform" = "iphonesimulator" ]; then
architectures="i386 x86_64 arm64"
else
architectures="armv7 armv7s arm64"
fi
else
if [ "$platform" = "appletvsimulator" ]; then
architectures="x86_64 arm64"
else
architectures="arm64"
fi
fi
else
architectures="`getActualArch $ARCH`"
fi
local bitcodeflag=""
if [ "$BITCODE" = "yes" ]; then
bitcodeflag="BITCODE_GENERATION_MODE=bitcode ENABLE_BITCODE=yes"
fi
xcodebuild archive \
-project $xcproject.xcodeproj \
-sdk $platform$SDK \
-configuration ${BUILD_TYPE} \
ARCHS="${architectures}" \
IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
${bitcodeflag} \
-scheme "$target" \
-archivePath build/"$target"-$platform$SDK.xcarchive \
SKIP_INSTALL=no \
> ${out}
}
collectBuiltMedialibraryLibs()
{
local medialibraryInstallDir="${MEDIALIBRARY_DIR}/build/${PLATFORM_NAME}OS-install"
local medialibrarySimulatorInstallDir="${MEDIALIBRARY_DIR}/build/${PLATFORM_NAME}Simulator-install"
local medialibraryArch="`ls ${medialibraryInstallDir}`"
local medialibrarySimulatorArch="`ls ${medialibrarySimulatorInstallDir}`"
local devicefiles=""
local simulatorfiles=""
log "info" "Finding libmedialibrary.a binaries..."
if [ "$ARCH" = "all" ]; then
for i in ${medialibraryArch}
do
devicefiles="${medialibraryInstallDir}/${i}/lib/libmedialibrary.a ${devicefiles}"
done
for i in ${medialibrarySimulatorArch}
do
simulatorfiles="${medialibrarySimulatorInstallDir}/${i}/lib/libmedialibrary.a ${simulatorfiles}"
done
else
local actualArch="`getActualArch ${ARCH}`"
devicefiles="${medialibraryInstallDir}/${actualArch}/lib/libmedialibrary.a"
simulatorfiles="${medialibrarySimulatorInstallDir}/${actualArch}/lib/libmedialibrary.a"
fi
BUILTMEDIALIBRARYLIBSDEVICE=$devicefiles
BUILTMEDIALIBRARYLIBSSIM=$simulatorfiles
log "info" "libmedialibrary libs collected!"
}
collectBuiltJPEGLibs()
{
local libjpegInstallDir="${LIBJPEG_DIR}/install"
local files=""
log "info" "Finding libjpeg.a binaries..."
spushd ${libjpegInstallDir}
if [ "$ARCH" = "all" ]; then
for i in `ls ${PLATFORM_NAME_LOWERCASE}OS`
do
files="${libjpegInstallDir}/${PLATFORM_NAME_LOWERCASE}OS/${i}/lib/libjpeg.a ${files}"
done
BUILTJPEGLIBSDEVICE=$files
files=""
for i in `ls ${PLATFORM_NAME_LOWERCASE}Simulator`
do
files="${libjpegInstallDir}/${PLATFORM_NAME_LOWERCASE}Simulator/${i}/lib/libjpeg.a ${files}"
done
BUILTJPEGLIBSSIM=$files
else
local actualArch="`getActualArch ${ARCH}`"
BUILTJPEGLIBSDEVICE="${libjpegInstallDir}/${PLATFORM_NAME_LOWERCASE}OS/${actualArch}/lib/libjpeg.a"
BUILTJPEGLIBSSIM="${libjpegInstallDir}/${PLATFORM_NAME_LOWERCASE}Simulator/${actualArch}/lib/libjpeg.a"
fi
spopd
log "info" "libJPEG libs collected!"
}
collectBuiltSQliteLibs()
{
local sqliteInstallDir="${SQLITE_DIR}/build"
local sqliteArchDevice="`ls ${sqliteInstallDir}/${PLATFORM_NAME}OS`"
local sqliteArchSimulator="`ls ${sqliteInstallDir}/${PLATFORM_NAME}Simulator`"
local deviceFiles=""
local simulatorFiles=""
log "info" "Finding libsqlite3.a binaries..."
if [ "$ARCH" = "all" ]; then
for i in ${sqliteArchDevice}
do
deviceFiles="${sqliteInstallDir}/${PLATFORM_NAME}OS/${i}/.libs/libsqlite3.a ${deviceFiles}"
done
BUILTSQLITELIBSDEVICE=$deviceFiles
for i in ${sqliteArchSimulator}
do
simulatorFiles="${sqliteInstallDir}/${PLATFORM_NAME}Simulator/${i}/.libs/libsqlite3.a ${simulatorFiles}"
done
BUILTSQLITELIBSSIM=$simulatorFiles
else
local actualArch="`getActualArch ${ARCH}`"
BUILTSQLITELIBSDEVICE="${sqliteInstallDir}/${PLATFORM_NAME}OS/${actualArch}/.libs/libsqlite3.a"
BUILTSQLITELIBSSIM="${sqliteInstallDir}/${PLATFORM_NAME}Simulator/${actualArch}/.libs/libsqlite3.a"
fi
log "info" "libsqlite3.a libs collected!"
}
createFramework()
{
local target="$1"
local libPath=""
local platform="iphoneos"
local framework="${target}.xcframework"
local medialibraryLibDir="${MEDIALIBRARY_DIR}/build"
local productPath=""
local frameworks=""
log "info" "Starting the creation of $framework..."
productPath=$ROOT_DIR/build/VLCMediaLibraryKit-${platform}.xcarchive
if [ -d ${productPath} ];then
dsymfolder=${productPath}/dSYMs/VLCMediaLibraryKit.framework.dSYM
bcsymbolmapfolder=${productPath}/BCSymbolMaps
frameworks="$frameworks -framework VLCMediaLibraryKit-${platform}.xcarchive/Products/Library/Frameworks/VLCMediaLibraryKit.framework -debug-symbols $dsymfolder"
if [ -d ${bcsymbolmapfolder} ];then
info "Bitcode support found"
spushd $bcsymbolmapfolder
for i in `ls *.bcsymbolmap`
do
frameworks+=" -debug-symbols $bcsymbolmapfolder/$i"
done
spopd
fi
fi
platform="appletvos"
productPath=$ROOT_DIR/build/VLCMediaLibraryKit-${platform}.xcarchive
if [ -d ${productPath} ];then
dsymfolder=${productPath}/dSYMs/VLCMediaLibraryKit.framework.dSYM
bcsymbolmapfolder=${productPath}/BCSymbolMaps
frameworks="$frameworks -framework VLCMediaLibraryKit-${platform}.xcarchive/Products/Library/Frameworks/VLCMediaLibraryKit.framework -debug-symbols $dsymfolder"
if [ -d ${bcsymbolmapfolder} ];then
info "Bitcode support found"
spushd $bcsymbolmapfolder
for i in `ls *.bcsymbolmap`
do
frameworks+=" -debug-symbols $bcsymbolmapfolder/$i"
done
spopd
fi
fi
platform="iphonesimulator"
productPath=$ROOT_DIR/build/VLCMediaLibraryKit-${platform}.xcarchive
if [ -d ${productPath} ];then
dsymfolder=${productPath}/dSYMs/VLCMediaLibraryKit.framework.dSYM
frameworks="$frameworks -framework VLCMediaLibraryKit-${platform}.xcarchive/Products/Library/Frameworks/VLCMediaLibraryKit.framework -debug-symbols $dsymfolder"
fi
platform="appletvsimulator"
productPath=$ROOT_DIR/build/VLCMediaLibraryKit-${platform}.xcarchive
if [ -d ${productPath} ];then
dsymfolder=${productPath}/dSYMs/VLCMediaLibraryKit.framework.dSYM
frameworks="$frameworks -framework VLCMediaLibraryKit-${platform}.xcarchive/Products/Library/Frameworks/VLCMediaLibraryKit.framework -debug-symbols $dsymfolder"
fi
# Assumes both platforms were built currently
spushd build
rm -rf VLCMediaLibraryKit.xcframework
xcodebuild -create-xcframework $frameworks -output VLCMediaLibraryKit.xcframework
spopd # build
log "info" "$framework created!"
}
out="/dev/null"
if [ "$VERBOSE" = "yes" ]; then
out="/dev/stdout"
fi
##################
# Command Center #
##################
if [ "x$1" != "x" ]; then
usage
exit 1
fi
if [ "$CUSTOM_VLCKIT_PATH" != ~ ]; then
locateVLCKit
fi
if [ "$SKIP_MEDIALIBRARY" != "yes" ]; then
fetchMedialibrary
#Mobile first!
if [ "$ARCH" = "all" ]; then
if [ "$COMPILE_FOR_TVOS" = "yes" ]; then
buildMedialibrary "$PLATFORM_NAME" "x86_64" "Simulator"
buildMedialibrary "$PLATFORM_NAME" "aarch64" "Simulator"
buildMedialibrary "$PLATFORM_NAME" "aarch64" "OS"
else
buildMedialibrary "$PLATFORM_NAME" "i386" "Simulator"
buildMedialibrary "$PLATFORM_NAME" "x86_64" "Simulator"
buildMedialibrary "$PLATFORM_NAME" "aarch64" "Simulator"
buildMedialibrary "$PLATFORM_NAME" "armv7" "OS"
buildMedialibrary "$PLATFORM_NAME" "armv7s" "OS"
buildMedialibrary "$PLATFORM_NAME" "aarch64" "OS"
fi
else
platform="OS"
if isSimulatorArch $ARCH; then
platform="Simulator"
fi
buildMedialibrary "$PLATFORM_NAME" "$ARCH" "$platform"
fi
else
log "warning" "Build of Medialibrary skipped..."
fi
if [ "$CLEAN" = "yes" ]; then
xcodebuild -alltargets clean
log "info" "Xcode build cleaned!"
fi
collectBuiltJPEGLibs
collectBuiltSQliteLibs
collectBuiltMedialibraryLibs
rm -f $ROOT_DIR/Resources/dependencies.xcconfig
touch $ROOT_DIR/Resources/dependencies.xcconfig
echo "// This file is autogenerated by $(basename $0)" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "LIBJPEG_LIBRARIES_SIMULATOR=$BUILTJPEGLIBSSIM" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "SQLITE_LIBRARIES_SIMULATOR=$BUILTSQLITELIBSSIM" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "MEDIALIBRARY_LIBRARIES_SIMULATOR=$BUILTMEDIALIBRARYLIBSSIM" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "LIBJPEG_LIBRARIES_DEVICE=$BUILTJPEGLIBSDEVICE" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "SQLITE_LIBRARIES_DEVICE=$BUILTSQLITELIBSDEVICE" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "MEDIALIBRARY_LIBRARIES_DEVICE=$BUILTMEDIALIBRARYLIBSDEVICE" >> $ROOT_DIR/Resources/dependencies.xcconfig
echo "MOBILEVLCKIT_XCFRAMEWORK=$VLCKIT_DIR" >> $ROOT_DIR/Resources/dependencies.xcconfig
if [ "$ARCH" = "all" ] || isSimulatorArch $ARCH; then
buildXcodeproj VLCMediaLibraryKit "VLCMediaLibraryKit" ${PLATFORM_NAME_LOWERCASE}simulator
fi
if [ "$ARCH" = "all" ] || ! isSimulatorArch $ARCH; then
buildXcodeproj VLCMediaLibraryKit "VLCMediaLibraryKit" ${PLATFORM_NAME_LOWERCASE}os
fi
if [ "$CREATE_XCFRAMEWORK" = "yes" ]; then
createFramework "VLCMediaLibraryKit"
fi