buildMobileVLCKit.sh 26 KB

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