buildMobileVLCKit.sh 22 KB

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