compileAndBuildVLCKit.sh 31 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="1177dfe4b" # 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. export PKG_CONFIG_PATH=""
  103. }
  104. buildxcodeproj()
  105. {
  106. cleantheenvironment
  107. local target="$2"
  108. local PLATFORM="$3"
  109. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  110. local architectures=""
  111. if [ "$FARCH" = "all" ];then
  112. if [ "$TVOS" = "yes" ]; then
  113. if [ "$PLATFORM" = "appletvsimulator" ]; then
  114. architectures="x86_64"
  115. else
  116. architectures="arm64"
  117. fi
  118. fi
  119. if [ "$IOS" = "yes" ]; then
  120. if [ "$PLATFORM" = "iphonesimulator" ]; then
  121. architectures="i386 x86_64"
  122. else
  123. architectures="armv7 armv7s arm64"
  124. fi
  125. fi
  126. else
  127. architectures=`get_actual_arch $FARCH`
  128. fi
  129. local bitcodeflag=""
  130. if [ "$BITCODE" = "yes" ]; then
  131. bitcodeflag="BITCODE_GENERATION_MODE=bitcode"
  132. fi
  133. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  134. if [ "$SCARY" = "no" ]; then
  135. defs="$defs NOSCARYCODECS"
  136. fi
  137. xcodebuild -project "$1.xcodeproj" \
  138. -target "$target" \
  139. -sdk $PLATFORM$SDK \
  140. -configuration ${CONFIGURATION} \
  141. ARCHS="${architectures}" \
  142. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  143. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  144. ${bitcodeflag} \
  145. > ${out}
  146. }
  147. buildLibVLC() {
  148. ARCH="$1"
  149. PLATFORM="$2"
  150. OSSTYLE=iPhone
  151. if [ "$DEBUG" = "yes" ]; then
  152. OPTIM="-O0 -g"
  153. else
  154. OPTIM="-O3 -g"
  155. fi
  156. if [ "$TVOS" = "yes" ]; then
  157. OSSTYLE=AppleTV
  158. fi
  159. if [ "$MACOS" = "yes" ]; then
  160. OSSTYLE=MacOSX
  161. PLATFORM=
  162. fi
  163. ACTUAL_ARCH=`get_actual_arch $ARCH`
  164. info "Compiling ${ARCH} with SDK version ${SDK_VERSION}, platform ${PLATFORM}"
  165. SDKROOT=`xcode-select -print-path`/Platforms/${OSSTYLE}${PLATFORM}.platform/Developer/SDKs/${OSSTYLE}${PLATFORM}${SDK_VERSION}.sdk
  166. if [ ! -d "${SDKROOT}" ]
  167. then
  168. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  169. exit 1
  170. fi
  171. BUILDDIR="${VLCROOT}/build-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  172. PREFIX="${VLCROOT}/install-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  173. TARGET="${ARCH}-apple-darwin14"
  174. # partially clean the environment
  175. export CFLAGS=""
  176. export CPPFLAGS=""
  177. export CXXFLAGS=""
  178. export OBJCFLAGS=""
  179. export LDFLAGS=""
  180. export PLATFORM=$PLATFORM
  181. export SDK_VERSION=$SDK_VERSION
  182. export VLCSDKROOT=$SDKROOT
  183. OBJCFLAGS="${OPTIM}"
  184. CFLAGS="-isysroot ${SDKROOT} -arch ${ACTUAL_ARCH} ${OPTIM}"
  185. EXTRA_CFLAGS="-arch ${ACTUAL_ARCH}"
  186. LDFLAGS="-arch ${ACTUAL_ARCH}"
  187. EXTRA_LDFLAGS="-arch ${ACTUAL_ARCH}"
  188. CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  189. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  190. LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  191. EXTRA_LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  192. if [ "$PLATFORM" = "OS" ]; then
  193. if [ "$ARCH" != "aarch64" ]; then
  194. CFLAGS+=" -mcpu=cortex-a8"
  195. EXTRA_CFLAGS+=" -mcpu=cortex-a8"
  196. fi
  197. else # Simulator platform
  198. LDFLAGS+=" -v"
  199. # Use the new ABI on simulator, else we can't build
  200. OBJCFLAGS+=" -fobjc-abi-version=2 -fobjc-legacy-dispatch"
  201. fi
  202. if [ "$BITCODE" = "yes" ]; then
  203. CFLAGS+=" -fembed-bitcode"
  204. fi
  205. export CFLAGS="${CFLAGS}"
  206. export CXXFLAGS="${CFLAGS}"
  207. export CPPFLAGS="${CFLAGS}"
  208. export OBJCFLAGS="${OBJCFLAGS}"
  209. export LDFLAGS="${LDFLAGS}"
  210. spushd ${VLCROOT}/contrib
  211. info "Compiling third-party libraries"
  212. mkdir -p "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  213. cd "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  214. if [ "$PLATFORM" = "OS" ]; then
  215. export AS="gas-preprocessor.pl ${CC}"
  216. export ASCPP="gas-preprocessor.pl ${CC}"
  217. export CCAS="gas-preprocessor.pl ${CC}"
  218. if [ "$ARCH" = "aarch64" ]; then
  219. export GASPP_FIX_XCODE5=1
  220. fi
  221. else
  222. export ASCPP="xcrun as"
  223. fi
  224. if [ "$TVOS" = "yes" ]; then
  225. CUSTOMOSOPTIONS="--disable-libarchive"
  226. fi
  227. if [ "$MACOS" = "yes" ]; then
  228. CUSTOMOSOPTIONS="--disable-fontconfig --disable-bghudappkit --disable-twolame --disable-microdns --disable-SDL --disable-SDL_image --disable-cddb --disable-bluray"
  229. fi
  230. if [ "$IOS" = "yes" ]; then
  231. CUSTOMOSOPTIONS=""
  232. fi
  233. if [ "${TARGET}" = "x86_64-apple-darwin14" ];then
  234. BUILD=""
  235. else
  236. BUILD="--build=x86_64-apple-darwin14"
  237. fi
  238. if [ "$MACOS" = "yes" ]; then
  239. # The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
  240. # here. This allows compilation also with newer macOS SDKs.
  241. # Added symbols in 10.13
  242. export ac_cv_func_open_wmemstream=no
  243. export ac_cv_func_fmemopen=no
  244. export ac_cv_func_open_memstream=no
  245. export ac_cv_func_futimens=no
  246. export ac_cv_func_utimensat=no
  247. # Added symbols between 10.11 and 10.12
  248. export ac_cv_func_basename_r=no
  249. export ac_cv_func_clock_getres=no
  250. export ac_cv_func_clock_gettime=no
  251. export ac_cv_func_clock_settime=no
  252. export ac_cv_func_dirname_r=no
  253. export ac_cv_func_getentropy=no
  254. export ac_cv_func_mkostemp=no
  255. export ac_cv_func_mkostemps=no
  256. # Added symbols between 10.7 and 10.11
  257. export ac_cv_func_ffsll=no
  258. export ac_cv_func_flsll=no
  259. export ac_cv_func_fdopendir=no
  260. export ac_cv_func_openat=no
  261. export ac_cv_func_fstatat=no
  262. export ac_cv_func_readlinkat=no
  263. else
  264. # The following symbols do not exist on the minimal iOS version (7.0), so they are disabled
  265. # here. This allows compilation also with newer iOS SDKs
  266. # Added symbols between 7.x and 10.x
  267. export ac_cv_func_basename_r=no
  268. export ac_cv_func_clock_getres=no
  269. export ac_cv_func_clock_gettime=no
  270. export ac_cv_func_clock_settime=no
  271. export ac_cv_func_dirname_r=no
  272. export ac_cv_func_getentropy=no
  273. export ac_cv_func_mkostemp=no
  274. export ac_cv_func_mkostemps=no
  275. export ac_cv_func_open_memstream=no
  276. export ac_cv_func_futimens=no
  277. fi
  278. export USE_FFMPEG=1
  279. ../bootstrap ${BUILD} --host=${TARGET} --prefix=${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH} --disable-gpl \
  280. --enable-ad-clauses \
  281. --disable-disc \
  282. --disable-sdl \
  283. --disable-SDL_image \
  284. --disable-iconv \
  285. --enable-zvbi \
  286. --disable-kate \
  287. --disable-caca \
  288. --disable-gettext \
  289. --disable-mpcdec \
  290. --disable-upnp \
  291. --disable-gme \
  292. --disable-srt \
  293. --disable-tremor \
  294. --enable-vorbis \
  295. --disable-sidplay2 \
  296. --disable-samplerate \
  297. --disable-goom \
  298. --disable-vncserver \
  299. --disable-orc \
  300. --disable-schroedinger \
  301. --disable-libmpeg2 \
  302. --disable-chromaprint \
  303. --disable-mad \
  304. --enable-fribidi \
  305. --enable-libxml2 \
  306. --enable-freetype2 \
  307. --enable-ass \
  308. --disable-fontconfig \
  309. --disable-gpg-error \
  310. --disable-vncclient \
  311. --disable-gnutls \
  312. --disable-lua \
  313. --disable-luac \
  314. --disable-aribb24 \
  315. --disable-aribb25 \
  316. --enable-vpx \
  317. --enable-libdsm \
  318. --enable-libplacebo \
  319. --disable-sparkle \
  320. --disable-growl \
  321. --disable-breakpad \
  322. --disable-ncurses \
  323. --disable-asdcplib \
  324. --enable-soxr \
  325. ${CUSTOMOSOPTIONS} \
  326. --enable-taglib > ${out}
  327. echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
  328. echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
  329. make fetch -j$MAKE_JOBS
  330. make -j$MAKE_JOBS > ${out}
  331. spopd # ${VLCROOT}/contrib
  332. if ! [ -e ${VLCROOT}/configure ]; then
  333. info "Bootstraping vlc"
  334. ${VLCROOT}/bootstrap > ${out}
  335. fi
  336. mkdir -p ${BUILDDIR}
  337. spushd ${BUILDDIR}
  338. if [ "$DEBUG" = "yes" ]; then
  339. DEBUGFLAG="--enable-debug"
  340. else
  341. export CFLAGS="${CFLAGS} -DNDEBUG"
  342. fi
  343. if [ "$SCARY" = "yes" ]; then
  344. SCARYFLAG="--enable-dvbpsi --enable-avcodec"
  345. else
  346. SCARYFLAG="--disable-dca --disable-dvbpsi --disable-avcodec --disable-avformat --disable-zvbi --enable-vpx"
  347. fi
  348. if [ "$TVOS" != "yes" -a \( "$ARCH" = "armv7" -o "$ARCH" = "armv7s" \) ];then
  349. export ac_cv_arm_neon=yes
  350. else
  351. export ac_cv_arm_neon=no
  352. fi
  353. # Available but not authorized
  354. export ac_cv_func_daemon=no
  355. export ac_cv_func_fork=no
  356. if [ "${VLCROOT}/configure" -nt config.log -o \
  357. "${THIS_SCRIPT_PATH}" -nt config.log ]; then
  358. info "Configuring vlc"
  359. ${VLCROOT}/configure \
  360. --prefix="${PREFIX}" \
  361. --host="${TARGET}" \
  362. --with-contrib="${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" \
  363. --enable-static \
  364. ${DEBUGFLAG} \
  365. ${SCARYFLAG} \
  366. --disable-macosx \
  367. --disable-macosx-qtkit \
  368. --disable-macosx-avfoundation \
  369. --disable-shared \
  370. --enable-opus \
  371. --disable-faad \
  372. --disable-lua \
  373. --disable-a52 \
  374. --enable-fribidi \
  375. --disable-qt --disable-skins2 \
  376. --disable-vcd \
  377. --disable-vlc \
  378. --disable-vlm \
  379. --disable-httpd \
  380. --disable-nls \
  381. --disable-sse \
  382. --disable-notify \
  383. --enable-live555 \
  384. --enable-realrtsp \
  385. --enable-swscale \
  386. --disable-projectm \
  387. --enable-libass \
  388. --enable-libxml2 \
  389. --disable-goom \
  390. --disable-dvdread \
  391. --disable-dvdnav \
  392. --disable-bluray \
  393. --disable-linsys \
  394. --disable-libva \
  395. --disable-gme \
  396. --disable-tremor \
  397. --enable-vorbis \
  398. --disable-fluidsynth \
  399. --disable-jack \
  400. --disable-pulse \
  401. --disable-mtp \
  402. --enable-ogg \
  403. --enable-speex \
  404. --enable-theora \
  405. --enable-flac \
  406. --disable-screen \
  407. --enable-freetype \
  408. --enable-taglib \
  409. --disable-mmx \
  410. --disable-sparkle \
  411. --disable-addonmanagermodules \
  412. --disable-mad > ${out}
  413. fi
  414. info "Building libvlc"
  415. make -j$MAKE_JOBS > ${out}
  416. info "Installing libvlc"
  417. make install > ${out}
  418. find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
  419. rm -rf "${PREFIX}/contribs"
  420. cp -R "${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" "${PREFIX}/contribs"
  421. info "Removing unneeded modules"
  422. blacklist="
  423. stats
  424. access_bd
  425. shm
  426. access_imem
  427. oldrc
  428. real
  429. hotkeys
  430. gestures
  431. dynamicoverlay
  432. rss
  433. ball
  434. marq
  435. magnify
  436. audiobargraph_
  437. clone
  438. mosaic
  439. osdmenu
  440. puzzle
  441. mediadirs
  442. t140
  443. ripple
  444. motion
  445. sharpen
  446. grain
  447. posterize
  448. mirror
  449. wall
  450. scene
  451. blendbench
  452. psychedelic
  453. alphamask
  454. netsync
  455. audioscrobbler
  456. motiondetect
  457. motionblur
  458. export
  459. smf
  460. podcast
  461. bluescreen
  462. erase
  463. stream_filter_record
  464. speex_resampler
  465. remoteosd
  466. magnify
  467. gradient
  468. logger
  469. visual
  470. fb
  471. aout_file
  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 pull --rebase
  933. git reset --hard ${TESTEDHASH}
  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 [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  981. platform="appletvos"
  982. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  983. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  984. fi
  985. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);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