compileAndBuildVLCKit.sh 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  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="b22b91763" # 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. elif [ "$BUILD_SIMULATOR" = "yes" ]; then
  674. arch="x86_64"
  675. fi
  676. actual_arch=`get_actual_arch $arch`
  677. if [ -d ${VLCROOT}/install-"$OSSTYLE"OS ];then
  678. spushd ${VLCROOT}/install-"$OSSTYLE"OS
  679. for i in `ls .`
  680. do
  681. local iarch="`get_arch $i`"
  682. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  683. DEVICEARCHS="$DEVICEARCHS $iarch"
  684. fi
  685. done
  686. if (! is_simulator_arch $arch);then
  687. echo "IPHONE OS: $arch"
  688. spushd $actual_arch/lib/vlc/plugins
  689. for i in `ls *.a`
  690. do
  691. VLCMODULES="$i $VLCMODULES"
  692. done
  693. spopd # $actual_arch/lib/vlc/plugins
  694. fi
  695. if [ "$OSSTYLE" != "AppleTV" -a \
  696. \( "$FARCH" = "all" -o "$FARCH" = "armv7" -o "$FARCH" = "armv7s" \) ]; then
  697. # collect ARMv7/s specific neon modules
  698. if [ "$FARCH" = "all" ];then
  699. spushd armv7/lib/vlc/plugins
  700. else
  701. spushd $FARCH/lib/vlc/plugins
  702. fi
  703. for i in `ls *.a | grep neon`
  704. do
  705. VLCNEONMODULES="$i $VLCNEONMODULES"
  706. done
  707. spopd # armv7/lib/vlc/plugins
  708. fi
  709. spopd # vlc-install-"$OSSTYLE"OS
  710. fi
  711. if [ -d ${VLCROOT}/install-"$OSSTYLE"Simulator ];then
  712. spushd ${VLCROOT}/install-"$OSSTYLE"Simulator
  713. for i in `ls .`
  714. do
  715. local iarch="`get_arch $i`"
  716. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  717. SIMULATORARCHS="$SIMULATORARCHS $iarch"
  718. fi
  719. done
  720. if (is_simulator_arch $arch);then
  721. echo "SIMU OS: $arch"
  722. spushd $arch/lib/vlc/plugins
  723. for i in `ls *.a`
  724. do
  725. VLCMODULES="$i $VLCMODULES"
  726. done
  727. spopd # $iarch/lib/vlc/plugins
  728. fi
  729. spopd # vlc-install-"$OSSTYLE"Simulator
  730. fi
  731. if [ "$OSSTYLE" = "MacOSX" ]; then
  732. if [ -d ${VLCROOT}/install-"$OSSTYLE" ];then
  733. spushd ${VLCROOT}/install-"$OSSTYLE"
  734. echo `pwd`
  735. echo "macOS: $arch"
  736. spushd $arch/lib/vlc/plugins
  737. for i in `ls *.a`
  738. do
  739. VLCMODULES="$i $VLCMODULES"
  740. done
  741. spopd # $actual_arch/lib/vlc/plugins
  742. spopd # vlc-install-"$OSSTYLE"
  743. fi
  744. fi
  745. spushd ${VLCROOT}
  746. # collect contrib libraries
  747. spushd contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  748. for i in `ls *.a`
  749. do
  750. CONTRIBLIBS="$i $CONTRIBLIBS"
  751. done
  752. spopd # contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  753. # lipo all the vlc libraries and its plugins
  754. if [ "$OSSTYLE" != "MacOSX" ]; then
  755. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  756. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  757. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  758. for i in $VLCMODULES
  759. do
  760. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  761. done
  762. # lipo contrib libraries
  763. for i in $CONTRIBLIBS
  764. do
  765. doContribLipo $i $OSSTYLE
  766. done
  767. if [ "$OSSTYLE" != "AppleTV" ]; then
  768. # lipo the remaining NEON plugins
  769. DEVICEARCHS=""
  770. for i in armv7 armv7s; do
  771. local iarch="`get_arch $i`"
  772. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  773. DEVICEARCHS="$DEVICEARCHS $iarch"
  774. fi
  775. done
  776. SIMULATORARCHS=""
  777. for i in $VLCNEONMODULES
  778. do
  779. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  780. done
  781. fi
  782. fi
  783. # create module list
  784. info "creating module list"
  785. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  786. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  787. # arm64 got the lowest number of modules
  788. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  789. LDFLAGS=""
  790. DEFINITIONS=""
  791. # add contrib libraries to LDFLAGS
  792. for file in $CONTRIBLIBS
  793. do
  794. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/contrib/$file "
  795. done
  796. for file in $VLCMODULES
  797. do
  798. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  799. entryname=$(get_symbol "$symbols" _)
  800. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  801. BUILTINS+=" $entryname,\n"
  802. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  803. info "...$entryname"
  804. done;
  805. # we only have ARM NEON modules for 32bit so this is limited to iOS
  806. if [ "$OSSTYLE" = "iPhone" ]; then
  807. BUILTINS+="#ifdef __arm__\n"
  808. DEFINITIONS+="#ifdef __arm__\n"
  809. for file in $VLCNEONMODULES
  810. do
  811. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  812. entryname=$(get_symbol "$symbols" _)
  813. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  814. BUILTINS+=" $entryname,\n"
  815. LDFLAGS+="${VLCROOT}/install-$OSSTYLE/plugins/$file "
  816. info "...$entryname"
  817. done;
  818. BUILTINS+="#endif\n"
  819. DEFINITIONS+="#endif\n"
  820. fi
  821. BUILTINS="$BUILTINS NULL\n};\n"
  822. echo "$DEFINITIONS\n$BUILTINS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  823. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" >> $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  824. spopd # vlc
  825. }
  826. while getopts "hvwsfbdxntlk:a:e:" OPTION
  827. do
  828. case $OPTION in
  829. h)
  830. usage
  831. exit 1
  832. ;;
  833. v)
  834. VERBOSE=yes
  835. ;;
  836. s)
  837. BUILD_DEVICE=no
  838. BUILD_SIMULATOR=yes
  839. BUILD_STATIC_FRAMEWORK=no
  840. ;;
  841. f)
  842. BUILD_DEVICE=yes
  843. BUILD_SIMULATOR=yes
  844. BUILD_STATIC_FRAMEWORK=yes
  845. ;;
  846. d) CONFIGURATION="Debug"
  847. DEBUG=yes
  848. ;;
  849. w) SCARY="no"
  850. ;;
  851. n)
  852. NONETWORK=yes
  853. ;;
  854. l)
  855. SKIPLIBVLCCOMPILATION=yes
  856. ;;
  857. k)
  858. SDK=$OPTARG
  859. ;;
  860. a)
  861. BUILD_DEVICE=yes
  862. BUILD_SIMULATOR=yes
  863. BUILD_STATIC_FRAMEWORK=yes
  864. FARCH=$OPTARG
  865. ;;
  866. b)
  867. BITCODE=yes
  868. ;;
  869. t)
  870. TVOS=yes
  871. IOS=no
  872. BITCODE=yes
  873. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  874. SDK_MIN=9.0
  875. OSVERSIONMINCFLAG=mtvos-version-min
  876. OSVERSIONMINLDFLAG=tvos_version_min
  877. ;;
  878. x)
  879. MACOS=yes
  880. IOS=no
  881. BITCODE=no
  882. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  883. SDK_MIN=10.9
  884. OSVERSIONMINCFLAG=mmacosx-version-min
  885. OSVERSIONMINLDFLAG=macosx_version_min
  886. BUILD_DEVICE=yes
  887. FARCH=x86_64
  888. BUILD_DYNAMIC_FRAMEWORK=yes
  889. BUILD_STATIC_FRAMEWORK=no
  890. ;;
  891. e)
  892. VLCROOT=$OPTARG
  893. ;;
  894. ?)
  895. usage
  896. exit 1
  897. ;;
  898. esac
  899. done
  900. shift $(($OPTIND - 1))
  901. out="/dev/null"
  902. if [ "$VERBOSE" = "yes" ]; then
  903. out="/dev/stdout"
  904. fi
  905. if [ "x$1" != "x" ]; then
  906. usage
  907. exit 1
  908. fi
  909. # Get root dir
  910. spushd .
  911. ROOT_DIR=`pwd`
  912. spopd
  913. if [ "$VLCROOT" = "" ]; then
  914. VLCROOT=${ROOT_DIR}/libvlc/vlc
  915. info "Preparing build dirs"
  916. mkdir -p libvlc
  917. spushd libvlc
  918. if [ "$NONETWORK" != "yes" ]; then
  919. if ! [ -e vlc ]; then
  920. git clone https://git.videolan.org/git/vlc/vlc-3.0.git vlc
  921. info "Applying patches to vlc.git"
  922. cd vlc
  923. git checkout -B localBranch ${TESTEDHASH}
  924. git branch --set-upstream-to=origin/master localBranch
  925. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  926. if [ $? -ne 0 ]; then
  927. git am --abort
  928. info "Applying the patches failed, aborting git-am"
  929. exit 1
  930. fi
  931. cd ..
  932. else
  933. cd vlc
  934. git pull --rebase
  935. git reset --hard ${TESTEDHASH}
  936. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  937. cd ..
  938. fi
  939. fi
  940. spopd
  941. fi
  942. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:${VLC_PATH}:/usr/bin:/bin:/usr/sbin:/sbin"
  943. echo `pwd`
  944. #
  945. # Build time
  946. #
  947. out="/dev/null"
  948. if [ "$VERBOSE" = "yes" ]; then
  949. out="/dev/stdout"
  950. fi
  951. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  952. info "Building tools"
  953. spushd ${VLCROOT}/extras/tools
  954. ./bootstrap
  955. make
  956. make .gas
  957. spopd #${VLCROOT}/extras/tools
  958. fi
  959. if [ "$BUILD_DEVICE" != "no" ]; then
  960. buildMobileKit iphoneos
  961. fi
  962. if [ "$BUILD_SIMULATOR" != "no" ]; then
  963. buildMobileKit iphonesimulator
  964. fi
  965. DEVICEARCHS=""
  966. SIMULATORARCHS=""
  967. if [ "$TVOS" = "yes" ]; then
  968. build_universal_static_lib "AppleTV"
  969. fi
  970. if [ "$MACOS" = "yes" ]; then
  971. build_universal_static_lib "MacOSX"
  972. fi
  973. if [ "$IOS" = "yes" ]; then
  974. build_universal_static_lib "iPhone"
  975. fi
  976. info "all done"
  977. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  978. if [ "$TVOS" = "yes" ]; then
  979. info "Building static TVVLCKit.framework"
  980. lipo_libs=""
  981. platform=""
  982. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  983. platform="appletvos"
  984. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  985. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  986. fi
  987. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  988. platform="appletvsimulator"
  989. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  990. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  991. fi
  992. # Assumes both platforms were built currently
  993. spushd build
  994. rm -rf TVVLCKit.framework && \
  995. mkdir TVVLCKit.framework && \
  996. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  997. chmod a+x TVVLCKit.framework/TVVLCKit && \
  998. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  999. spopd # build
  1000. info "Build of static TVVLCKit.framework completed"
  1001. fi
  1002. if [ "$IOS" = "yes" ]; then
  1003. info "Building static MobileVLCKit.framework"
  1004. lipo_libs=""
  1005. platform=""
  1006. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  1007. platform="iphoneos"
  1008. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1009. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  1010. fi
  1011. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  1012. platform="iphonesimulator"
  1013. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1014. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  1015. fi
  1016. # Assumes both platforms were built currently
  1017. spushd build
  1018. rm -rf MobileVLCKit.framework && \
  1019. mkdir MobileVLCKit.framework && \
  1020. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  1021. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  1022. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  1023. spopd # build
  1024. info "Build of static MobileVLCKit.framework completed"
  1025. fi
  1026. fi
  1027. if [ "$BUILD_DYNAMIC_FRAMEWORK" != "no" ]; then
  1028. if [ "$MACOS" = "yes" ]; then
  1029. info "Building VLCKit.framework"
  1030. buildxcodeproj VLCKit "VLCKit" "macosx"
  1031. # remove intermediate build result we don't need to keep
  1032. spushd build
  1033. rm ${CONFIGURATION}/libStaticLibVLC.a
  1034. spopd # build
  1035. info "Build of VLCKit.framework completed"
  1036. fi
  1037. fi