buildMobileVLCKit.sh 26 KB

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