buildMobileVLCKit.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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=7.0
  10. VERBOSE=no
  11. CONFIGURATION="Release"
  12. NONETWORK=no
  13. SKIPLIBVLCCOMPILATION=no
  14. SCARY=yes
  15. TESTEDHASH=fe65f5106
  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.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 pull --rebase
  136. git reset --hard ${TESTEDHASH}
  137. git am ../../patches/*.patch
  138. cd ..
  139. fi
  140. fi
  141. spopd
  142. #
  143. # Build time
  144. #
  145. buildMobileKit() {
  146. PLATFORM="$1"
  147. info "Building for $PLATFORM"
  148. spushd MobileVLCKit/ImportedSources
  149. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  150. spushd vlc/extras/package/ios
  151. info "Building vlc"
  152. args=""
  153. if [ "$VERBOSE" = "yes" ]; then
  154. args="${args} -v"
  155. fi
  156. if [ "$CONFIGURATION" = "Debug" ]; then
  157. args="${args} -d"
  158. fi
  159. if [ "$SCARY" = "no" ]; then
  160. args="${args} -w"
  161. fi
  162. if [ "$PLATFORM" = "iphonesimulator" ]; then
  163. args="${args} -s"
  164. ./build.sh -a i386 ${args} -k "${SDK}" && ./build.sh -a x86_64 ${args} -k "${SDK}"
  165. else
  166. ./build.sh -a armv7 ${args} -k "${SDK}" && ./build.sh -a armv7s ${args} -k "${SDK}" && ./build.sh -a aarch64 ${args} -k "${SDK}"
  167. fi
  168. spopd
  169. fi
  170. spopd # MobileVLCKit/ImportedSources
  171. buildxcodeproj MobileVLCKit "Aggregate static plugins"
  172. buildxcodeproj MobileVLCKit "MobileVLCKit"
  173. info "Build for $PLATFORM completed"
  174. }
  175. if [ "$BUILD_DEVICE" != "no" ]; then
  176. buildMobileKit iphoneos
  177. fi
  178. if [ "$BUILD_SIMULATOR" != "no" ]; then
  179. buildMobileKit iphonesimulator
  180. fi
  181. if [ "$BUILD_FRAMEWORK" != "no" ]; then
  182. info "Building MobileVLCKit.framework"
  183. # Assumes both platforms were built currently
  184. spushd build
  185. rm -rf MobileVLCKit.framework && \
  186. mkdir MobileVLCKit.framework && \
  187. lipo -create Release-iphoneos/libMobileVLCKit.a \
  188. Release-iphonesimulator/libMobileVLCKit.a \
  189. -o MobileVLCKit.framework/MobileVLCKit && \
  190. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  191. cp -pr Release-iphoneos/include/MobileVLCKit MobileVLCKit.framework/Headers
  192. spopd # build
  193. info "Build of MobileVLCKit.framework completed"
  194. fi