Don't like ads? PRO users don't see any ads ;-)

compile-scripts.sh

By: Ciphor on Apr 29th, 2012  |  syntax: Bash  |  size: 1.51 KB  |  hits: 453  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env bash
  2.  
  3. # DO NOT REDISTRIBUTE OR MODIFY WITHOUT CONSENT
  4.  
  5. clear
  6. echo "\033]0;Compile-Scripts by Ciphor\007"
  7. clear
  8.  
  9. cc="javac"
  10. cflags="-deprecation"
  11. bin="bin"
  12. src="src"
  13.  
  14. cd "$(dirname "$BASH_SOURCE")"
  15.  
  16. if [ ! -f RSBot*.jar ]; then
  17.     echo "[INFO] RSBot could not be found."
  18.     echo "[NOTE] Please ensure one copy of RSBot is in the same directory as compile-scripts.sh"
  19.     echo "Press any key to continue..."
  20.     awk "BEGIN{getline}"
  21.     exit
  22. fi
  23.  
  24. if [ ! -d "$src" ]; then
  25.     echo "[INFO] Creating src directory..."
  26.     mkdir "$src"
  27. fi
  28.  
  29. if [ ! -d "$bin" ]; then
  30.     echo "[INFO] Creating bin directory..."
  31.     mkdir "$bin"
  32. fi
  33.        
  34. for file in $src/*.java
  35. do
  36.     if [ ! -f "${file}" ]; then
  37.         echo "[INFO] No .java script source files found."
  38.         echo "[NOTE] If this is the first time running compile-scripts.sh"
  39.         echo "[NOTE] You now need to move your .java files into the src folder."
  40.         echo "Press any key to continue..."
  41.         awk "BEGIN{getline}"
  42.         exit
  43.     fi
  44. done
  45.  
  46. echo "[INFO] Setting chmod +x to all scripts..."
  47. find "$src" -type f -exec chmod +x {} \;
  48. echo "[INFO] Compiling scripts..."
  49.  
  50. for file in $src/*.class
  51. do
  52.     if [ -f $src/*.class ]; then
  53.         rm -R $src/*.class
  54.         break
  55.     fi
  56. done
  57.  
  58. "$cc" "$cflags" -cp RSBot*.jar -d "$bin" $src/*.java
  59.  
  60. if [ $? != 0 ]; then
  61.         echo "[INFO] Scripts failed to compile."
  62.         else
  63.         echo "[INFO] Scripts compiled successfully."
  64. fi
  65.  
  66. echo "Press any key to continue..."
  67. awk "BEGIN{getline}"
  68. exit