buildMobileVLCKit.sh 26 KB

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