setup_and_build.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. # echo "Getting the latest pre-release URL..."
  22. # USED_TAG=$(wget -qO- https://api.github.com/repos/synopse/mORMot2/releases/latest | jq -r '.tag_name')
  23. USED_TAG="2.0.4383"
  24. echo "Used release tag $USED_TAG"
  25. URL="https://github.com/synopse/mORMot2/releases/download/$USED_TAG/mormot2static.7z"
  26. echo "Download statics from $URL ..."
  27. wget -q -O./mormot2static.7z "$URL"
  28. mkdir -p ./libs/mORMot/static
  29. echo "Unpacking to ./libs/mORMot/static ..."
  30. 7za x ./mormot2static.7z -o./libs/mORMot/static
  31. rm -rf ./mormot2static.7z
  32. # uncomment for fixed commit URL
  33. URL=https://github.com/synopse/mORMot2/tarball/9a186358a3695afc3065853790e90f2868d86e23
  34. #URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
  35. echo "Download and unpacking mORMot sources from $URL ..."
  36. wget -qO- "$URL" | tar -xz -C ./libs/mORMot --strip-components=1
  37. # uncomment line below to echo commands to console
  38. set -x
  39. # get a mORMot folder name based on this script location
  40. TARGET="${TARGET:-linux}"
  41. ARCH="${ARCH:-x86_64}"
  42. ARCH_TG="$ARCH-$TARGET"
  43. MSRC="./libs/mORMot/src"
  44. BIN="./bin"
  45. STATIC="./libs/mORMot/static"
  46. mkdir -p "$BIN/fpc-$ARCH_TG/.dcu"
  47. rm -f "$BIN"/fpc-"$ARCH_TG"/.dcu/*
  48. dest_fn=raw
  49. if [[ $TARGET == win* ]]; then
  50. dest_fn="$dest_fn.exe"
  51. fi
  52. # suppress warnings
  53. # Warning: (5059) Function result variable does not seem to be initialized
  54. # Warning: (5036) Local variable XXX does not seem to be initialized
  55. # Warning: (5089) Local variable XXX of a managed type does not seem to be initialized
  56. # Warning: (5090) Variable XXX of a managed type does not seem to be initialized
  57. SUPRESS_WARN=-vm11047,6058,5092,5091,5060,5058,5057,5028,5024,5023,4081,4079,4055,3187,3124,3123,5059,5036,5089,5090
  58. echo "Start compiling..."
  59. fpc -MDelphi -Sci -Ci -O4 -g -gl -gw2 -Xg -k'-rpath=$ORIGIN' -k-L$BIN \
  60. -T$TARGET -P$ARCH \
  61. -veiq -v-n-h- $SUPRESS_WARN \
  62. -Fi"$BIN/fpc-$ARCH_TG/.dcu" -Fi"$MSRC" \
  63. -Fl"$STATIC/$ARCH-$TARGET" \
  64. -Fu"$MSRC/core" -Fu"$MSRC/db" -Fu"$MSRC/rest" -Fu"$MSRC/crypt" \
  65. -Fu"$MSRC/app" -Fu"$MSRC/net" -Fu"$MSRC/lib" -Fu"$MSRC/orm" -Fu"$MSRC/soa" \
  66. -FU"$BIN/fpc-$ARCH_TG/.dcu" -FE"$BIN/fpc-$ARCH_TG" -o"$BIN/fpc-$ARCH_TG/$dest_fn" \
  67. -dFPC_LIBCMM -dNOSYNDBZEOS -dNOSYNDBIBX \
  68. -B -Se1 "./src/raw.pas" | grep "[Warning|Error|Fatal]:"
  69. script_successful