PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/bin/build_thirdparty.sh

https://gitlab.com/s9perween/Impala
Shell | 236 lines | 171 code | 21 blank | 44 comment | 28 complexity | b7b1a2791cb89c88c3a76e51b9c6690a MD5 | raw file
  1. #!/usr/bin/env bash
  2. # Copyright 2012 Cloudera Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # cleans and rebuilds thirdparty/. The Impala build environment must be set up
  16. # by bin/impala-config.sh before running this script.
  17. # Exit on non-true return value
  18. set -e
  19. # Exit on reference to unitialized variable
  20. set -u
  21. # By default, git clean every library we build
  22. CLEAN_ACTION=1
  23. # By default, build every library
  24. BUILD_ALL=1
  25. # If BUILD_ALL -eq 1, these are ignored, otherwise only build those libaries with
  26. # BUILD_<lib> -eq 1
  27. BUILD_AVRO=0
  28. BUILD_THRIFT=0
  29. BUILD_GLOG=0
  30. BUILD_GFLAGS=0
  31. BUILD_GTEST=0
  32. BUILD_RE2=0
  33. BUILD_SASL=0
  34. BUILD_LDAP=0
  35. BUILD_SNAPPY=0
  36. BUILD_PPROF=0
  37. BUILD_CDH4EXTRAS=0
  38. for ARG in $*
  39. do
  40. case "$ARG" in
  41. -noclean)
  42. CLEAN_ACTION=0
  43. ;;
  44. -avro)
  45. BUILD_ALL=0
  46. BUILD_AVRO=1
  47. ;;
  48. -glog)
  49. BUILD_ALL=0
  50. BUILD_GLOG=1
  51. ;;
  52. -thrift)
  53. BUILD_ALL=0
  54. BUILD_THRIFT=1
  55. ;;
  56. -gflags)
  57. BUILD_ALL=0
  58. BUILD_GFLAGS=1
  59. ;;
  60. -gtest)
  61. BUILD_ALL=0
  62. BUILD_GTEST=1
  63. ;;
  64. -re2)
  65. BUILD_ALL=0
  66. BUILD_RE2=1
  67. ;;
  68. -sasl)
  69. BUILD_ALL=0
  70. BUILD_SASL=1
  71. ;;
  72. -ldap)
  73. BUILD_ALL=0
  74. BUILD_LDAP=1
  75. ;;
  76. -snappy)
  77. BUILD_ALL=0
  78. BUILD_SNAPPY=1
  79. ;;
  80. -pprof)
  81. BUILD_ALL=0
  82. BUILD_PPROF=1
  83. ;;
  84. -cdh4extras)
  85. BUILD_ALL=0
  86. BUILD_CDH4EXTRAS=1
  87. ;;
  88. -*)
  89. echo "Usage: build_thirdparty.sh [-noclean] \
  90. [-avro -glog -thrift -gflags -gtest -re2 -sasl -ldap -snappy -pprof -cdh4extras]"
  91. exit 1
  92. esac
  93. done
  94. bin=`dirname "$0"`
  95. bin=`cd "$bin"; pwd`
  96. . "$bin"/impala-config.sh
  97. USE_PIC_LIB_PATH=${PIC_LIB_PATH:-}
  98. function build_preamble() {
  99. echo
  100. echo
  101. echo "********************************************************************************"
  102. echo "Building $2 in $1 $([ $CLEAN_ACTION -eq 1 ] && echo '(clean)')"
  103. echo "********************************************************************************"
  104. cd $1
  105. if [ $CLEAN_ACTION -eq 1 ]; then
  106. # remove everything that is not checked in
  107. git clean -dfx
  108. fi
  109. }
  110. # build thrift
  111. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_THRIFT -eq 1 ]; then
  112. cd ${THRIFT_SRC_DIR}
  113. build_preamble ${THRIFT_SRC_DIR} "Thrift"
  114. if [ -d "${PIC_LIB_PATH:-}" ]; then
  115. PIC_LIB_OPTIONS="--with-zlib=${PIC_LIB_PATH} "
  116. fi
  117. JAVA_PREFIX=${THRIFT_HOME}/java PY_PREFIX=${THRIFT_HOME}/python \
  118. ./configure --with-pic --prefix=${THRIFT_HOME} \
  119. --with-php=no --with-java=no --with-perl=no --with-erlang=no \
  120. --with-ruby=no --with-haskell=no --with-erlang=no --with-d=no \
  121. --with-qt4=no --with-libevent=no ${PIC_LIB_OPTIONS:-}
  122. make # Make with -j fails
  123. make install
  124. cd ${THRIFT_SRC_DIR}/contrib/fb303
  125. chmod 755 ./bootstrap.sh
  126. ./bootstrap.sh
  127. chmod 755 configure
  128. CPPFLAGS="-I${THRIFT_HOME}/include" PY_PREFIX=${THRIFT_HOME}/python ./configure \
  129. --prefix=${THRIFT_HOME} --with-thriftpath=${THRIFT_HOME}
  130. make
  131. make install
  132. fi
  133. # build gflags
  134. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_GFLAGS -eq 1 ]; then
  135. build_preamble $IMPALA_HOME/thirdparty/gflags-${IMPALA_GFLAGS_VERSION} GFlags
  136. GFLAGS_INSTALL=`pwd`/third-party-install
  137. ./configure --with-pic --prefix=${GFLAGS_INSTALL}
  138. make -j4 install
  139. fi
  140. # Build pprof
  141. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_PPROF -eq 1 ]; then
  142. build_preamble $IMPALA_HOME/thirdparty/gperftools-${IMPALA_GPERFTOOLS_VERSION} \
  143. GPerftools
  144. # TODO: google perf tools indicates this might be necessary on 64 bit systems.
  145. # we're not compiling the rest of our code to not omit frame pointers but it
  146. # still seems to generate useful profiling data.
  147. ./configure --enable-frame-pointers --with-pic
  148. make -j4
  149. fi
  150. # Build glog
  151. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_GLOG -eq 1 ]; then
  152. build_preamble $IMPALA_HOME/thirdparty/glog-${IMPALA_GLOG_VERSION} GLog
  153. ./configure --with-pic --with-gflags=${GFLAGS_INSTALL}
  154. # SLES's gcc45-c++ is required for sse2 support (default is 4.3), but crashes
  155. # when building logging_unittest-logging_unittest.o. Telling it to uses the
  156. # stabs format for debugging symbols instead of dwarf exercises a different
  157. # code path to work around this issue.
  158. cat > Makefile.gcc45sles_workaround <<EOF
  159. logging_unittest-logging_unittest.o : CXXFLAGS= -gstabs -O2
  160. EOF
  161. cat Makefile >> Makefile.gcc45sles_workaround
  162. mv Makefile.gcc45sles_workaround Makefile
  163. make -j4
  164. fi
  165. # Build gtest
  166. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_GTEST -eq 1 ]; then
  167. build_preamble $IMPALA_HOME/thirdparty/gtest-${IMPALA_GTEST_VERSION} GTest
  168. cmake .
  169. make -j4
  170. fi
  171. # Build Snappy
  172. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_SNAPPY -eq 1 ]; then
  173. build_preamble $IMPALA_HOME/thirdparty/snappy-${IMPALA_SNAPPY_VERSION} Snappy
  174. ./configure --with-pic --prefix=$IMPALA_HOME/thirdparty/snappy-${IMPALA_SNAPPY_VERSION}/build
  175. make install
  176. fi
  177. # Build re2
  178. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_RE2 -eq 1 ]; then
  179. build_preamble $IMPALA_HOME/thirdparty/re2 RE2
  180. make -j4
  181. fi
  182. # Build Ldap
  183. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_LDAP -eq 1 ]; then
  184. build_preamble $IMPALA_HOME/thirdparty/openldap-${IMPALA_OPENLDAP_VERSION} Openldap
  185. ./configure --enable-slapd=no --prefix=`pwd`/install --enable-static --with-pic
  186. make -j4
  187. make -j4 depend
  188. make install
  189. fi
  190. # Build Sasl
  191. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_SASL -eq 1 ]; then
  192. if [ -z "$USE_PIC_LIB_PATH" ]; then
  193. build_preamble $IMPALA_HOME/thirdparty/cyrus-sasl-${IMPALA_CYRUS_SASL_VERSION} Sasl
  194. # Disable everything except those protocols needed -- currently just Kerberos.
  195. # Sasl does not have a --with-pic configuration.
  196. CFLAGS="-fPIC -DPIC" CXXFLAGS="-fPIC -DPIC" ./configure \
  197. --disable-sql --disable-otp --disable-ldap --disable-digest --with-saslauthd=no \
  198. --prefix=$IMPALA_HOME/thirdparty/cyrus-sasl-${IMPALA_CYRUS_SASL_VERSION}/build \
  199. --enable-static --enable-staticdlopen
  200. # the first time you do a make it fails, ignore the error.
  201. (make || true)
  202. make install
  203. fi
  204. fi
  205. # Build Avro
  206. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_AVRO -eq 1 ]; then
  207. build_preamble $IMPALA_HOME/thirdparty/avro-c-${IMPALA_AVRO_VERSION} Avro
  208. cmake .
  209. make -j4
  210. fi
  211. # Build cdh4-extras
  212. if [ $BUILD_ALL -eq 1 ] || [ $BUILD_CDH4EXTRAS -eq 1 ]; then
  213. build_preamble $IMPALA_HOME/thirdparty/cdh4-extras cdh4-extras
  214. mvn package -DskipTests
  215. fi