buildMobileVLCKit.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. #!/bin/sh
  2. # Copyright (C) Pierre d'Herbemont, 2010
  3. # Copyright (C) Felix Paul Kühne, 2012-2017
  4. set -e
  5. BUILD_DEVICE=yes
  6. BUILD_SIMULATOR=yes
  7. BUILD_STATIC_FRAMEWORK=no
  8. SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
  9. SDK_MIN=7.0
  10. VERBOSE=no
  11. DEBUG=no
  12. CONFIGURATION="Release"
  13. NONETWORK=no
  14. SKIPLIBVLCCOMPILATION=no
  15. SCARY=yes
  16. TVOS=no
  17. BITCODE=no
  18. OSVERSIONMINCFLAG=miphoneos-version-min
  19. OSVERSIONMINLDFLAG=ios_version_min
  20. ROOT_DIR=empty
  21. TESTEDHASH=5f341b579
  22. CORE_COUNT=`sysctl -n machdep.cpu.core_count`
  23. let MAKE_JOBS=$CORE_COUNT+1
  24. usage()
  25. {
  26. cat << EOF
  27. usage: $0 [-s] [-v] [-k sdk]
  28. OPTIONS
  29. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  30. -v Be more verbose
  31. -s Build for simulator
  32. -f Build framework for device and simulator
  33. -d Enable Debug
  34. -n Skip script steps requiring network interaction
  35. -l Skip libvlc compilation
  36. -t Build for tvOS
  37. -w Build a limited stack of non-scary libraries only
  38. -y Build universal static libraries
  39. -b Enable bitcode
  40. EOF
  41. }
  42. while getopts "hvwsfbdntlk:" OPTION
  43. do
  44. case $OPTION in
  45. h)
  46. usage
  47. exit 1
  48. ;;
  49. v)
  50. VERBOSE=yes
  51. MAKE_JOBS=1
  52. ;;
  53. s)
  54. BUILD_DEVICE=no
  55. BUILD_SIMULATOR=yes
  56. BUILD_STATIC_FRAMEWORK=no
  57. ;;
  58. f)
  59. BUILD_DEVICE=yes
  60. BUILD_SIMULATOR=yes
  61. BUILD_STATIC_FRAMEWORK=yes
  62. ;;
  63. d) CONFIGURATION="Debug"
  64. DEBUG=yes
  65. ;;
  66. w) SCARY="no"
  67. ;;
  68. n)
  69. NONETWORK=yes
  70. ;;
  71. l)
  72. SKIPLIBVLCCOMPILATION=yes
  73. ;;
  74. k)
  75. SDK=$OPTARG
  76. ;;
  77. b)
  78. BITCODE=yes
  79. ;;
  80. t)
  81. TVOS=yes
  82. BITCODE=yes
  83. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  84. SDK_MIN=9.0
  85. OSVERSIONMINCFLAG=mtvos-version-min
  86. OSVERSIONMINLDFLAG=tvos_version_min
  87. ;;
  88. ?)
  89. usage
  90. exit 1
  91. ;;
  92. esac
  93. done
  94. shift $(($OPTIND - 1))
  95. out="/dev/null"
  96. if [ "$VERBOSE" = "yes" ]; then
  97. out="/dev/stdout"
  98. fi
  99. if [ "x$1" != "x" ]; then
  100. usage
  101. exit 1
  102. fi
  103. spushd()
  104. {
  105. pushd "$1" 2>&1> /dev/null
  106. }
  107. spopd()
  108. {
  109. popd 2>&1> /dev/null
  110. }
  111. info()
  112. {
  113. local green="\033[1;32m"
  114. local normal="\033[0m"
  115. echo "[${green}info${normal}] $1"
  116. }
  117. buildxcodeproj()
  118. {
  119. local target="$2"
  120. local PLATFORM="$3"
  121. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  122. local architectures=""
  123. if [ "$TVOS" != "yes" ]; then
  124. if [ "$PLATFORM" = "iphonesimulator" ]; then
  125. architectures="i386 x86_64"
  126. else
  127. architectures="armv7 armv7s arm64"
  128. fi
  129. else
  130. if [ "$PLATFORM" = "appletvsimulator" ]; then
  131. architectures="x86_64"
  132. else
  133. architectures="arm64"
  134. fi
  135. fi
  136. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  137. if [ "$SCARY" = "no" ]; then
  138. defs="$defs NOSCARYCODECS"
  139. fi
  140. xcodebuild -project "$1.xcodeproj" \
  141. -target "$target" \
  142. -sdk $PLATFORM$SDK \
  143. -configuration ${CONFIGURATION} \
  144. ARCHS="${architectures}" \
  145. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  146. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  147. > ${out}
  148. }
  149. # Get root dir
  150. spushd .
  151. ROOT_DIR=`pwd`
  152. spopd
  153. info "Preparing build dirs"
  154. mkdir -p libvlc
  155. spushd libvlc
  156. echo `pwd`
  157. if [ "$NONETWORK" != "yes" ]; then
  158. if ! [ -e vlc ]; then
  159. git clone git://git.videolan.org/vlc.git vlc
  160. info "Applying patches to vlc.git"
  161. cd vlc
  162. git checkout -B localBranch ${TESTEDHASH}
  163. git branch --set-upstream-to=origin/master localBranch
  164. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  165. if [ $? -ne 0 ]; then
  166. git am --abort
  167. info "Applying the patches failed, aborting git-am"
  168. exit 1
  169. fi
  170. cd ..
  171. else
  172. cd vlc
  173. git pull --rebase
  174. git reset --hard ${TESTEDHASH}
  175. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  176. cd ..
  177. fi
  178. fi
  179. spopd
  180. #
  181. # Build time
  182. #
  183. out="/dev/null"
  184. if [ "$VERBOSE" = "yes" ]; then
  185. out="/dev/stdout"
  186. fi
  187. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  188. info "Building tools"
  189. spushd ${ROOT_DIR}/libvlc/vlc/extras/tools
  190. ./bootstrap
  191. make
  192. make .gas
  193. spopd #libvlc/vlc/extras/tools
  194. fi
  195. buildLibVLC() {
  196. VERBOSE="$1"
  197. DEBUG="$2"
  198. SCARY="$3"
  199. BITCODE="$4"
  200. ARCH="$5"
  201. TVOS="$6"
  202. SDK_VERSION="$7"
  203. PLATFORM="$8"
  204. OSSTYLE=iPhone
  205. VLCROOT=${ROOT_DIR}/libvlc/vlc
  206. if [ "$DEBUG" = "yes" ]; then
  207. OPTIM="-O0 -g"
  208. else
  209. OPTIM="-O3 -g"
  210. fi
  211. if [ "$TVOS" = "yes" ]; then
  212. OSSTYLE=AppleTV
  213. fi
  214. if [ "$ARCH" = "aarch64" ]; then
  215. ACTUAL_ARCH="arm64"
  216. else
  217. ACTUAL_ARCH="$ARCH"
  218. fi
  219. info "Compiling ${ARCH} with SDK version ${SDK_VERSION}, platform ${PLATFORM}"
  220. SDKROOT=`xcode-select -print-path`/Platforms/${OSSTYLE}${PLATFORM}.platform/Developer/SDKs/${OSSTYLE}${PLATFORM}${SDK_VERSION}.sdk
  221. if [ ! -d "${SDKROOT}" ]
  222. then
  223. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  224. exit 1
  225. fi
  226. BUILDDIR="${VLCROOT}/build-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  227. PREFIX="${VLCROOT}/install-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  228. TARGET="${ARCH}-apple-darwin14"
  229. # clean the environment
  230. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:${PATH}"
  231. export CFLAGS=""
  232. export CPPFLAGS=""
  233. export CXXFLAGS=""
  234. export OBJCFLAGS=""
  235. export LDFLAGS=""
  236. export PLATFORM=$PLATFORM
  237. export SDK_VERSION=$SDK_VERSION
  238. export VLCSDKROOT=$SDKROOT
  239. CFLAGS="-isysroot ${SDKROOT} -arch ${ACTUAL_ARCH} ${OPTIM}"
  240. OBJCFLAGS="${OPTIM}"
  241. if [ "$PLATFORM" = "OS" ]; then
  242. if [ "$ARCH" != "aarch64" ]; then
  243. CFLAGS+=" -mcpu=cortex-a8 -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  244. else
  245. CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  246. fi
  247. else
  248. CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  249. fi
  250. if [ "$BITCODE" = "yes" ]; then
  251. CFLAGS+=" -fembed-bitcode"
  252. fi
  253. export CFLAGS="${CFLAGS}"
  254. export CXXFLAGS="${CFLAGS}"
  255. export CPPFLAGS="${CFLAGS}"
  256. export OBJCFLAGS="${OBJCFLAGS}"
  257. if [ "$PLATFORM" = "Simulator" ]; then
  258. # Use the new ABI on simulator, else we can't build
  259. export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
  260. fi
  261. export LDFLAGS="-isysroot ${SDKROOT} -L${SDKROOT}/usr/lib -arch ${ACTUAL_ARCH}"
  262. if [ "$PLATFORM" = "OS" ]; then
  263. EXTRA_CFLAGS="-arch ${ACTUAL_ARCH}"
  264. EXTRA_LDFLAGS="-arch ${ACTUAL_ARCH}"
  265. if [ "$ARCH" != "aarch64" ]; then
  266. EXTRA_CFLAGS+=" -mcpu=cortex-a8"
  267. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  268. EXTRA_LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  269. export LDFLAGS="${LDFLAGS} -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  270. else
  271. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  272. EXTRA_LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  273. export LDFLAGS="${LDFLAGS} -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  274. fi
  275. else
  276. EXTRA_CFLAGS="-arch ${ARCH}"
  277. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  278. EXTRA_LDFLAGS=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  279. export LDFLAGS="${LDFLAGS} -v -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  280. fi
  281. spushd ${VLCROOT}/contrib
  282. info "Compiling third-party libraries"
  283. mkdir -p "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  284. cd "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  285. if [ "$PLATFORM" = "OS" ]; then
  286. export AS="gas-preprocessor.pl ${CC}"
  287. export ASCPP="gas-preprocessor.pl ${CC}"
  288. export CCAS="gas-preprocessor.pl ${CC}"
  289. if [ "$ARCH" = "aarch64" ]; then
  290. export GASPP_FIX_XCODE5=1
  291. fi
  292. else
  293. export ASCPP="xcrun as"
  294. fi
  295. if [ "$TVOS" = "yes" ]; then
  296. TVOSOPTIONS="--disable-libarchive"
  297. else
  298. TVOSOPTIONS=""
  299. fi
  300. if [ "${TARGET}" = "x86_64-apple-darwin14" ];then
  301. BUILD=""
  302. else
  303. BUILD="--build=x86_64-apple-darwin14"
  304. fi
  305. ../bootstrap ${BUILD} --host=${TARGET} --prefix=${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH} --disable-gpl \
  306. --disable-disc --disable-sout \
  307. --disable-sdl \
  308. --disable-SDL_image \
  309. --disable-iconv \
  310. --enable-zvbi \
  311. --disable-kate \
  312. --disable-caca \
  313. --disable-gettext \
  314. --disable-mpcdec \
  315. --disable-upnp \
  316. --disable-gme \
  317. --disable-tremor \
  318. --enable-vorbis \
  319. --disable-sidplay2 \
  320. --disable-samplerate \
  321. --disable-goom \
  322. --disable-vncserver \
  323. --disable-orc \
  324. --disable-schroedinger \
  325. --disable-libmpeg2 \
  326. --disable-chromaprint \
  327. --disable-mad \
  328. --enable-fribidi \
  329. --enable-libxml2 \
  330. --enable-freetype2 \
  331. --enable-ass \
  332. --disable-fontconfig \
  333. --disable-gpg-error \
  334. --disable-vncclient \
  335. --disable-gnutls \
  336. --disable-lua \
  337. --disable-luac \
  338. --disable-protobuf \
  339. --disable-aribb24 \
  340. --disable-aribb25 \
  341. --enable-vpx \
  342. --enable-libdsm \
  343. ${TVOSOPTIONS} \
  344. --enable-taglib > ${out}
  345. echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
  346. echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
  347. make fetch -j$MAKE_JOBS
  348. make -j$MAKE_JOBS > ${out}
  349. spopd # ${VLCROOT}/contrib
  350. if ! [ -e ${VLCROOT}/configure ]; then
  351. info "Bootstraping vlc"
  352. ${VLCROOT}/bootstrap > ${out}
  353. fi
  354. mkdir -p ${BUILDDIR}
  355. spushd ${BUILDDIR}
  356. if [ "$DEBUG" = "yes" ]; then
  357. DEBUGFLAG="--enable-debug"
  358. else
  359. DEBUGFLAG="--disable-debug"
  360. fi
  361. if [ "$SCARY" = "yes" ]; then
  362. SCARYFLAG="--enable-dvbpsi --enable-avcodec --disable-vpx"
  363. else
  364. SCARYFLAG="--disable-dca --disable-dvbpsi --disable-avcodec --disable-avformat --disable-zvbi --enable-vpx"
  365. fi
  366. if [ "$TVOS" = "yes" ]; then
  367. TVOSOPTIONS="--disable-neon"
  368. else
  369. TVOSOPTIONS="--enable-neon"
  370. fi
  371. # Available but not authorized
  372. export ac_cv_func_daemon=no
  373. export ac_cv_func_fork=no
  374. if [ "${VLCROOT}/configure" -nt config.log -o \
  375. "${THIS_SCRIPT_PATH}" -nt config.log ]; then
  376. info "Configuring vlc"
  377. ${VLCROOT}/configure \
  378. --prefix="${PREFIX}" \
  379. --host="${TARGET}" \
  380. --with-contrib="${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" \
  381. --enable-static \
  382. ${DEBUGFLAG} \
  383. ${SCARYFLAG} \
  384. ${TVOSOPTIONS} \
  385. --disable-macosx \
  386. --disable-macosx-qtkit \
  387. --disable-macosx-avfoundation \
  388. --disable-shared \
  389. --enable-opus \
  390. --disable-faad \
  391. --disable-lua \
  392. --disable-a52 \
  393. --enable-fribidi \
  394. --disable-qt --disable-skins2 \
  395. --disable-vcd \
  396. --disable-vlc \
  397. --disable-vlm \
  398. --disable-httpd \
  399. --disable-nls \
  400. --disable-sse \
  401. --disable-notify \
  402. --enable-live555 \
  403. --enable-realrtsp \
  404. --enable-swscale \
  405. --disable-projectm \
  406. --enable-libass \
  407. --enable-libxml2 \
  408. --disable-goom \
  409. --disable-dvdread \
  410. --disable-dvdnav \
  411. --disable-bluray \
  412. --disable-linsys \
  413. --disable-libva \
  414. --disable-gme \
  415. --disable-tremor \
  416. --enable-vorbis \
  417. --disable-fluidsynth \
  418. --disable-jack \
  419. --disable-pulse \
  420. --disable-mtp \
  421. --enable-ogg \
  422. --enable-speex \
  423. --enable-theora \
  424. --enable-flac \
  425. --disable-screen \
  426. --enable-freetype \
  427. --enable-taglib \
  428. --disable-mmx \
  429. --disable-addonmanagermodules \
  430. --disable-mad > ${out}
  431. fi
  432. info "Building libvlc"
  433. make -j$MAKE_JOBS > ${out}
  434. info "Installing libvlc"
  435. make install > ${out}
  436. find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
  437. rm -rf "${PREFIX}/contribs"
  438. cp -R "${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" "${PREFIX}/contribs"
  439. info "Removing unneeded modules"
  440. blacklist="
  441. stats
  442. access_bd
  443. shm
  444. access_imem
  445. oldrc
  446. real
  447. hotkeys
  448. gestures
  449. dynamicoverlay
  450. rss
  451. ball
  452. marq
  453. magnify
  454. audiobargraph_
  455. clone
  456. mosaic
  457. osdmenu
  458. puzzle
  459. mediadirs
  460. t140
  461. ripple
  462. motion
  463. sharpen
  464. grain
  465. posterize
  466. mirror
  467. wall
  468. scene
  469. blendbench
  470. psychedelic
  471. alphamask
  472. netsync
  473. audioscrobbler
  474. motiondetect
  475. motionblur
  476. export
  477. smf
  478. podcast
  479. bluescreen
  480. erase
  481. stream_filter_record
  482. speex_resampler
  483. remoteosd
  484. magnify
  485. gradient
  486. logger
  487. visual
  488. fb
  489. aout_file
  490. dummy
  491. invert
  492. sepia
  493. wave
  494. hqdn3d
  495. headphone_channel_mixer
  496. gaussianblur
  497. gradfun
  498. extract
  499. colorthres
  500. antiflicker
  501. anaglyph
  502. remap
  503. oldmovie
  504. vhs
  505. demuxdump
  506. fingerprinter
  507. output_udp
  508. output_http
  509. output_livehttp
  510. libmux
  511. stream_out
  512. "
  513. if [ "$SCARY" = "no" ]; then
  514. blacklist="${blacklist}
  515. dts
  516. dvbsub
  517. svcd
  518. hevc
  519. packetizer_mlp
  520. a52
  521. vc1
  522. uleaddvaudio
  523. librar
  524. libvoc
  525. avio
  526. chorus_flanger
  527. smooth
  528. cvdsub
  529. libmod
  530. libdash
  531. libmpgv
  532. dolby_surround
  533. mpegaudio"
  534. fi
  535. echo ${blacklist}
  536. for i in ${blacklist}
  537. do
  538. find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
  539. done
  540. spopd
  541. }
  542. buildMobileKit() {
  543. PLATFORM="$1"
  544. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  545. if [ "$TVOS" = "yes" ]; then
  546. export BUILDFORTVOS="yes"
  547. info "Building libvlc for tvOS"
  548. else
  549. info "Building libvlc for iOS"
  550. fi
  551. export BUILDFORIOS="yes"
  552. export AR=`xcrun -f ar`
  553. export RANLIB=`xcrun -f ranlib`
  554. export CC=`xcrun -f clang`
  555. export OBJC=`xcrun -f clang`
  556. export CXX=`xcrun -f clang++`
  557. export LD=`xcrun -f ld`
  558. export STRIP=`xcrun -f strip`
  559. export CPPFLAGS=-E
  560. export CXXCPPFLAGS=-E
  561. unset AS
  562. unset CCAS
  563. if [ "$TVOS" = "yes" ]; then
  564. if [ "$PLATFORM" = "iphonesimulator" ]; then
  565. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $SDK_VERSION "Simulator"
  566. else
  567. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $SDK_VERSION "OS"
  568. fi
  569. else
  570. if [ "$PLATFORM" = "iphonesimulator" ]; then
  571. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "i386" $TVOS $SDK_VERSION "Simulator"
  572. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $SDK_VERSION "Simulator"
  573. else
  574. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7" $TVOS $SDK_VERSION "OS"
  575. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7s" $TVOS $SDK_VERSION "OS"
  576. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $SDK_VERSION "OS"
  577. fi
  578. fi
  579. fi
  580. }
  581. if [ "$BUILD_DEVICE" != "no" ]; then
  582. buildMobileKit iphoneos
  583. fi
  584. if [ "$BUILD_SIMULATOR" != "no" ]; then
  585. buildMobileKit iphonesimulator
  586. fi
  587. DEVICEARCHS=""
  588. SIMULATORARCHS=""
  589. doVLCLipo() {
  590. FILEPATH="$1"
  591. FILE="$2"
  592. PLUGIN="$3"
  593. OSSTYLE="$4"
  594. files=""
  595. info "...$FILEPATH$FILE"
  596. for i in $DEVICEARCHS
  597. do
  598. files="install-"$OSSTYLE"OS/$i/lib/$FILEPATH$FILE $files"
  599. done
  600. for i in $SIMULATORARCHS
  601. do
  602. files="install-"$OSSTYLE"Simulator/$i/lib/$FILEPATH$FILE $files"
  603. done
  604. if [ "$PLUGIN" != "no" ]; then
  605. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  606. else
  607. lipo $files -create -output install-$OSSTYLE/core/$FILE
  608. fi
  609. }
  610. doContribLipo() {
  611. LIBNAME="$1"
  612. OSSTYLE="$2"
  613. files=""
  614. info "...$LIBNAME"
  615. for i in $DEVICEARCHS
  616. do
  617. if [ "$i" != "arm64" ]; then
  618. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  619. else
  620. files="contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib/$LIBNAME $files"
  621. fi
  622. done
  623. for i in $SIMULATORARCHS
  624. do
  625. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  626. done
  627. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  628. }
  629. get_symbol()
  630. {
  631. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  632. }
  633. build_universal_static_lib() {
  634. PROJECT_DIR=`pwd`
  635. OSSTYLE="$1"
  636. info "building universal static libs for OS style $OSSTYLE"
  637. # remove old module list
  638. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  639. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  640. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  641. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  642. spushd libvlc/vlc
  643. rm -rf install-$OSSTYLE
  644. mkdir install-$OSSTYLE
  645. mkdir install-$OSSTYLE/core
  646. mkdir install-$OSSTYLE/contrib
  647. mkdir install-$OSSTYLE/plugins
  648. spopd # vlc
  649. spushd libvlc/vlc/install-"$OSSTYLE"OS
  650. for i in `ls .`
  651. do
  652. DEVICEARCHS="$DEVICEARCHS $i"
  653. done
  654. spopd # vlc-install-"$OSSTYLE"OS
  655. spushd libvlc/vlc/install-"$OSSTYLE"Simulator
  656. for i in `ls .`
  657. do
  658. SIMULATORARCHS="$SIMULATORARCHS $i"
  659. done
  660. spopd # vlc-install-"$OSSTYLE"Simulator
  661. # arm64 got the lowest number of modules
  662. VLCMODULES=""
  663. spushd libvlc/vlc/install-"$OSSTYLE"OS/arm64/lib/vlc/plugins
  664. for i in `ls *.a`
  665. do
  666. VLCMODULES="$i $VLCMODULES"
  667. done
  668. spopd # vlc/install-"$OSSTYLE"OS/arm64/lib/vlc/plugins
  669. if [ "$OSSTYLE" != "AppleTV" ]; then
  670. # collect ARMv7/s specific neon modules
  671. VLCNEONMODULES=""
  672. spushd libvlc/vlc/install-"$OSSTYLE"OS/armv7/lib/vlc/plugins
  673. for i in `ls *.a | grep neon`
  674. do
  675. VLCNEONMODULES="$i $VLCNEONMODULES"
  676. done
  677. spopd # vlc/install-"$OSSTYLE"OS/armv7/lib/vlc/plugins
  678. fi
  679. spushd libvlc/vlc
  680. # lipo all the vlc libraries and its plugins
  681. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  682. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  683. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  684. for i in $VLCMODULES
  685. do
  686. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  687. done
  688. # lipo contrib libraries
  689. CONTRIBLIBS=""
  690. spushd contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib
  691. for i in `ls *.a`
  692. do
  693. CONTRIBLIBS="$i $CONTRIBLIBS"
  694. done
  695. spopd # contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib
  696. for i in $CONTRIBLIBS
  697. do
  698. doContribLipo $i $OSSTYLE
  699. done
  700. if [ "$OSSTYLE" != "AppleTV" ]; then
  701. # lipo the remaining NEON plugins
  702. DEVICEARCHS="armv7 armv7s"
  703. SIMULATORARCHS=""
  704. for i in $VLCNEONMODULES
  705. do
  706. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  707. done
  708. fi
  709. # create module list
  710. info "creating module list"
  711. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  712. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  713. # arm64 got the lowest number of modules
  714. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  715. LDFLAGS=""
  716. DEFINITIONS=""
  717. # add contrib libraries to LDFLAGS
  718. for file in $CONTRIBLIBS
  719. do
  720. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/contrib/$file "
  721. done
  722. for file in $VLCMODULES
  723. do
  724. symbols=$(nm -g -arch arm64 install-$OSSTYLE/plugins/$file)
  725. entryname=$(get_symbol "$symbols" _)
  726. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  727. BUILTINS+=" $entryname,\n"
  728. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  729. info "...$entryname"
  730. done;
  731. if [ "$OSSTYLE" != "AppleTV" ]; then
  732. BUILTINS+="#ifdef __arm__\n"
  733. DEFINITIONS+="#ifdef __arm__\n"
  734. for file in $VLCNEONMODULES
  735. do
  736. symbols=$(nm -g -arch armv7 install-$OSSTYLE/plugins/$file)
  737. entryname=$(get_symbol "$symbols" _)
  738. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  739. BUILTINS+=" $entryname,\n"
  740. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  741. info "...$entryname"
  742. done;
  743. BUILTINS+="#endif\n"
  744. DEFINITIONS+="#endif\n"
  745. fi
  746. BUILTINS="$BUILTINS NULL\n};\n"
  747. echo "$DEFINITIONS\n$BUILTINS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  748. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  749. spopd # vlc
  750. }
  751. if [ "$TVOS" != "yes" ]; then
  752. build_universal_static_lib "iPhone"
  753. else
  754. build_universal_static_lib "AppleTV"
  755. fi
  756. info "all done"
  757. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  758. if [ "$TVOS" != "yes" ]; then
  759. info "Building static MobileVLCKit.framework"
  760. buildxcodeproj MobileVLCKit "MobileVLCKit" iphoneos
  761. buildxcodeproj MobileVLCKit "MobileVLCKit" iphonesimulator
  762. # Assumes both platforms were built currently
  763. spushd build
  764. rm -rf MobileVLCKit.framework && \
  765. mkdir MobileVLCKit.framework && \
  766. lipo -create ${CONFIGURATION}-iphoneos/libMobileVLCKit.a \
  767. ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a \
  768. -o MobileVLCKit.framework/MobileVLCKit && \
  769. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  770. cp -pr ${CONFIGURATION}-iphoneos/MobileVLCKit MobileVLCKit.framework/Headers
  771. spopd # build
  772. info "Build of static MobileVLCKit.framework completed"
  773. else
  774. info "Building static TVVLCKit.framework"
  775. buildxcodeproj MobileVLCKit "TVVLCKit" appletvos
  776. buildxcodeproj MobileVLCKit "TVVLCKit" appletvsimulator
  777. # Assumes both platforms were built currently
  778. spushd build
  779. rm -rf TVVLCKit.framework && \
  780. mkdir TVVLCKit.framework && \
  781. lipo -create ${CONFIGURATION}-appletvos/libTVVLCKit.a \
  782. ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a \
  783. -o TVVLCKit.framework/TVVLCKit && \
  784. chmod a+x TVVLCKit.framework/TVVLCKit && \
  785. cp -pr ${CONFIGURATION}-appletvos/TVVLCKit TVVLCKit.framework/Headers
  786. spopd # build
  787. info "Build of static TVVLCKit.framework completed"
  788. fi
  789. fi