buildMobileVLCKit.sh 26 KB

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