buildMobileVLCKit.sh 4.3 KB

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