buildMobileVLCKit.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #!/bin/sh
  2. # Copyright (C) Pierre d'Herbemont, 2010
  3. # Copyright (C) Felix Paul Kühne, 2012-2013
  4. set -e
  5. BUILD_DEVICE=yes
  6. BUILD_SIMULATOR=no
  7. BUILD_FRAMEWORK=no
  8. SDK=`xcrun --sdk iphoneos --show-sdk-version`
  9. SDK_MIN=6.1
  10. VERBOSE=no
  11. CONFIGURATION="Release"
  12. NONETWORK=no
  13. SKIPLIBVLCCOMPILATION=no
  14. SCARY=yes
  15. TESTEDHASH=2a445ee73c
  16. usage()
  17. {
  18. cat << EOF
  19. usage: $0 [-s] [-v] [-k sdk]
  20. OPTIONS
  21. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  22. -v Be more verbose
  23. -s Build for simulator
  24. -f Build framework for device and simulator
  25. -d Enable Debug
  26. -n Skip script steps requiring network interaction
  27. -l Skip libvlc compilation
  28. -w Build a limited stack of non-scary libraries only
  29. EOF
  30. }
  31. spushd()
  32. {
  33. pushd "$1" 2>&1> /dev/null
  34. }
  35. spopd()
  36. {
  37. popd 2>&1> /dev/null
  38. }
  39. info()
  40. {
  41. local green="\033[1;32m"
  42. local normal="\033[0m"
  43. echo "[${green}info${normal}] $1"
  44. }
  45. buildxcodeproj()
  46. {
  47. local target="$2"
  48. if [ "x$target" = "x" ]; then
  49. target="$1"
  50. fi
  51. info "Building $1 ($target, ${CONFIGURATION})"
  52. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  53. if [ "$SCARY" = "no" ]; then
  54. defs="$defs NOSCARYCODECS"
  55. fi
  56. xcodebuild -project "$1.xcodeproj" \
  57. -target "$target" \
  58. -sdk $PLATFORM$SDK \
  59. -configuration ${CONFIGURATION} \
  60. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  61. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  62. > ${out}
  63. }
  64. while getopts "hvwsfdnlk:" OPTION
  65. do
  66. case $OPTION in
  67. h)
  68. usage
  69. exit 1
  70. ;;
  71. v)
  72. VERBOSE=yes
  73. ;;
  74. s)
  75. BUILD_DEVICE=no
  76. BUILD_SIMULATOR=yes
  77. BUILD_FRAMEWORK=no
  78. ;;
  79. f)
  80. BUILD_DEVICE=yes
  81. BUILD_SIMULATOR=yes
  82. BUILD_FRAMEWORK=yes
  83. ;;
  84. d) CONFIGURATION="Debug"
  85. ;;
  86. w) SCARY="no"
  87. ;;
  88. n)
  89. NONETWORK=yes
  90. ;;
  91. l)
  92. SKIPLIBVLCCOMPILATION=yes
  93. ;;
  94. k)
  95. SDK=$OPTARG
  96. ;;
  97. ?)
  98. usage
  99. exit 1
  100. ;;
  101. esac
  102. done
  103. shift $(($OPTIND - 1))
  104. out="/dev/null"
  105. if [ "$VERBOSE" = "yes" ]; then
  106. out="/dev/stdout"
  107. fi
  108. if [ "x$1" != "x" ]; then
  109. usage
  110. exit 1
  111. fi
  112. # Get root dir
  113. spushd .
  114. aspen_root_dir=`pwd`
  115. spopd
  116. info "Preparing build dirs"
  117. mkdir -p MobileVLCKit/ImportedSources
  118. spushd MobileVLCKit/ImportedSources
  119. if [ "$NONETWORK" != "yes" ]; then
  120. if ! [ -e vlc ]; then
  121. git clone git://git.videolan.org/vlc.git vlc
  122. info "Applying patches to vlc-2.2.git"
  123. cd vlc
  124. git checkout -B localBranch ${TESTEDHASH}
  125. git branch --set-upstream-to=origin/master localBranch
  126. git am ../../patches/*.patch
  127. if [ $? -ne 0 ]; then
  128. git am --abort
  129. info "Applying the patches failed, aborting git-am"
  130. exit 1
  131. fi
  132. cd ..
  133. else
  134. cd vlc
  135. git reset --hard ${TESTEDHASH}
  136. git am ../../patches/*.patch
  137. cd ..
  138. fi
  139. fi
  140. spopd
  141. #
  142. # Build time
  143. #
  144. buildMobileKit() {
  145. PLATFORM="$1"
  146. info "Building for $PLATFORM"
  147. spushd MobileVLCKit/ImportedSources
  148. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  149. spushd vlc/extras/package/ios
  150. info "Building vlc"
  151. args=""
  152. if [ "$VERBOSE" = "yes" ]; then
  153. args="${args} -v"
  154. fi
  155. if [ "$CONFIGURATION" = "Debug" ]; then
  156. args="${args} -d"
  157. fi
  158. if [ "$SCARY" = "no" ]; then
  159. args="${args} -w"
  160. fi
  161. if [ "$PLATFORM" = "iphonesimulator" ]; then
  162. args="${args} -s"
  163. ./build.sh -a i386 ${args} -k "${SDK}" && ./build.sh -a x86_64 ${args} -k "${SDK}"
  164. else
  165. ./build.sh -a armv7 ${args} -k "${SDK}" && ./build.sh -a armv7s ${args} -k "${SDK}" && ./build.sh -a aarch64 ${args} -k "${SDK}"
  166. fi
  167. spopd
  168. fi
  169. spopd # MobileVLCKit/ImportedSources
  170. buildxcodeproj MobileVLCKit "Aggregate static plugins"
  171. buildxcodeproj MobileVLCKit "MobileVLCKit"
  172. info "Build for $PLATFORM completed"
  173. }
  174. if [ "$BUILD_DEVICE" != "no" ]; then
  175. buildMobileKit iphoneos
  176. fi
  177. if [ "$BUILD_SIMULATOR" != "no" ]; then
  178. buildMobileKit iphonesimulator
  179. fi
  180. if [ "$BUILD_FRAMEWORK" != "no" ]; then
  181. info "Building MobileVLCKit.framework"
  182. # Assumes both platforms were built currently
  183. spushd build
  184. rm -rf MobileVLCKit.framework && \
  185. mkdir MobileVLCKit.framework && \
  186. lipo -create Release-iphoneos/libMobileVLCKit.a \
  187. Release-iphonesimulator/libMobileVLCKit.a \
  188. -o MobileVLCKit.framework/MobileVLCKit && \
  189. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  190. cp -pr Release-iphoneos/include/MobileVLCKit MobileVLCKit.framework/Headers
  191. spopd # build
  192. info "Build of MobileVLCKit.framework completed"
  193. fi