ulib.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. # Add a simple configuration file to it
  18. cd $ULIB_ROOT
  19. if [ ! -f "benchmark.cfg" ]; then
  20. cat <<EOF >benchmark.cfg
  21. userver {
  22. PORT 8080
  23. PREFORK_CHILD 4
  24. TCP_LINGER_SET -1
  25. LISTEN_BACKLOG 256
  26. ORM_DRIVER "mysql pgsql sqlite"
  27. DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
  28. }
  29. EOF
  30. fi
  31. # 1. Download ULib
  32. cd $IROOT
  33. fw_get -o ULib-${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz
  34. fw_untar ULib-${ULIB_VERSION}.tar.gz
  35. # 2. Compile application (userver_tcp)
  36. cd ULib-$ULIB_VERSION
  37. # Check for the compiler support (We want at least g++ 4.8)
  38. CC=gcc # C compiler command
  39. CXX=g++ # C++ compiler command
  40. gcc_version=`g++ -dumpversion`
  41. case "$gcc_version" in
  42. 3*|4.0*|4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*)
  43. CC='gcc-4.9'
  44. CXX='g++-4.9'
  45. ;;
  46. esac
  47. export CC CXX
  48. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  49. find . -exec touch {} \;
  50. USP_FLAGS="-DAS_cpoll_cppsp_DO" \
  51. ./configure --prefix=$ULIB_ROOT \
  52. --disable-static --disable-examples \
  53. --with-mysql --with-pgsql --with-sqlite3 \
  54. --without-ssl --without-pcre --without-expat \
  55. --without-libz --without-libuuid --without-magic --without-libares \
  56. --enable-static-orm-driver='mysql pgsql sqlite' --enable-static-server-plugin=http
  57. # --enable-debug \
  58. #USP_LIBS="-ljson" \
  59. make install
  60. cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
  61. cd examples/userver
  62. make install
  63. # 3. Compile usp pages for benchmark
  64. cd ../../src/ulib/net/server/plugin/usp
  65. make db.la fortune.la json.la plaintext.la query.la update.la
  66. # Check that compilation worked
  67. if [ ! -e .libs/db.so ]; then
  68. exit 1
  69. fi
  70. mkdir -p $ULIB_DOCUMENT_ROOT
  71. cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so $ULIB_DOCUMENT_ROOT
  72. echo 'export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"' > $IROOT/ulib.installed
  73. echo "export ULIB_VERSION=${ULIB_VERSION}" >> $IROOT/ulib.installed
  74. echo "export ULIB_ROOT=${ULIB_ROOT}" >> $IROOT/ulib.installed
  75. echo "export ULIB_DOCUMENT_ROOT=${ULIB_DOCUMENT_ROOT}" >> $IROOT/ulib.installed
  76. echo -e "export PATH=\$ULIB_ROOT/bin:\$PATH" >> $IROOT/ulib.installed
  77. source $IROOT/ulib.installed