Common.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # FPC build scripts also work in Windows in WSL, Cygwin, MSYS, etc.
  3. # FPC compiler command
  4. FPC=fpc
  5. # You can override default FPC target (to cross-compile etc.)
  6. #TARGET=-Tuser
  7. # Uncomment if you run this shell script in WSL and want to run Windows-side FPC instead of Linux FPC
  8. #FPC=fpc.exe
  9. set -e
  10. # Make sure there are no CR characters (by fpc.exe) otherwise variable concatenation of FPCTARGET would fail
  11. FPCCPU=$($FPC -iTP | tr -d '\r')
  12. FPCOS=$($FPC -iTO | tr -d '\r')
  13. FPCTARGET=$FPCCPU-$FPCOS
  14. ROOTDIR=".."
  15. DEMOPATH="$ROOTDIR/Demos/ObjectPascal"
  16. BINPATH="$ROOTDIR/Demos/Bin"
  17. UNITPATH="$ROOTDIR/Demos/Bin/Dcu/$FPCTARGET"
  18. # FPC does not like creating any new directories passed by -FE -FU
  19. mkdir -p $UNITPATH
  20. mkdir -p $BINPATH
  21. set +e
  22. OUTPUT="-FE$BINPATH -FU$UNITPATH"
  23. # This is how you suppress -vn set in fpc.cfg
  24. OPTIONS="-B -O3 -Xs -vn-"
  25. INCLUDE="-Fi$ROOTDIR/Source"
  26. LIBS="-Fl$ROOTDIR/Extensions/J2KObjects -Fl$ROOTDIR/Extensions/LibTiff/Compiled"
  27. DEMOSBUILD=0
  28. DEMOCOUNT=0
  29. function buildDemo {
  30. $FPC $OPTIONS $OUTPUT $TARGET $DEFINES $UNITS $INCLUDE $LIBS $DEMOPATH/$1
  31. if [ $? = 0 ]; then
  32. ((DEMOSBUILD++))
  33. fi
  34. echo
  35. }
  36. function printResult {
  37. SWITCH="\033["
  38. NORMAL="${SWITCH}0m"
  39. RED="${SWITCH}0;31m"
  40. GREEN="${SWITCH}0;32m"
  41. if [ $DEMOSBUILD = $DEMOCOUNT ]; then
  42. echo -e "${GREEN}Build Successful - all $DEMOSBUILD of $DEMOCOUNT in Demos/Bin directory${NORMAL}"
  43. else
  44. echo -e "${RED}Errors during building - only $DEMOSBUILD of $DEMOCOUNT demos build${NORMAL}"
  45. fi
  46. }