当前位置:   article > 正文

IOS-libevent

ios libevent
  1. #!/bin/bash
  2. # Builds libevent for all five current iPhone targets: iPhoneSimulator-i386,
  3. # iPhoneSimulator-x86_64, iPhoneOS-armv7, iPhoneOS-armv7s, iPhoneOS-arm64.
  4. #
  5. # Copyright 2012-2016 Mike Tigas <mike AT tig DOT as>
  6. #
  7. # Based on "build-libssl.sh" in OpenSSL-for-iPhone by Felix Schulze,
  8. # forked on 2012-02-24. Original license follows:
  9. # Copyright 2010 Felix Schulze. All rights reserved.
  10. #
  11. # Licensed under the Apache License, Version 2.0 (the "License");
  12. # you may not use this file except in compliance with the License.
  13. # You may obtain a copy of the License at
  14. #
  15. # http://www.apache.org/licenses/LICENSE-2.0
  16. #
  17. # Unless required by applicable law or agreed to in writing, software
  18. # distributed under the License is distributed on an "AS IS" BASIS,
  19. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. # See the License for the specific language governing permissions and
  21. # limitations under the License.
  22. #
  23. ###########################################################################
  24. # Choose your libevent version and your currently-installed iOS SDK version:
  25. #
  26. VERSION="2.1.8-stable"
  27. USERSDKVERSION="10.3"
  28. MINIOSVERSION="8.0"
  29. VERIFYGPG=false
  30. ###########################################################################
  31. #
  32. # Don't change anything under this line!
  33. #
  34. ###########################################################################
  35. # No need to change this since xcode build will only compile in the
  36. # necessary bits from the libraries we create
  37. ARCHS="i386 x86_64 armv7 arm64"
  38. DEVELOPER=`xcode-select -print-path`
  39. #DEVELOPER="/Applications/Xcode.app/Contents/Developer"
  40. # for continuous integration
  41. # https://travis-ci.org/mtigas/iOS-OnionBrowser
  42. if [ "$1" == "--noverify" ]; then
  43. VERIFYGPG=false
  44. fi
  45. if [ "$2" == "--travis" ]; then
  46. ARCHS="i386 x86_64"
  47. fi
  48. if [[ ! -z "$TRAVIS" && $TRAVIS ]]; then
  49. # Travis CI highest available version
  50. echo "==================== TRAVIS CI ===================="
  51. SDKVERSION="10.3"
  52. else
  53. SDKVERSION="$USERSDKVERSION"
  54. fi
  55. cd "`dirname \"$0\"`"
  56. REPOROOT=$(pwd)
  57. # Where we'll end up storing things in the end
  58. OUTPUTDIR="${REPOROOT}/dependencies"
  59. mkdir -p ${OUTPUTDIR}/include
  60. mkdir -p ${OUTPUTDIR}/lib
  61. BUILDDIR="${REPOROOT}/build"
  62. # where we will keep our sources and build from.
  63. SRCDIR="${BUILDDIR}/src"
  64. mkdir -p $SRCDIR
  65. # where we will store intermediary builds
  66. INTERDIR="${BUILDDIR}/built"
  67. mkdir -p $INTERDIR
  68. ########################################
  69. cd $SRCDIR
  70. # Exit the script if an error happens
  71. set -e
  72. if [ ! -e "${SRCDIR}/libevent-${VERSION}.tar.gz" ]; then
  73. echo "Downloading libevent-${VERSION}.tar.gz"
  74. curl -LO https://github.com/libevent/libevent/releases/download/release-${VERSION}/libevent-${VERSION}.tar.gz
  75. fi
  76. echo "Using libevent-${VERSION}.tar.gz"
  77. # up to you to set up `gpg` and add keys to your keychain
  78. # may have to import from link on http://www.wangafu.net/~nickm/ or http://www.citi.umich.edu/u/provos/
  79. if $VERIFYGPG; then
  80. if [ ! -e "${SRCDIR}/libevent-${VERSION}.tar.gz.asc" ]; then
  81. curl -LO https://github.com/libevent/libevent/releases/download/release-${VERSION}/libevent-${VERSION}.tar.gz.asc
  82. fi
  83. echo "Using libevent-${VERSION}.tar.gz.asc"
  84. if out=$(gpg --status-fd 1 --verify "libevent-${VERSION}.tar.gz.asc" "libevent-${VERSION}.tar.gz" 2>/dev/null) &&
  85. echo "$out" | grep -qs "^\[GNUPG:\] VALIDSIG"; then
  86. echo "$out" | egrep "GOODSIG|VALIDSIG"
  87. echo "Verified GPG signature for source..."
  88. else
  89. echo "$out" >&2
  90. echo "COULD NOT VERIFY PACKAGE SIGNATURE..."
  91. exit 1
  92. fi
  93. fi
  94. if [ ! -d "${SRCDIR}/libevent-${VERSION}" ]; then
  95. echo 文件不存在
  96. tar zxf libevent-${VERSION}.tar.gz -C $SRCDIR
  97. fi
  98. cd "${SRCDIR}/libevent-${VERSION}"
  99. set +e # don't bail out of bash script if ccache doesn't exist
  100. CCACHE=`which ccache`
  101. if [ $? == "0" ]; then
  102. echo "Building with ccache: $CCACHE"
  103. CCACHE="${CCACHE} "
  104. else
  105. echo "Building without ccache"
  106. CCACHE=""
  107. fi
  108. set -e # back to regular "bail out on error" mode
  109. export ORIGINALPATH=$PATH
  110. for ARCH in ${ARCHS}
  111. do
  112. if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];
  113. then
  114. PLATFORM="iPhoneSimulator"
  115. EXTRA_CONFIG="--host=x86_64-apple-darwin"
  116. else
  117. PLATFORM="iPhoneOS"
  118. EXTRA_CONFIG="--host=arm-apple-darwin"
  119. fi
  120. mkdir -p "${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
  121. export PATH="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/:${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/usr/bin/:${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin:${DEVELOPER}/usr/bin:${ORIGINALPATH}"
  122. export CC="${CCACHE}`which gcc` -arch ${ARCH} -miphoneos-version-min=${MINIOSVERSION} -fembed-bitcode"
  123. ./configure --disable-shared --enable-static --disable-debug-mode --disable-openssl --disable-clock-gettime ${EXTRA_CONFIG} \
  124. --prefix="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" \
  125. LDFLAGS="$LDFLAGS -L${OUTPUTDIR}/lib" \
  126. CFLAGS="$CFLAGS -Os -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk" \
  127. CPPFLAGS="$CPPFLAGS -I${OUTPUTDIR}/include -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDKVERSION}.sdk"
  128. # Build the application and install it to the fake SDK intermediary dir
  129. # we have set up. Make sure to clean up afterward because we will re-use
  130. # this source tree to cross-compile other targets.
  131. make -j$(sysctl hw.ncpu | awk '{print $2}')
  132. make install
  133. make clean
  134. done
  135. ########################################
  136. echo "Build library..."
  137. # These are the libs that comprise libevent. `libevent_openssl` and `libevent_pthreads`
  138. # may not be compiled if those dependencies aren't available.
  139. OUTPUT_LIBS="libevent.a libevent_core.a libevent_extra.a libevent_openssl.a libevent_pthreads.a"
  140. for OUTPUT_LIB in ${OUTPUT_LIBS}; do
  141. INPUT_LIBS=""
  142. for ARCH in ${ARCHS}; do
  143. if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];
  144. then
  145. PLATFORM="iPhoneSimulator"
  146. else
  147. PLATFORM="iPhoneOS"
  148. fi
  149. INPUT_ARCH_LIB="${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/lib/${OUTPUT_LIB}"
  150. if [ -e $INPUT_ARCH_LIB ]; then
  151. INPUT_LIBS="${INPUT_LIBS} ${INPUT_ARCH_LIB}"
  152. fi
  153. done
  154. # Combine the three architectures into a universal library.
  155. if [ -n "$INPUT_LIBS" ]; then
  156. lipo -create $INPUT_LIBS \
  157. -output "${OUTPUTDIR}/lib/${OUTPUT_LIB}"
  158. else
  159. echo "$OUTPUT_LIB does not exist, skipping (are the dependencies installed?)"
  160. fi
  161. done
  162. for ARCH in ${ARCHS}; do
  163. if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ];
  164. then
  165. PLATFORM="iPhoneSimulator"
  166. else
  167. PLATFORM="iPhoneOS"
  168. fi
  169. cp -R ${INTERDIR}/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/include/* ${OUTPUTDIR}/include/
  170. if [ $? == "0" ]; then
  171. # We only need to copy the headers over once. (So break out of forloop
  172. # once we get first success.)
  173. break
  174. fi
  175. done
  176. ####################
  177. echo "Building done."
  178. echo "Cleaning up..."
  179. rm -fr ${INTERDIR}
  180. #rm -fr "${SRCDIR}/libevent-${VERSION}"
  181. echo "Done."

需要修改 USERSDKVERSION="10.3"

转载于:https://my.oschina.net/u/814319/blog/1524547

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/742821
推荐阅读
相关标签
  

闽ICP备14008679号