compileAndBuildVLCKit.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. #!/bin/sh
  2. # Copyright (C) Pierre d'Herbemont, 2010
  3. # Copyright (C) Felix Paul Kühne, 2012-2019
  4. set -e
  5. BUILD_DEVICE=yes
  6. BUILD_SIMULATOR=yes
  7. BUILD_STATIC_FRAMEWORK=no
  8. BUILD_DYNAMIC_FRAMEWORK=no
  9. SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
  10. SDK_MIN=9.0
  11. VERBOSE=no
  12. DISABLEDEBUG=no
  13. CONFIGURATION="Debug"
  14. NONETWORK=no
  15. SKIPLIBVLCCOMPILATION=no
  16. TVOS=no
  17. MACOS=no
  18. IOS=yes
  19. BITCODE=no
  20. OSVERSIONMINCFLAG=iphoneos
  21. OSVERSIONMINLDFLAG=ios
  22. ROOT_DIR=empty
  23. FARCH="all"
  24. TESTEDHASH="6e223d67a" # libvlc hash that this version of VLCKit is build on
  25. usage()
  26. {
  27. cat << EOF
  28. usage: $0 [-s] [-v] [-k sdk]
  29. OPTIONS
  30. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  31. -v Be more verbose
  32. -s Build for simulator
  33. -f Build framework for device and simulator
  34. -d Disable Debug
  35. -n Skip script steps requiring network interaction
  36. -l Skip libvlc compilation
  37. -t Build for tvOS
  38. -x Build for macOS / Mac OS X
  39. -y Build universal static libraries
  40. -b Enable bitcode
  41. -a Build framework for specific arch (all|i386|x86_64|armv7|armv7s|aarch64)
  42. -e External VLC source path
  43. EOF
  44. }
  45. get_actual_arch() {
  46. if [ "$1" = "aarch64" ]; then
  47. echo "arm64"
  48. else
  49. echo "$1"
  50. fi
  51. }
  52. get_arch() {
  53. if [ "$1" = "arm64" ]; then
  54. echo "aarch64"
  55. else
  56. echo "$1"
  57. fi
  58. }
  59. is_simulator_arch() {
  60. if [ "$1" = "i386" -o "$1" = "x86_64" ];then
  61. return 0
  62. else
  63. return 1
  64. fi
  65. }
  66. spushd()
  67. {
  68. pushd "$1" 2>&1> /dev/null
  69. }
  70. spopd()
  71. {
  72. popd 2>&1> /dev/null
  73. }
  74. info()
  75. {
  76. local green="\033[1;32m"
  77. local normal="\033[0m"
  78. echo "[${green}info${normal}] $1"
  79. }
  80. buildxcodeproj()
  81. {
  82. local target="$2"
  83. local PLATFORM="$3"
  84. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  85. local architectures=""
  86. if [ "$FARCH" = "all" ];then
  87. if [ "$TVOS" = "yes" ]; then
  88. if [ "$PLATFORM" = "appletvsimulator" ]; then
  89. architectures="x86_64"
  90. else
  91. architectures="arm64"
  92. fi
  93. fi
  94. if [ "$IOS" = "yes" ]; then
  95. if [ "$PLATFORM" = "iphonesimulator" ]; then
  96. architectures="i386 x86_64"
  97. else
  98. architectures="armv7 armv7s arm64"
  99. fi
  100. fi
  101. else
  102. architectures=`get_actual_arch $FARCH`
  103. fi
  104. local bitcodeflag=""
  105. if [ "$BITCODE" = "yes" ]; then
  106. bitcodeflag="BITCODE_GENERATION_MODE=bitcode"
  107. fi
  108. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  109. xcodebuild -project "$1.xcodeproj" \
  110. -target "$target" \
  111. -sdk $PLATFORM$SDK \
  112. -configuration ${CONFIGURATION} \
  113. ARCHS="${architectures}" \
  114. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  115. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  116. ${bitcodeflag} \
  117. > ${out}
  118. }
  119. buildLibVLC() {
  120. ARCH="$1"
  121. PLATFORM="$2"
  122. if [ "$DISABLEDEBUG" = "yes" ]; then
  123. DEBUGFLAG="--disable-debug"
  124. else
  125. DEBUGFLAG=""
  126. fi
  127. if [ "$VERBOSE" = "yes" ]; then
  128. VERBOSEFLAG="--verbose"
  129. else
  130. VERBOSEFLAG=""
  131. fi
  132. info "Compiling ${ARCH} with SDK version ${SDK_VERSION}, platform ${PLATFORM}"
  133. ACTUAL_ARCH=`get_actual_arch $ARCH`
  134. BUILDDIR="${VLCROOT}/build-${PLATFORM}-${ACTUAL_ARCH}"
  135. mkdir -p ${BUILDDIR}
  136. spushd ${BUILDDIR}
  137. ../extras/package/apple/build.sh --arch=$ARCH --sdk=${PLATFORM}${SDK_VERSION} ${DEBUGFLAG} ${VERBOSEFLAG}
  138. spopd # builddir
  139. info "Finished compiling libvlc for ${ARCH} with SDK version ${SDK_VERSION}, platform ${PLATFORM}"
  140. }
  141. buildMobileKit() {
  142. PLATFORM="$1"
  143. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  144. if [ "$FARCH" = "all" ];then
  145. if [ "$TVOS" = "yes" ]; then
  146. if [ "$PLATFORM" = "iphonesimulator" ]; then
  147. buildLibVLC "x86_64" "appletvsimulator"
  148. else
  149. buildLibVLC "aarch64" "appletvos"
  150. fi
  151. fi
  152. if [ "$MACOS" = "yes" ]; then
  153. buildLibVLC "x86_64" "macosx"
  154. fi
  155. if [ "$IOS" = "yes" ]; then
  156. if [ "$PLATFORM" = "iphonesimulator" ]; then
  157. buildLibVLC "i386" $PLATFORM
  158. buildLibVLC "x86_64" $PLATFORM
  159. else
  160. buildLibVLC "armv7" $PLATFORM
  161. buildLibVLC "armv7s" $PLATFORM
  162. buildLibVLC "aarch64" $PLATFORM
  163. fi
  164. fi
  165. else
  166. if [ "$FARCH" != "x86_64" -a "$FARCH" != "aarch64" -a "$FARCH" != "i386" \
  167. -a "$FARCH" != "armv7" -a "$FARCH" != "armv7s" ];then
  168. echo "*** Framework ARCH: ${FARCH} is invalid ***"
  169. exit 1
  170. fi
  171. if (is_simulator_arch $FARCH);then
  172. if [ "$TVOS" = "yes" ]; then
  173. PLATFORM="appletvsimulator"
  174. fi
  175. if [ "$IOS" = "yes" ]; then
  176. PLATFORM="iphonesimulator"
  177. fi
  178. if [ "$MACOS" = "yes" ]; then
  179. PLATFORM="macosx"
  180. fi
  181. else
  182. if [ "$TVOS" = "yes" ]; then
  183. PLATFORM="appletvos"
  184. fi
  185. if [ "$IOS" = "yes" ]; then
  186. PLATFORM="iphoneos"
  187. fi
  188. if [ "$MACOS" = "yes" ]; then
  189. PLATFORM="macosx"
  190. fi
  191. fi
  192. buildLibVLC $FARCH "$PLATFORM"
  193. fi
  194. fi
  195. }
  196. doVLCLipo() {
  197. FILEPATH="$1"
  198. FILE="$2"
  199. PLUGIN="$3"
  200. OSSTYLE="$4"
  201. files=""
  202. info "...$FILEPATH$FILE"
  203. for i in $DEVICEARCHS
  204. do
  205. actual_arch=`get_actual_arch $i`
  206. files="build-"$OSSTYLE"os-$actual_arch/vlc-"$OSSTYLE"os${SDK_VERSION}-$actual_arch/lib/$FILEPATH$FILE $files"
  207. done
  208. for i in $SIMULATORARCHS
  209. do
  210. actual_arch=`get_actual_arch $i`
  211. files="build-"$OSSTYLE"simulator-$actual_arch/vlc-"$OSSTYLE"simulator${SDK_VERSION}-$actual_arch/lib/$FILEPATH$FILE $files"
  212. done
  213. if [ "$PLUGIN" != "no" ]; then
  214. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  215. else
  216. lipo $files -create -output install-$OSSTYLE/core/$FILE
  217. fi
  218. }
  219. doContribLipo() {
  220. LIBNAME="$1"
  221. OSSTYLE="$2"
  222. files=""
  223. info "...$LIBNAME"
  224. for i in $DEVICEARCHS
  225. do
  226. files="build-"$OSSTYLE"os-$i/contrib/$i-"$OSSTYLE"os/lib/$LIBNAME $files"
  227. done
  228. for i in $SIMULATORARCHS
  229. do
  230. files="build-"$OSSTYLE"simulator-$i/contrib/$i-"$OSSTYLE"simulator/lib/$LIBNAME $files"
  231. done
  232. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  233. }
  234. get_symbol()
  235. {
  236. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  237. }
  238. build_universal_static_lib() {
  239. PROJECT_DIR=`pwd`
  240. OSSTYLE="$1"
  241. info "building universal static libs for OS style $OSSTYLE"
  242. # remove old module list
  243. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  244. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  245. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  246. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  247. if [ "$OSSTYLE" != "MacOSX" ]; then
  248. spushd ${VLCROOT}
  249. rm -rf install-$OSSTYLE
  250. mkdir install-$OSSTYLE
  251. mkdir install-$OSSTYLE/core
  252. mkdir install-$OSSTYLE/contrib
  253. mkdir install-$OSSTYLE/plugins
  254. spopd # vlc
  255. else
  256. spushd ${VLCROOT}/install-$OSSTYLE
  257. rm -rf core
  258. rm -rf contrib
  259. rm -rf plugins
  260. ln -s x86_64/lib core
  261. ln -s x86_64/contribs/lib contrib
  262. ln -s x86_64/lib/vlc/plugins plugins
  263. spopd # vlc
  264. fi
  265. VLCMODULES=""
  266. VLCMODULECATEGORYNAMES=""
  267. VLCNEONMODULES=""
  268. SIMULATORARCHS=""
  269. CONTRIBLIBS=""
  270. DEVICEARCHS=""
  271. arch="aarch64"
  272. if [ "$FARCH" != "all" ];then
  273. arch="$FARCH"
  274. elif [ "$BUILD_SIMULATOR" = "yes" ]; then
  275. arch="x86_64"
  276. fi
  277. actual_arch=`get_actual_arch $arch`
  278. # arm64 got the lowest number of modules, so we iterate here
  279. if [ -d ${VLCROOT}/build-"$OSSTYLE"os-arm64 ];then
  280. if [ "$OSSTYLE" = "iphone" ];then
  281. if [ "$FARCH" = "all" ];then
  282. DEVICEARCHS="arm64 armv7 armv7s"
  283. fi
  284. fi
  285. if [ "$OSSTYLE" = "appletv" ];then
  286. if [ "$FARCH" = "all" ];then
  287. DEVICEARCHS="arm64"
  288. fi
  289. fi
  290. VLCMODULES=""
  291. CONTRIBLIBS=""
  292. spushd ${VLCROOT}/build-"$OSSTYLE"os-arm64/vlc-"$OSSTYLE"os${SDK_VERSION}-arm64/lib/vlc/plugins/
  293. for f in `ls -F`
  294. do
  295. VLCMODULECATEGORYNAMES="$f $VLCMODULECATEGORYNAMES"
  296. for i in `ls $f*.a`
  297. do
  298. VLCMODULES="$i $VLCMODULES"
  299. done
  300. done
  301. spopd
  302. spushd ${VLCROOT}/build-"$OSSTYLE"os-arm64/contrib/arm64-"$OSSTYLE"os/lib
  303. for i in `ls *.a`
  304. do
  305. CONTRIBLIBS="$i $CONTRIBLIBS"
  306. done
  307. spopd
  308. fi
  309. if [ "$OSSTYLE" != "appletv" ];then
  310. # if we have an armv7(s) slice, we should search for and include NEON modules
  311. if [ -d ${VLCROOT}/build-"$OSSTYLE"os-armv7 ];then
  312. spushd ${VLCROOT}/build-"$OSSTYLE"os-armv7/vlc-"$OSSTYLE"os${SDK_VERSION}-armv7/lib/vlc/plugins/
  313. for f in `ls -F`
  314. do
  315. for i in `ls $f*.a | grep neon`
  316. do
  317. VLCNEONMODULES="$i $VLCNEONMODULES"
  318. done
  319. done
  320. spopd
  321. fi
  322. fi
  323. # x86_64 got the lowest number of modules, so we iterate here
  324. if [ -d ${VLCROOT}/build-"$OSSTYLE"simulator-x86_64 ];then
  325. if [ "$OSSTYLE" = "iphone" ];then
  326. if [ "$FARCH" = "all" ];then
  327. SIMULATORARCHS="x86_64 i386"
  328. fi
  329. fi
  330. if [ "$OSSTYLE" = "appletv" ];then
  331. if [ "$FARCH" = "all" ];then
  332. DEVICEARCHS="x86_64"
  333. fi
  334. fi
  335. VLCMODULES=""
  336. CONTRIBLIBS=""
  337. VLCMODULECATEGORYNAMES=""
  338. spushd ${VLCROOT}/build-"$OSSTYLE"simulator-x86_64/vlc-"$OSSTYLE"simulator${SDK_VERSION}-x86_64/lib/vlc/plugins/
  339. for f in `ls -F`
  340. do
  341. VLCMODULECATEGORYNAMES="$f $VLCMODULECATEGORYNAMES"
  342. for i in `ls $f*.a`
  343. do
  344. VLCMODULES="$i $VLCMODULES"
  345. done
  346. done
  347. spopd
  348. spushd ${VLCROOT}/build-"$OSSTYLE"simulator-x86_64/contrib/x86_64-"$OSSTYLE"simulator/lib
  349. for i in `ls *.a`
  350. do
  351. CONTRIBLIBS="$i $CONTRIBLIBS"
  352. done
  353. spopd
  354. fi
  355. if [ "$OSSTYLE" = "MacOSX" ]; then
  356. if [ -d ${VLCROOT}/install-"$OSSTYLE" ];then
  357. spushd ${VLCROOT}/install-"$OSSTYLE"
  358. echo `pwd`
  359. echo "macOS: $arch"
  360. spushd $arch/lib/vlc/plugins
  361. for i in `ls *.a`
  362. do
  363. VLCMODULES="$i $VLCMODULES"
  364. done
  365. spopd # $actual_arch/lib/vlc/plugins
  366. spopd # vlc-install-"$OSSTYLE"
  367. fi
  368. fi
  369. spushd ${VLCROOT}
  370. # add missing destination folders based on module category names
  371. for i in $VLCMODULECATEGORYNAMES
  372. do
  373. mkdir install-$OSSTYLE/plugins/$i
  374. done
  375. # lipo all the vlc libraries and its plugins
  376. if [ "$OSSTYLE" != "MacOSX" ]; then
  377. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  378. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  379. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  380. for i in $VLCMODULES
  381. do
  382. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  383. done
  384. # lipo contrib libraries
  385. for i in $CONTRIBLIBS
  386. do
  387. doContribLipo $i $OSSTYLE
  388. done
  389. if [ "$OSSTYLE" != "AppleTV" ]; then
  390. # lipo the remaining NEON plugins
  391. DEVICEARCHS=""
  392. for i in armv7 armv7s; do
  393. local iarch="`get_arch $i`"
  394. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  395. DEVICEARCHS="$DEVICEARCHS $iarch"
  396. fi
  397. done
  398. SIMULATORARCHS=""
  399. for i in $VLCNEONMODULES
  400. do
  401. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  402. done
  403. fi
  404. fi
  405. spopd
  406. # create module list
  407. info "creating module list"
  408. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  409. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  410. # arm64 got the lowest number of modules
  411. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  412. LDFLAGS=""
  413. DEFINITIONS=""
  414. # add contrib libraries to LDFLAGS
  415. for file in $CONTRIBLIBS
  416. do
  417. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/contrib/$file "
  418. done
  419. for file in $VLCMODULES
  420. do
  421. symbols=$(nm -g -arch $actual_arch ${VLCROOT}/install-$OSSTYLE/plugins/$file)
  422. entryname=$(get_symbol "$symbols" _)
  423. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  424. BUILTINS+=" $entryname,\n"
  425. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  426. info "...$entryname"
  427. done;
  428. # we only have ARM NEON modules for 32bit so this is limited to iOS
  429. if [ "$OSSTYLE" = "iphone" ]; then
  430. BUILTINS+="#ifdef __arm__\n"
  431. DEFINITIONS+="#ifdef __arm__\n"
  432. for file in $VLCNEONMODULES
  433. do
  434. symbols=$(nm -g -arch $actual_arch ${VLCROOT}/install-$OSSTYLE/plugins/$file)
  435. entryname=$(get_symbol "$symbols" _)
  436. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  437. BUILTINS+=" $entryname,\n"
  438. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  439. info "...$entryname"
  440. done;
  441. BUILTINS+="#endif\n"
  442. DEFINITIONS+="#endif\n"
  443. fi
  444. BUILTINS="$BUILTINS NULL\n};\n"
  445. echo "$DEFINITIONS\n$BUILTINS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  446. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  447. }
  448. while getopts "hvsfbdxntlk:a:e:" OPTION
  449. do
  450. case $OPTION in
  451. h)
  452. usage
  453. exit 1
  454. ;;
  455. v)
  456. VERBOSE=yes
  457. ;;
  458. s)
  459. BUILD_DEVICE=no
  460. BUILD_SIMULATOR=yes
  461. BUILD_STATIC_FRAMEWORK=no
  462. ;;
  463. f)
  464. BUILD_DEVICE=yes
  465. BUILD_SIMULATOR=yes
  466. BUILD_STATIC_FRAMEWORK=yes
  467. ;;
  468. d) CONFIGURATION="Release"
  469. DISABLEDEBUG=yes
  470. ;;
  471. n)
  472. NONETWORK=yes
  473. ;;
  474. l)
  475. SKIPLIBVLCCOMPILATION=yes
  476. ;;
  477. k)
  478. SDK=$OPTARG
  479. ;;
  480. a)
  481. BUILD_DEVICE=yes
  482. BUILD_SIMULATOR=yes
  483. BUILD_STATIC_FRAMEWORK=yes
  484. FARCH=$OPTARG
  485. ;;
  486. b)
  487. BITCODE=yes
  488. ;;
  489. t)
  490. TVOS=yes
  491. IOS=no
  492. BITCODE=yes
  493. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  494. SDK_MIN=10.2
  495. OSVERSIONMINCFLAG=tvos
  496. OSVERSIONMINLDFLAG=tvos
  497. ;;
  498. x)
  499. MACOS=yes
  500. IOS=no
  501. BITCODE=no
  502. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  503. SDK_MIN=10.11
  504. OSVERSIONMINCFLAG=macosx
  505. OSVERSIONMINLDFLAG=macosx
  506. BUILD_DEVICE=yes
  507. FARCH=x86_64
  508. BUILD_DYNAMIC_FRAMEWORK=yes
  509. BUILD_STATIC_FRAMEWORK=no
  510. ;;
  511. e)
  512. VLCROOT=$OPTARG
  513. ;;
  514. ?)
  515. usage
  516. exit 1
  517. ;;
  518. esac
  519. done
  520. shift $(($OPTIND - 1))
  521. out="/dev/null"
  522. if [ "$VERBOSE" = "yes" ]; then
  523. out="/dev/stdout"
  524. fi
  525. if [ "x$1" != "x" ]; then
  526. usage
  527. exit 1
  528. fi
  529. # Get root dir
  530. spushd .
  531. ROOT_DIR=`pwd`
  532. spopd
  533. if [ "$VLCROOT" = "" ]; then
  534. VLCROOT=${ROOT_DIR}/libvlc/vlc
  535. info "Preparing build dirs"
  536. mkdir -p libvlc
  537. spushd libvlc
  538. if [ "$NONETWORK" != "yes" ]; then
  539. if ! [ -e vlc ]; then
  540. git clone https://git.videolan.org/git/vlc.git vlc
  541. info "Applying patches to vlc.git"
  542. cd vlc
  543. git checkout -B localBranch ${TESTEDHASH}
  544. git branch --set-upstream-to=origin/master localBranch
  545. git am ${ROOT_DIR}/libvlc/patches/*.patch
  546. if [ $? -ne 0 ]; then
  547. git am --abort
  548. info "Applying the patches failed, aborting git-am"
  549. exit 1
  550. fi
  551. cd ..
  552. else
  553. cd vlc
  554. git fetch --all
  555. git reset --hard ${TESTEDHASH}
  556. git am ${ROOT_DIR}/libvlc/patches/*.patch
  557. cd ..
  558. fi
  559. fi
  560. spopd
  561. fi
  562. fetch_python3_path() {
  563. PYTHON3_PATH=$(echo /Library/Frameworks/Python.framework/Versions/3.*/bin | awk '{print $1;}')
  564. if [ ! -d "${PYTHON3_PATH}" ]; then
  565. PYTHON3_PATH=""
  566. fi
  567. }
  568. #
  569. # Build time
  570. #
  571. out="/dev/null"
  572. if [ "$VERBOSE" = "yes" ]; then
  573. out="/dev/stdout"
  574. fi
  575. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  576. info "Building tools"
  577. fetch_python3_path
  578. export PATH="${PYTHON3_PATH}:${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  579. spushd ${VLCROOT}/extras/tools
  580. ./bootstrap
  581. make
  582. make .buildgas
  583. make .buildxz
  584. make .buildtar
  585. make .buildmeson
  586. make .buildninja
  587. spopd #${VLCROOT}/extras/tools
  588. fi
  589. if [ "$BUILD_DEVICE" != "no" ]; then
  590. buildMobileKit iphoneos
  591. fi
  592. if [ "$BUILD_SIMULATOR" != "no" ]; then
  593. buildMobileKit iphonesimulator
  594. fi
  595. DEVICEARCHS=""
  596. SIMULATORARCHS=""
  597. if [ "$TVOS" = "yes" ]; then
  598. build_universal_static_lib "AppleTV"
  599. fi
  600. if [ "$MACOS" = "yes" ]; then
  601. build_universal_static_lib "MacOSX"
  602. fi
  603. if [ "$IOS" = "yes" ]; then
  604. build_universal_static_lib "iphone"
  605. fi
  606. info "all done"
  607. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  608. if [ "$TVOS" = "yes" ]; then
  609. info "Building static TVVLCKit.framework"
  610. lipo_libs=""
  611. platform=""
  612. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  613. platform="appletvos"
  614. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  615. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  616. fi
  617. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  618. platform="appletvsimulator"
  619. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  620. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  621. fi
  622. # Assumes both platforms were built currently
  623. spushd build
  624. rm -rf TVVLCKit.framework && \
  625. mkdir TVVLCKit.framework && \
  626. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  627. chmod a+x TVVLCKit.framework/TVVLCKit && \
  628. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  629. cp -pr ${CONFIGURATION}-${platform}/Modules TVVLCKit.framework/Modules
  630. spopd # build
  631. info "Build of static TVVLCKit.framework completed"
  632. fi
  633. if [ "$IOS" = "yes" ]; then
  634. info "Building static MobileVLCKit.framework"
  635. lipo_libs=""
  636. platform=""
  637. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  638. platform="iphoneos"
  639. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  640. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  641. fi
  642. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  643. platform="iphonesimulator"
  644. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  645. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  646. fi
  647. # Assumes both platforms were built currently
  648. spushd build
  649. rm -rf MobileVLCKit.framework && \
  650. mkdir MobileVLCKit.framework && \
  651. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  652. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  653. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  654. cp -pr ${CONFIGURATION}-${platform}/Modules MobileVLCKit.framework/Modules
  655. spopd # build
  656. info "Build of static MobileVLCKit.framework completed"
  657. fi
  658. fi
  659. if [ "$BUILD_DYNAMIC_FRAMEWORK" != "no" ]; then
  660. if [ "$MACOS" = "yes" ]; then
  661. info "Building VLCKit.framework"
  662. buildxcodeproj VLCKit "VLCKit" "macosx"
  663. # remove intermediate build result we don't need to keep
  664. spushd build
  665. rm ${CONFIGURATION}/libStaticLibVLC.a
  666. spopd # build
  667. info "Build of VLCKit.framework completed"
  668. fi
  669. fi