compileAndBuildVLCKit.sh 31 KB

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