ulib.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/bash
  2. RETCODE=$(fw_exists ${IROOT}/ulib.installed)
  3. [ ! "$RETCODE" == 0 ] || { \
  4. source $IROOT/ulib.installed
  5. return 0; }
  6. ULIB_VERSION=1.4.2
  7. ULIB_ROOT=$IROOT/ULib
  8. ULIB_DOCUMENT_ROOT=$ULIB_ROOT/ULIB_DOCUMENT_ROOT
  9. # Create a run directory for ULIB
  10. [ ! -e $IROOT/ulib.installed -a -d $IROOT/ULib ] && rm -rf $IROOT/ULib*
  11. if [ ! -d "$ULIB_ROOT" ]; then
  12. mkdir -p $ULIB_ROOT
  13. fi
  14. # AVOID "fatal error: postgres_fe.h: No such file or directory"
  15. # TODO: This should already be installed and unnecessary.
  16. sudo apt-get install -y postgresql-server-dev-all
  17. # make use of FIFO scheduling policy possible
  18. type setcap >/dev/null 2>/dev/null
  19. if [ $? -ne 0 ]; then
  20. sudo apt-get install -y libcap2-bin
  21. fi
  22. # Add a simple configuration file to it
  23. cd $ULIB_ROOT
  24. if [ ! -f "benchmark.cfg" ]; then
  25. cat <<EOF >benchmark.cfg
  26. userver {
  27. PORT 8080
  28. PREFORK_CHILD 4
  29. TCP_LINGER_SET -1
  30. LISTEN_BACKLOG 256
  31. ORM_DRIVER "mysql pgsql sqlite"
  32. DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
  33. }
  34. EOF
  35. fi
  36. # 1. Download ULib
  37. cd $IROOT
  38. fw_get -o ULib-${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz
  39. fw_untar ULib-${ULIB_VERSION}.tar.gz
  40. # 2. Compile application (userver_tcp)
  41. cd ULib-$ULIB_VERSION
  42. # Check for the compiler support (We want at least g++ 4.8)
  43. CC=gcc # C compiler command
  44. CXX=g++ # C++ compiler command
  45. gcc_version=`g++ -dumpversion`
  46. case "$gcc_version" in
  47. 3*|4.0*|4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*)
  48. CC='gcc-4.9'
  49. CXX='g++-4.9'
  50. ;;
  51. esac
  52. export CC CXX
  53. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  54. find . -exec touch {} \;
  55. USP_FLAGS="-DAS_cpoll_cppsp_DO" \
  56. ./configure --prefix=$ULIB_ROOT \
  57. --disable-static --disable-examples \
  58. --with-mysql --with-pgsql --with-sqlite3 \
  59. --without-ssl --without-pcre --without-expat \
  60. --without-libz --without-libuuid --without-magic --without-libares \
  61. --enable-static-orm-driver='mysql pgsql sqlite' --enable-static-server-plugin=http
  62. # --enable-debug \
  63. #USP_LIBS="-ljson" \
  64. make install
  65. cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
  66. cd examples/userver
  67. make install
  68. # 3. Compile usp pages for benchmark
  69. cd ../../src/ulib/net/server/plugin/usp
  70. make db.la fortune.la json.la plaintext.la query.la update.la rdb.la rquery.la rupdate.la rfortune.la
  71. # Check that compilation worked
  72. if [ ! -e .libs/db.so ]; then
  73. exit 1
  74. fi
  75. mkdir -p $ULIB_DOCUMENT_ROOT
  76. cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so .libs/rdb.so .libs/rquery.so .libs/rupdate.so .libs/rfortune.so $ULIB_DOCUMENT_ROOT
  77. echo "export ULIB_VERSION=${ULIB_VERSION}" >> $IROOT/ulib.installed
  78. echo "export ULIB_ROOT=${ULIB_ROOT}" >> $IROOT/ulib.installed
  79. echo "export ULIB_DOCUMENT_ROOT=${ULIB_DOCUMENT_ROOT}" >> $IROOT/ulib.installed
  80. echo -e "export PATH=\$ULIB_ROOT/bin:\$PATH" >> $IROOT/ulib.installed
  81. source $IROOT/ulib.installed