buildMobileVLCKit.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  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=7e8b50a2
  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}/Resources/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}/Resources/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-vlc-app \
  382. --disable-macosx-avfoundation \
  383. --disable-audioqueue \
  384. --disable-shared \
  385. --enable-opus \
  386. --disable-faad \
  387. --disable-lua \
  388. --disable-a52 \
  389. --enable-fribidi \
  390. --disable-qt --disable-skins2 \
  391. --disable-vcd \
  392. --disable-vlc \
  393. --disable-vlm \
  394. --disable-httpd \
  395. --disable-nls \
  396. --disable-sse \
  397. --disable-notify \
  398. --enable-live555 \
  399. --enable-realrtsp \
  400. --enable-swscale \
  401. --disable-projectm \
  402. --enable-libass \
  403. --enable-libxml2 \
  404. --disable-goom \
  405. --disable-dvdread \
  406. --disable-dvdnav \
  407. --disable-bluray \
  408. --disable-linsys \
  409. --disable-libva \
  410. --disable-gme \
  411. --disable-tremor \
  412. --enable-vorbis \
  413. --disable-fluidsynth \
  414. --disable-jack \
  415. --disable-pulse \
  416. --disable-mtp \
  417. --enable-ogg \
  418. --enable-speex \
  419. --enable-theora \
  420. --enable-flac \
  421. --disable-screen \
  422. --enable-freetype \
  423. --enable-taglib \
  424. --disable-mmx \
  425. --disable-addonmanagermodules \
  426. --disable-mad > ${out}
  427. fi
  428. info "Building libvlc"
  429. make -j$MAKE_JOBS > ${out}
  430. info "Installing libvlc"
  431. make install > ${out}
  432. find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
  433. rm -rf "${PREFIX}/contribs"
  434. cp -R "${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" "${PREFIX}/contribs"
  435. info "Removing unneeded modules"
  436. blacklist="
  437. stats
  438. access_bd
  439. shm
  440. access_imem
  441. oldrc
  442. real
  443. hotkeys
  444. gestures
  445. dynamicoverlay
  446. rss
  447. ball
  448. marq
  449. magnify
  450. audiobargraph_
  451. clone
  452. mosaic
  453. osdmenu
  454. puzzle
  455. mediadirs
  456. t140
  457. ripple
  458. motion
  459. sharpen
  460. grain
  461. posterize
  462. mirror
  463. wall
  464. scene
  465. blendbench
  466. psychedelic
  467. alphamask
  468. netsync
  469. audioscrobbler
  470. motiondetect
  471. motionblur
  472. export
  473. smf
  474. podcast
  475. bluescreen
  476. erase
  477. stream_filter_record
  478. speex_resampler
  479. remoteosd
  480. magnify
  481. gradient
  482. logger
  483. visual
  484. fb
  485. aout_file
  486. dummy
  487. invert
  488. sepia
  489. wave
  490. hqdn3d
  491. headphone_channel_mixer
  492. gaussianblur
  493. gradfun
  494. extract
  495. colorthres
  496. antiflicker
  497. anaglyph
  498. remap
  499. oldmovie
  500. vhs
  501. demuxdump
  502. fingerprinter
  503. output_udp
  504. output_http
  505. output_livehttp
  506. libmux
  507. stream_out
  508. "
  509. if [ "$SCARY" = "no" ]; then
  510. blacklist="${blacklist}
  511. dts
  512. dvbsub
  513. svcd
  514. hevc
  515. packetizer_mlp
  516. a52
  517. vc1
  518. uleaddvaudio
  519. librar
  520. libvoc
  521. avio
  522. chorus_flanger
  523. smooth
  524. cvdsub
  525. libmod
  526. libdash
  527. libmpgv
  528. dolby_surround
  529. mpegaudio"
  530. fi
  531. echo ${blacklist}
  532. for i in ${blacklist}
  533. do
  534. find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
  535. done
  536. spopd
  537. }
  538. buildMobileKit() {
  539. PLATFORM="$1"
  540. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  541. if [ "$TVOS" = "yes" ]; then
  542. export BUILDFORTVOS="yes"
  543. info "Building libvlc for tvOS"
  544. else
  545. info "Building libvlc for iOS"
  546. fi
  547. export BUILDFORIOS="yes"
  548. export AR="xcrun ar"
  549. export RANLIB="xcrun ranlib"
  550. export CC="xcrun clang"
  551. export OBJC="xcrun clang"
  552. export CXX="xcrun clang++"
  553. export LD="xcrun ld"
  554. export STRIP="xcrun strip"
  555. export CPP="xcrun cc -E"
  556. export CXXCPP="xcrun c++ -E"
  557. if [ "$TVOS" = "yes" ]; then
  558. if [ "$PLATFORM" = "iphonesimulator" ]; then
  559. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $SDK_VERSION "Simulator"
  560. else
  561. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $SDK_VERSION "OS"
  562. fi
  563. else
  564. if [ "$PLATFORM" = "iphonesimulator" ]; then
  565. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "i386" $TVOS $SDK_VERSION "Simulator"
  566. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $SDK_VERSION "Simulator"
  567. else
  568. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7" $TVOS $SDK_VERSION "OS"
  569. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7s" $TVOS $SDK_VERSION "OS"
  570. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $SDK_VERSION "OS"
  571. fi
  572. fi
  573. fi
  574. }
  575. if [ "$BUILD_DEVICE" != "no" ]; then
  576. buildMobileKit iphoneos
  577. fi
  578. if [ "$BUILD_SIMULATOR" != "no" ]; then
  579. buildMobileKit iphonesimulator
  580. fi
  581. DEVICEARCHS=""
  582. SIMULATORARCHS=""
  583. doVLCLipo() {
  584. FILEPATH="$1"
  585. FILE="$2"
  586. PLUGIN="$3"
  587. OSSTYLE="$4"
  588. files=""
  589. info "...$FILEPATH$FILE"
  590. for i in $DEVICEARCHS
  591. do
  592. files="install-"$OSSTYLE"OS/$i/lib/$FILEPATH$FILE $files"
  593. done
  594. for i in $SIMULATORARCHS
  595. do
  596. files="install-"$OSSTYLE"Simulator/$i/lib/$FILEPATH$FILE $files"
  597. done
  598. if [ "$PLUGIN" != "no" ]; then
  599. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  600. else
  601. lipo $files -create -output install-$OSSTYLE/core/$FILE
  602. fi
  603. }
  604. doContribLipo() {
  605. LIBNAME="$1"
  606. OSSTYLE="$2"
  607. files=""
  608. info "...$LIBNAME"
  609. for i in $DEVICEARCHS
  610. do
  611. if [ "$i" != "arm64" ]; then
  612. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  613. else
  614. files="contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib/$LIBNAME $files"
  615. fi
  616. done
  617. for i in $SIMULATORARCHS
  618. do
  619. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  620. done
  621. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  622. }
  623. get_symbol()
  624. {
  625. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  626. }
  627. build_universal_static_lib() {
  628. PROJECT_DIR=`pwd`
  629. OSSTYLE="$1"
  630. info "building universal static libs for OS style $OSSTYLE"
  631. # remove old module list
  632. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  633. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  634. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  635. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  636. spushd libvlc/vlc
  637. rm -rf install-$OSSTYLE
  638. mkdir install-$OSSTYLE
  639. mkdir install-$OSSTYLE/core
  640. mkdir install-$OSSTYLE/contrib
  641. mkdir install-$OSSTYLE/plugins
  642. spopd # vlc
  643. spushd libvlc/vlc/install-"$OSSTYLE"OS
  644. for i in `ls .`
  645. do
  646. DEVICEARCHS="$DEVICEARCHS $i"
  647. done
  648. spopd # vlc-install-"$OSSTYLE"OS
  649. spushd libvlc/vlc/install-"$OSSTYLE"Simulator
  650. for i in `ls .`
  651. do
  652. SIMULATORARCHS="$SIMULATORARCHS $i"
  653. done
  654. spopd # vlc-install-"$OSSTYLE"Simulator
  655. # arm64 got the lowest number of modules
  656. VLCMODULES=""
  657. spushd libvlc/vlc/install-"$OSSTYLE"OS/arm64/lib/vlc/plugins
  658. for i in `ls *.a`
  659. do
  660. VLCMODULES="$i $VLCMODULES"
  661. done
  662. spopd # vlc/install-"$OSSTYLE"OS/arm64/lib/vlc/plugins
  663. if [ "$OSSTYLE" != "AppleTV" ]; then
  664. # collect ARMv7/s specific neon modules
  665. VLCNEONMODULES=""
  666. spushd libvlc/vlc/install-"$OSSTYLE"OS/armv7/lib/vlc/plugins
  667. for i in `ls *.a | grep neon`
  668. do
  669. VLCNEONMODULES="$i $VLCNEONMODULES"
  670. done
  671. spopd # vlc/install-"$OSSTYLE"OS/armv7/lib/vlc/plugins
  672. fi
  673. spushd libvlc/vlc
  674. # lipo all the vlc libraries and its plugins
  675. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  676. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  677. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  678. for i in $VLCMODULES
  679. do
  680. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  681. done
  682. # lipo contrib libraries
  683. CONTRIBLIBS=""
  684. spushd contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib
  685. for i in `ls *.a`
  686. do
  687. CONTRIBLIBS="$i $CONTRIBLIBS"
  688. done
  689. spopd # contrib/$OSSTYLE-aarch64-apple-darwin14-aarch64/lib
  690. for i in $CONTRIBLIBS
  691. do
  692. doContribLipo $i $OSSTYLE
  693. done
  694. if [ "$OSSTYLE" != "AppleTV" ]; then
  695. # lipo the remaining NEON plugins
  696. DEVICEARCHS="armv7 armv7s"
  697. SIMULATORARCHS=""
  698. for i in $VLCNEONMODULES
  699. do
  700. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  701. done
  702. fi
  703. # create module list
  704. info "creating module list"
  705. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  706. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  707. # arm64 got the lowest number of modules
  708. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  709. LDFLAGS=""
  710. DEFINITIONS=""
  711. # add contrib libraries to LDFLAGS
  712. for file in $CONTRIBLIBS
  713. do
  714. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/contrib/$file "
  715. done
  716. for file in $VLCMODULES
  717. do
  718. symbols=$(nm -g -arch arm64 install-$OSSTYLE/plugins/$file)
  719. entryname=$(get_symbol "$symbols" _)
  720. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  721. BUILTINS+=" $entryname,\n"
  722. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  723. info "...$entryname"
  724. done;
  725. if [ "$OSSTYLE" != "AppleTV" ]; then
  726. BUILTINS+="#ifdef __arm__\n"
  727. DEFINITIONS+="#ifdef __arm__\n"
  728. for file in $VLCNEONMODULES
  729. do
  730. symbols=$(nm -g -arch armv7 install-$OSSTYLE/plugins/$file)
  731. entryname=$(get_symbol "$symbols" _)
  732. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  733. BUILTINS+=" $entryname,\n"
  734. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  735. info "...$entryname"
  736. done;
  737. BUILTINS+="#endif\n"
  738. DEFINITIONS+="#endif\n"
  739. fi
  740. BUILTINS="$BUILTINS NULL\n};\n"
  741. echo "$DEFINITIONS\n$BUILTINS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  742. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  743. spopd # vlc
  744. }
  745. if [ "$TVOS" != "yes" ]; then
  746. build_universal_static_lib "iPhone"
  747. else
  748. build_universal_static_lib "AppleTV"
  749. fi
  750. info "all done"
  751. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  752. if [ "$TVOS" != "yes" ]; then
  753. info "Building static MobileVLCKit.framework"
  754. buildxcodeproj MobileVLCKit "MobileVLCKit" iphoneos
  755. buildxcodeproj MobileVLCKit "MobileVLCKit" iphonesimulator
  756. # Assumes both platforms were built currently
  757. spushd build
  758. rm -rf MobileVLCKit.framework && \
  759. mkdir MobileVLCKit.framework && \
  760. lipo -create ${CONFIGURATION}-iphoneos/libMobileVLCKit.a \
  761. ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a \
  762. -o MobileVLCKit.framework/MobileVLCKit && \
  763. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  764. cp -pr ${CONFIGURATION}-iphoneos/MobileVLCKit MobileVLCKit.framework/Headers
  765. spopd # build
  766. info "Build of static MobileVLCKit.framework completed"
  767. else
  768. info "Building static TVVLCKit.framework"
  769. buildxcodeproj MobileVLCKit "TVVLCKit" appletvos
  770. buildxcodeproj MobileVLCKit "TVVLCKit" appletvsimulator
  771. # Assumes both platforms were built currently
  772. spushd build
  773. rm -rf TVVLCKit.framework && \
  774. mkdir TVVLCKit.framework && \
  775. lipo -create ${CONFIGURATION}-appletvos/libTVVLCKit.a \
  776. ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a \
  777. -o TVVLCKit.framework/TVVLCKit && \
  778. chmod a+x TVVLCKit.framework/TVVLCKit && \
  779. cp -pr ${CONFIGURATION}-appletvos/TVVLCKit TVVLCKit.framework/Headers
  780. spopd # build
  781. info "Build of static TVVLCKit.framework completed"
  782. fi
  783. fi