buildMobileVLCKit.sh 22 KB

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