buildMobileVLCKit.sh 4.2 KB

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