compileAndBuildVLCKit.sh 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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"
  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. invert
  472. sepia
  473. wave
  474. hqdn3d
  475. headphone_channel_mixer
  476. gaussianblur
  477. gradfun
  478. extract
  479. colorthres
  480. antiflicker
  481. anaglyph
  482. remap
  483. oldmovie
  484. vhs
  485. demuxdump
  486. fingerprinter
  487. output_udp
  488. output_livehttp
  489. libmux
  490. "
  491. if [ "$SCARY" = "no" ]; then
  492. blacklist="${blacklist}
  493. dts
  494. dvbsub
  495. svcd
  496. hevc
  497. packetizer_mlp
  498. a52
  499. vc1
  500. uleaddvaudio
  501. librar
  502. libvoc
  503. avio
  504. chorus_flanger
  505. smooth
  506. cvdsub
  507. libmod
  508. libdash
  509. libmpgv
  510. dolby_surround
  511. mpegaudio"
  512. fi
  513. echo ${blacklist}
  514. for i in ${blacklist}
  515. do
  516. find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
  517. done
  518. spopd
  519. }
  520. buildMobileKit() {
  521. PLATFORM="$1"
  522. cleantheenvironment
  523. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  524. if [ "$TVOS" = "yes" ]; then
  525. # this variable is read by libvlc's contrib build script
  526. # to create the required build environment
  527. # for historical raisons, tvOS is a special flavor of iOS
  528. # so we need to export both variables
  529. export BUILDFORIOS="yes"
  530. export BUILDFORTVOS="yes"
  531. info "Building libvlc for tvOS"
  532. fi
  533. if [ "$MACOS" = "yes" ]; then
  534. # macOS is the default build environment for libvlc's contrib
  535. # build scripts, so we don't need to export anything
  536. info "Building libvlc for macOS"
  537. fi
  538. if [ "$IOS" = "yes" ]; then
  539. # this variable is read by libvlc's contrib build script
  540. # to create the required build environment
  541. export BUILDFORIOS="yes"
  542. info "Building libvlc for iOS"
  543. fi
  544. export AR=`xcrun -f ar`
  545. export RANLIB=`xcrun -f ranlib`
  546. export CC=`xcrun -f clang`
  547. export OBJC=`xcrun -f clang`
  548. export CXX=`xcrun -f clang++`
  549. export LD=`xcrun -f ld`
  550. export STRIP=`xcrun -f strip`
  551. export CPPFLAGS=-E
  552. export CXXCPPFLAGS=-E
  553. unset AS
  554. unset CCAS
  555. if [ "$FARCH" = "all" ];then
  556. if [ "$TVOS" = "yes" ]; then
  557. if [ "$PLATFORM" = "iphonesimulator" ]; then
  558. buildLibVLC "x86_64" "Simulator"
  559. else
  560. buildLibVLC "aarch64" "OS"
  561. fi
  562. fi
  563. if [ "$MACOS" = "yes" ]; then
  564. buildLibVLC "x86_64" "OS"
  565. fi
  566. if [ "$IOS" = "yes" ]; then
  567. if [ "$PLATFORM" = "iphonesimulator" ]; then
  568. buildLibVLC "i386" "Simulator"
  569. buildLibVLC "x86_64" "Simulator"
  570. else
  571. buildLibVLC "armv7" "OS"
  572. buildLibVLC "armv7s" "OS"
  573. buildLibVLC "aarch64" "OS"
  574. fi
  575. fi
  576. else
  577. if [ "$FARCH" != "x86_64" -a "$FARCH" != "aarch64" -a "$FARCH" != "i386" \
  578. -a "$FARCH" != "armv7" -a "$FARCH" != "armv7s" ];then
  579. echo "*** Framework ARCH: ${FARCH} is invalid ***"
  580. exit 1
  581. fi
  582. local buildPlatform=""
  583. if [ "$PLATFORM" = "iphonesimulator" ]; then
  584. if [ "$FARCH" == "x86_64" -o "$FARCH" == "i386" ];then
  585. buildPlatform="Simulator"
  586. fi
  587. else
  588. if [ "$FARCH" == "armv7" -o "$FARCH" == "armv7s" -o "$FARCH" == "aarch64" ];then
  589. buildPlatform="OS"
  590. fi
  591. fi
  592. if [ ! -z "$buildPlatform" ];then
  593. buildLibVLC $FARCH $buildPlatform
  594. fi
  595. fi
  596. fi
  597. }
  598. doVLCLipo() {
  599. FILEPATH="$1"
  600. FILE="$2"
  601. PLUGIN="$3"
  602. OSSTYLE="$4"
  603. files=""
  604. info "...$FILEPATH$FILE"
  605. for i in $DEVICEARCHS
  606. do
  607. actual_arch=`get_actual_arch $i`
  608. files="install-"$OSSTYLE"OS/$actual_arch/lib/$FILEPATH$FILE $files"
  609. done
  610. for i in $SIMULATORARCHS
  611. do
  612. actual_arch=`get_actual_arch $i`
  613. files="install-"$OSSTYLE"Simulator/$actual_arch/lib/$FILEPATH$FILE $files"
  614. done
  615. if [ "$PLUGIN" != "no" ]; then
  616. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  617. else
  618. lipo $files -create -output install-$OSSTYLE/core/$FILE
  619. fi
  620. }
  621. doContribLipo() {
  622. LIBNAME="$1"
  623. OSSTYLE="$2"
  624. files=""
  625. info "...$LIBNAME"
  626. for i in $DEVICEARCHS $SIMULATORARCHS
  627. do
  628. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  629. done
  630. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  631. }
  632. get_symbol()
  633. {
  634. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  635. }
  636. build_universal_static_lib() {
  637. PROJECT_DIR=`pwd`
  638. OSSTYLE="$1"
  639. info "building universal static libs for OS style $OSSTYLE"
  640. # remove old module list
  641. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  642. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  643. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  644. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  645. if [ "$OSSTYLE" != "MacOSX" ]; then
  646. spushd ${VLCROOT}
  647. rm -rf install-$OSSTYLE
  648. mkdir install-$OSSTYLE
  649. mkdir install-$OSSTYLE/core
  650. mkdir install-$OSSTYLE/contrib
  651. mkdir install-$OSSTYLE/plugins
  652. spopd # vlc
  653. else
  654. spushd ${VLCROOT}/install-$OSSTYLE
  655. rm -rf core
  656. rm -rf contrib
  657. rm -rf plugins
  658. ln -s x86_64/lib core
  659. ln -s x86_64/contribs/lib contrib
  660. ln -s x86_64/lib/vlc/plugins plugins
  661. spopd # vlc
  662. fi
  663. VLCMODULES=""
  664. VLCNEONMODULES=""
  665. SIMULATORARCHS=""
  666. CONTRIBLIBS=""
  667. DEVICEARCHS=""
  668. # arm64 got the lowest number of modules
  669. arch="aarch64"
  670. if [ "$FARCH" != "all" ];then
  671. arch="$FARCH"
  672. fi
  673. actual_arch=`get_actual_arch $arch`
  674. if [ -d ${VLCROOT}/install-"$OSSTYLE"OS ];then
  675. spushd ${VLCROOT}/install-"$OSSTYLE"OS
  676. for i in `ls .`
  677. do
  678. local iarch="`get_arch $i`"
  679. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  680. DEVICEARCHS="$DEVICEARCHS $iarch"
  681. fi
  682. done
  683. if (! is_simulator_arch $arch);then
  684. echo "IPHONE OS: $arch"
  685. spushd $actual_arch/lib/vlc/plugins
  686. for i in `ls *.a`
  687. do
  688. VLCMODULES="$i $VLCMODULES"
  689. done
  690. spopd # $actual_arch/lib/vlc/plugins
  691. fi
  692. if [ "$OSSTYLE" != "AppleTV" -a \
  693. \( "$FARCH" = "all" -o "$FARCH" = "armv7" -o "$FARCH" = "armv7s" \) ]; then
  694. # collect ARMv7/s specific neon modules
  695. if [ "$FARCH" = "all" ];then
  696. spushd armv7/lib/vlc/plugins
  697. else
  698. spushd $FARCH/lib/vlc/plugins
  699. fi
  700. for i in `ls *.a | grep neon`
  701. do
  702. VLCNEONMODULES="$i $VLCNEONMODULES"
  703. done
  704. spopd # armv7/lib/vlc/plugins
  705. fi
  706. spopd # vlc-install-"$OSSTYLE"OS
  707. fi
  708. if [ -d ${VLCROOT}/install-"$OSSTYLE"Simulator ];then
  709. spushd ${VLCROOT}/install-"$OSSTYLE"Simulator
  710. if (is_simulator_arch $arch);then
  711. echo "SIMU OS: $arch"
  712. spushd $actual_arch/lib/vlc/plugins
  713. for i in `ls *.a`
  714. do
  715. VLCMODULES="$i $VLCMODULES"
  716. done
  717. spopd # $actual_arch/lib/vlc/plugins
  718. fi
  719. for i in `ls .`
  720. do
  721. local iarch="`get_arch $i`"
  722. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  723. SIMULATORARCHS="$SIMULATORARCHS $iarch"
  724. fi
  725. done
  726. spopd # vlc-install-"$OSSTYLE"Simulator
  727. fi
  728. if [ "$OSSTYLE" = "MacOSX" ]; then
  729. if [ -d ${VLCROOT}/install-"$OSSTYLE" ];then
  730. spushd ${VLCROOT}/install-"$OSSTYLE"
  731. echo `pwd`
  732. echo "macOS: $arch"
  733. spushd $arch/lib/vlc/plugins
  734. for i in `ls *.a`
  735. do
  736. VLCMODULES="$i $VLCMODULES"
  737. done
  738. spopd # $actual_arch/lib/vlc/plugins
  739. spopd # vlc-install-"$OSSTYLE"
  740. fi
  741. fi
  742. spushd ${VLCROOT}
  743. # collect contrib libraries
  744. spushd contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  745. for i in `ls *.a`
  746. do
  747. CONTRIBLIBS="$i $CONTRIBLIBS"
  748. done
  749. spopd # contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  750. # lipo all the vlc libraries and its plugins
  751. if [ "$OSSTYLE" != "MacOSX" ]; then
  752. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  753. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  754. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  755. for i in $VLCMODULES
  756. do
  757. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  758. done
  759. # lipo contrib libraries
  760. for i in $CONTRIBLIBS
  761. do
  762. doContribLipo $i $OSSTYLE
  763. done
  764. if [ "$OSSTYLE" != "AppleTV" ]; then
  765. # lipo the remaining NEON plugins
  766. DEVICEARCHS=""
  767. for i in armv7 armv7s; do
  768. local iarch="`get_arch $i`"
  769. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  770. DEVICEARCHS="$DEVICEARCHS $iarch"
  771. fi
  772. done
  773. SIMULATORARCHS=""
  774. for i in $VLCNEONMODULES
  775. do
  776. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  777. done
  778. fi
  779. fi
  780. # create module list
  781. info "creating module list"
  782. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  783. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  784. # arm64 got the lowest number of modules
  785. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  786. LDFLAGS=""
  787. DEFINITIONS=""
  788. # add contrib libraries to LDFLAGS
  789. for file in $CONTRIBLIBS
  790. do
  791. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/contrib/$file "
  792. done
  793. for file in $VLCMODULES
  794. do
  795. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  796. entryname=$(get_symbol "$symbols" _)
  797. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  798. BUILTINS+=" $entryname,\n"
  799. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  800. info "...$entryname"
  801. done;
  802. # we only have ARM NEON modules for 32bit so this is limited to iOS
  803. if [ "$OSSTYLE" = "iPhone" ]; then
  804. BUILTINS+="#ifdef __arm__\n"
  805. DEFINITIONS+="#ifdef __arm__\n"
  806. for file in $VLCNEONMODULES
  807. do
  808. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  809. entryname=$(get_symbol "$symbols" _)
  810. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  811. BUILTINS+=" $entryname,\n"
  812. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  813. info "...$entryname"
  814. done;
  815. BUILTINS+="#endif\n"
  816. DEFINITIONS+="#endif\n"
  817. fi
  818. BUILTINS="$BUILTINS NULL\n};\n"
  819. echo "$DEFINITIONS\n$BUILTINS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  820. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  821. spopd # vlc
  822. }
  823. while getopts "hvwsfbdxntlk:a:e:" OPTION
  824. do
  825. case $OPTION in
  826. h)
  827. usage
  828. exit 1
  829. ;;
  830. v)
  831. VERBOSE=yes
  832. ;;
  833. s)
  834. BUILD_DEVICE=no
  835. BUILD_SIMULATOR=yes
  836. BUILD_STATIC_FRAMEWORK=no
  837. ;;
  838. f)
  839. BUILD_DEVICE=yes
  840. BUILD_SIMULATOR=yes
  841. BUILD_STATIC_FRAMEWORK=yes
  842. ;;
  843. d) CONFIGURATION="Debug"
  844. DEBUG=yes
  845. ;;
  846. w) SCARY="no"
  847. ;;
  848. n)
  849. NONETWORK=yes
  850. ;;
  851. l)
  852. SKIPLIBVLCCOMPILATION=yes
  853. ;;
  854. k)
  855. SDK=$OPTARG
  856. ;;
  857. a)
  858. BUILD_DEVICE=yes
  859. BUILD_SIMULATOR=yes
  860. BUILD_STATIC_FRAMEWORK=yes
  861. FARCH=$OPTARG
  862. ;;
  863. b)
  864. BITCODE=yes
  865. ;;
  866. t)
  867. TVOS=yes
  868. IOS=no
  869. BITCODE=yes
  870. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  871. SDK_MIN=9.0
  872. OSVERSIONMINCFLAG=mtvos-version-min
  873. OSVERSIONMINLDFLAG=tvos_version_min
  874. ;;
  875. x)
  876. MACOS=yes
  877. IOS=no
  878. BITCODE=no
  879. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  880. SDK_MIN=10.9
  881. OSVERSIONMINCFLAG=mmacosx-version-min
  882. OSVERSIONMINLDFLAG=macosx_version_min
  883. BUILD_DEVICE=yes
  884. FARCH=x86_64
  885. BUILD_DYNAMIC_FRAMEWORK=yes
  886. BUILD_STATIC_FRAMEWORK=no
  887. ;;
  888. e)
  889. VLCROOT=$OPTARG
  890. ;;
  891. ?)
  892. usage
  893. exit 1
  894. ;;
  895. esac
  896. done
  897. shift $(($OPTIND - 1))
  898. out="/dev/null"
  899. if [ "$VERBOSE" = "yes" ]; then
  900. out="/dev/stdout"
  901. fi
  902. if [ "x$1" != "x" ]; then
  903. usage
  904. exit 1
  905. fi
  906. # Get root dir
  907. spushd .
  908. ROOT_DIR=`pwd`
  909. spopd
  910. if [ "$VLCROOT" = "" ]; then
  911. VLCROOT=${ROOT_DIR}/libvlc/vlc
  912. info "Preparing build dirs"
  913. mkdir -p libvlc
  914. spushd libvlc
  915. if [ "$NONETWORK" != "yes" ]; then
  916. if ! [ -e vlc ]; then
  917. git clone https://git.videolan.org/git/vlc/vlc-3.0.git vlc
  918. info "Applying patches to vlc.git"
  919. cd vlc
  920. git checkout -B localBranch ${TESTEDHASH}
  921. git branch --set-upstream-to=origin/master localBranch
  922. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  923. if [ $? -ne 0 ]; then
  924. git am --abort
  925. info "Applying the patches failed, aborting git-am"
  926. exit 1
  927. fi
  928. cd ..
  929. else
  930. cd vlc
  931. git pull --rebase
  932. git reset --hard ${TESTEDHASH}
  933. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  934. cd ..
  935. fi
  936. fi
  937. spopd
  938. fi
  939. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:${VLC_PATH}:/usr/bin:/bin:/usr/sbin:/sbin"
  940. echo `pwd`
  941. #
  942. # Build time
  943. #
  944. out="/dev/null"
  945. if [ "$VERBOSE" = "yes" ]; then
  946. out="/dev/stdout"
  947. fi
  948. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  949. info "Building tools"
  950. spushd ${VLCROOT}/extras/tools
  951. ./bootstrap
  952. make
  953. make .gas
  954. spopd #${VLCROOT}/extras/tools
  955. fi
  956. if [ "$BUILD_DEVICE" != "no" ]; then
  957. buildMobileKit iphoneos
  958. fi
  959. if [ "$BUILD_SIMULATOR" != "no" ]; then
  960. buildMobileKit iphonesimulator
  961. fi
  962. DEVICEARCHS=""
  963. SIMULATORARCHS=""
  964. if [ "$TVOS" = "yes" ]; then
  965. build_universal_static_lib "AppleTV"
  966. fi
  967. if [ "$MACOS" = "yes" ]; then
  968. build_universal_static_lib "MacOSX"
  969. fi
  970. if [ "$IOS" = "yes" ]; then
  971. build_universal_static_lib "iPhone"
  972. fi
  973. info "all done"
  974. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  975. if [ "$TVOS" = "yes" ]; then
  976. info "Building static TVVLCKit.framework"
  977. lipo_libs=""
  978. platform=""
  979. if [ -d ${VLCROOT}/install-AppleTVOS ];then
  980. platform="appletvos"
  981. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  982. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  983. fi
  984. if [ -d ${VLCROOT}/install-AppleTVSimulator ];then
  985. platform="appletvsimulator"
  986. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  987. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  988. fi
  989. # Assumes both platforms were built currently
  990. spushd build
  991. rm -rf TVVLCKit.framework && \
  992. mkdir TVVLCKit.framework && \
  993. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  994. chmod a+x TVVLCKit.framework/TVVLCKit && \
  995. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  996. spopd # build
  997. info "Build of static TVVLCKit.framework completed"
  998. fi
  999. if [ "$IOS" = "yes" ]; then
  1000. info "Building static MobileVLCKit.framework"
  1001. lipo_libs=""
  1002. platform=""
  1003. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  1004. platform="iphoneos"
  1005. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1006. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  1007. fi
  1008. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  1009. platform="iphonesimulator"
  1010. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1011. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  1012. fi
  1013. # Assumes both platforms were built currently
  1014. spushd build
  1015. rm -rf MobileVLCKit.framework && \
  1016. mkdir MobileVLCKit.framework && \
  1017. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  1018. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  1019. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  1020. spopd # build
  1021. info "Build of static MobileVLCKit.framework completed"
  1022. fi
  1023. fi
  1024. if [ "$BUILD_DYNAMIC_FRAMEWORK" != "no" ]; then
  1025. if [ "$MACOS" = "yes" ]; then
  1026. info "Building VLCKit.framework"
  1027. buildxcodeproj VLCKit "VLCKit" "macosx"
  1028. # remove intermediate build result we don't need to keep
  1029. spushd build
  1030. rm ${CONFIGURATION}/libStaticLibVLC.a
  1031. spopd # build
  1032. info "Build of VLCKit.framework completed"
  1033. fi
  1034. fi