buildMobileVLCKit.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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=57c046ce1
  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. xcodebuild -project "$1.xcodeproj" \
  53. -target "$target" \
  54. -sdk $PLATFORM$SDK \
  55. -configuration ${CONFIGURATION} \
  56. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} > ${out}
  57. }
  58. while getopts "hvwsfdnlk:" OPTION
  59. do
  60. case $OPTION in
  61. h)
  62. usage
  63. exit 1
  64. ;;
  65. v)
  66. VERBOSE=yes
  67. ;;
  68. s)
  69. BUILD_DEVICE=no
  70. BUILD_SIMULATOR=yes
  71. BUILD_FRAMEWORK=no
  72. ;;
  73. f)
  74. BUILD_DEVICE=yes
  75. BUILD_SIMULATOR=yes
  76. BUILD_FRAMEWORK=yes
  77. ;;
  78. d) CONFIGURATION="Debug"
  79. ;;
  80. w) SCARY="no"
  81. ;;
  82. n)
  83. NONETWORK=yes
  84. ;;
  85. l)
  86. SKIPLIBVLCCOMPILATION=yes
  87. ;;
  88. k)
  89. SDK=$OPTARG
  90. ;;
  91. ?)
  92. usage
  93. exit 1
  94. ;;
  95. esac
  96. done
  97. shift $(($OPTIND - 1))
  98. out="/dev/null"
  99. if [ "$VERBOSE" = "yes" ]; then
  100. out="/dev/stdout"
  101. fi
  102. if [ "x$1" != "x" ]; then
  103. usage
  104. exit 1
  105. fi
  106. # Get root dir
  107. spushd .
  108. aspen_root_dir=`pwd`
  109. spopd
  110. info "Preparing build dirs"
  111. mkdir -p MobileVLCKit/ImportedSources
  112. spushd MobileVLCKit/ImportedSources
  113. if [ "$NONETWORK" != "yes" ]; then
  114. if ! [ -e vlc ]; then
  115. git clone git://git.videolan.org/vlc/vlc-2.2.git vlc
  116. info "Applying patches to vlc-2.2.git"
  117. cd vlc
  118. git checkout -B localBranch ${TESTEDHASH}
  119. git branch --set-upstream-to=origin/master localBranch
  120. git am ../../patches/*.patch
  121. if [ $? -ne 0 ]; then
  122. git am --abort
  123. info "Applying the patches failed, aborting git-am"
  124. exit 1
  125. fi
  126. cd ..
  127. else
  128. cd vlc
  129. git reset --hard ${TESTEDHASH}
  130. git am ../../patches/*.patch
  131. cd ..
  132. fi
  133. fi
  134. spopd
  135. #
  136. # Build time
  137. #
  138. buildMobileKit() {
  139. PLATFORM="$1"
  140. info "Building for $PLATFORM"
  141. spushd MobileVLCKit/ImportedSources
  142. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  143. spushd vlc/extras/package/ios
  144. info "Building vlc"
  145. args=""
  146. if [ "$VERBOSE" = "yes" ]; then
  147. args="${args} -v"
  148. fi
  149. if [ "$CONFIGURATION" = "Debug" ]; then
  150. args="${args} -d"
  151. fi
  152. if [ "$SCARY" = "no" ]; then
  153. args="${args} -w"
  154. fi
  155. if [ "$PLATFORM" = "iphonesimulator" ]; then
  156. args="${args} -s"
  157. ./build.sh -a i386 ${args} -k "${SDK}" && ./build.sh -a x86_64 ${args} -k "${SDK}"
  158. else
  159. ./build.sh -a armv7 ${args} -k "${SDK}" && ./build.sh -a armv7s ${args} -k "${SDK}" && ./build.sh -a arm64 ${args} -k "${SDK}"
  160. fi
  161. spopd
  162. fi
  163. spopd # MobileVLCKit/ImportedSources
  164. buildxcodeproj MobileVLCKit "Aggregate static plugins"
  165. buildxcodeproj MobileVLCKit "MobileVLCKit"
  166. info "Build for $PLATFORM completed"
  167. }
  168. if [ "$BUILD_DEVICE" != "no" ]; then
  169. buildMobileKit iphoneos
  170. fi
  171. if [ "$BUILD_SIMULATOR" != "no" ]; then
  172. buildMobileKit iphonesimulator
  173. fi
  174. if [ "$BUILD_FRAMEWORK" != "no" ]; then
  175. info "Building MobileVLCKit.framework"
  176. # Assumes both platforms were built currently
  177. spushd build
  178. rm -rf MobileVLCKit.framework && \
  179. mkdir MobileVLCKit.framework && \
  180. lipo -create Release-iphoneos/libMobileVLCKit.a \
  181. Release-iphonesimulator/libMobileVLCKit.a \
  182. -o MobileVLCKit.framework/MobileVLCKit && \
  183. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  184. cp -pr Release-iphoneos/include/MobileVLCKit MobileVLCKit.framework/Headers
  185. spopd # build
  186. info "Build of MobileVLCKit.framework completed"
  187. fi