mkhighlight.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. here="$( cd "$( dirname "$0" )" &> /dev/null && pwd )"
  3. opt_all=0
  4. opt_dest="$HOME/.gpuedit/highlighters/."
  5. opt_parser=0
  6. opt_sudo=""
  7. while getopts ":ad:ps" opt; do
  8. case $opt in
  9. a)
  10. opt_all=1
  11. ;;
  12. d)
  13. opt_dest="$OPTARG""/."
  14. ;;
  15. p)
  16. opt_parser=1
  17. ;;
  18. s)
  19. opt_sudo=sudo
  20. ;;
  21. \?)
  22. echo "Invalid option: -$OPTARG"
  23. exit 1
  24. ;;
  25. :)
  26. echo "Option -$OPTARG requires an argument"
  27. exit 1
  28. ;;
  29. esac
  30. done
  31. shift $(($OPTIND - 1))
  32. # check if src/sti/parser/parser_gen exists
  33. # and is newer than the source file
  34. cd src/sti/parser
  35. if [ $opt_parser -eq 1 ] || ! [ -f parser_gen ] || [ parser_gen -ot parser_gen.c ]; then
  36. echo "building parser_gen"
  37. ./build.sh
  38. fi
  39. cd "$here/src/highlighters"
  40. paths=( $(find * -type d) )
  41. for i in "${paths[@]}"; do
  42. cd "$here/src/highlighters/$i"
  43. if [ $opt_all -eq 1 ] || [ "../$i.so" -ot lexer.c ] || [ "../$i.so" -ot lexer.h ] || [ "../$i.so" -ot tokens.txt ]; then
  44. echo "building $i highlighter..."
  45. ./build.sh
  46. cd "$here"
  47. $opt_sudo cp "$here/src/highlighters/$i.so" "$opt_dest"
  48. else
  49. echo "$i highlighter already up to date"
  50. fi
  51. done