buildMobileVLCKit.sh 26 KB

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