Sharing of my labs carried out during the TDDE18 course at Linköping University
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build_and_run.sh 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # TDDE18 - Lab 5 - Build script
  3. red='\e[0;31m'
  4. green='\e[0;32m'
  5. orange='\e[0;33m'
  6. neutral='\e[0;m'
  7. printout() {
  8. echo -e "[${green}INFO${neutral}] $@"
  9. }
  10. printhelp() {
  11. echo -e "[${orange}HELP${neutral}] $@"
  12. }
  13. printerr() {
  14. echo -e "[${red}ERROR${neutral}] $@"
  15. }
  16. valgrd() {
  17. echo ""
  18. valgrind --tool=memcheck --leak-check=yes ./out.o $1 $2 $3 $4 $5
  19. echo ""
  20. }
  21. printhelp "Compilation, execution and debugging script for TDDE18 C ++ labs."
  22. printout "Starting building..."
  23. /usr/bin/time --quiet --output=data.tmp -f "Time elasped: %E (%P cpu)" g++ -Wall -Wextra -Wpedantic -std=c++17 *.cc -o out.o
  24. if test $? -eq 0
  25. then
  26. printout "Build finished."
  27. printout `cat data.tmp`
  28. rm data.tmp
  29. printout "Running..."
  30. if [[ $1 == "" ]]
  31. then
  32. printhelp "No arguments provided, using default example.html -a."
  33. echo ""
  34. ./out.o samples/example.html -a
  35. else
  36. echo ""
  37. ./out.o $1 $2 $3 $4 $5
  38. fi
  39. echo ""
  40. printout "Done. Cleaning..."
  41. rm out.o
  42. printout "Done."
  43. else
  44. printerr "Build failed."
  45. printout `cat data.tmp`
  46. rm data.tmp
  47. exit 1
  48. fi
  49. echo ""
  50. exit 0