compileAndBuildVLCKit.sh 30 KB

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