setup_and_build.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. # Update mORMot and static folder content from the latest [pre]release of mORMot2
  3. # Required tools: jq wget 7zip. On Ubuntu can be installed by
  4. # sudo apt install wget jq p7zip-full
  5. # On error
  6. err_report() {
  7. >&2 echo "Error in $0 on line $1"
  8. script_aborted
  9. }
  10. trap 'err_report $LINENO' ERR
  11. script_successful(){
  12. echo "++Build successfully++"
  13. exit 0
  14. }
  15. script_aborted() {
  16. echo "******Build aborted******"
  17. exit 1
  18. }
  19. set -o pipefail
  20. rm -rf ./libs
  21. mkdir -p ./libs/mORMot/static
  22. # echo "Getting the latest pre-release URL..."
  23. # USED_TAG=$(wget -qO- https://api.github.com/repos/synopse/mORMot2/releases/latest | jq -r '.tag_name')
  24. USED_TAG="2.0.stable"
  25. echo "Used release tag $USED_TAG"
  26. URL="https://github.com/synopse/mORMot2/releases/download/$USED_TAG/mormot2static.tgz"
  27. echo "Download statics from $URL ..."
  28. wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static
  29. # uncomment for fixed commit URL
  30. URL=https://github.com/synopse/mORMot2/tarball/139b61c77065d0b7c784eeeec8217c7e4dbb9618
  31. #URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
  32. echo "Download and unpacking mORMot sources from $URL ..."
  33. wget -qO- "$URL" | tar -xz -C ./libs/mORMot --strip-components=1
  34. # download our modified libpq what do not PQflush inside PQPipelineSync
  35. URL=https://github.com/pavelmash/postgres/releases/download/5.16_PQpipelineSync_noflush/libpq.so.5.16
  36. echo "Download modified libpq from $URL ..."
  37. wget -q -O./libpq.so.5.16 "$URL"
  38. # uncomment line below to echo commands to console
  39. set -x
  40. # get a mORMot folder name based on this script location
  41. TARGET="${TARGET:-linux}"
  42. ARCH="${ARCH:-x86_64}"
  43. ARCH_TG="$ARCH-$TARGET"
  44. MSRC="./libs/mORMot/src"
  45. BIN="./bin"
  46. STATIC="./libs/mORMot/static"
  47. mkdir -p "$BIN/fpc-$ARCH_TG/.dcu"
  48. rm -f "$BIN"/fpc-"$ARCH_TG"/.dcu/*
  49. dest_fn=raw
  50. if [[ $TARGET == win* ]]; then
  51. dest_fn="$dest_fn.exe"
  52. fi
  53. # suppress warnings
  54. # Warning: (5059) Function result variable does not seem to be initialized
  55. # Warning: (5036) Local variable XXX does not seem to be initialized
  56. # Warning: (5089) Local variable XXX of a managed type does not seem to be initialized
  57. # Warning: (5090) Variable XXX of a managed type does not seem to be initialized
  58. SUPRESS_WARN=-vm11047,6058,5092,5091,5060,5058,5057,5028,5024,5023,4081,4079,4055,3187,3124,3123,5059,5036,5089,5090
  59. echo "Start compiling..."
  60. fpc -MDelphi -Sci -Ci -O4 -g -gl -gw2 -Xg -k'-rpath=$ORIGIN' -k-L$BIN \
  61. -T$TARGET -P$ARCH \
  62. -veiq -v-n-h- $SUPRESS_WARN \
  63. -Fi"$BIN/fpc-$ARCH_TG/.dcu" -Fi"$MSRC" \
  64. -Fl"$STATIC/$ARCH-$TARGET" \
  65. -Fu"$MSRC/core" -Fu"$MSRC/db" -Fu"$MSRC/rest" -Fu"$MSRC/crypt" \
  66. -Fu"$MSRC/app" -Fu"$MSRC/net" -Fu"$MSRC/lib" -Fu"$MSRC/orm" -Fu"$MSRC/soa" \
  67. -FU"$BIN/fpc-$ARCH_TG/.dcu" -FE"$BIN/fpc-$ARCH_TG" -o"$BIN/fpc-$ARCH_TG/$dest_fn" \
  68. -dFPC_LIBCMM \
  69. -B -Se1 "./src/raw.pas" | grep "[Warning|Error|Fatal]:"
  70. script_successful