compileAndBuildVLCKit.sh 31 KB

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