
compile-scripts.sh
By:
Ciphor on
Apr 29th, 2012 | syntax:
Bash | size: 1.51 KB | hits: 453 | expires: Never
#!/usr/bin/env bash
# DO NOT REDISTRIBUTE OR MODIFY WITHOUT CONSENT
clear
echo "\033]0;Compile-Scripts by Ciphor\007"
clear
cc="javac"
cflags="-deprecation"
bin="bin"
src="src"
cd "$(dirname "$BASH_SOURCE")"
if [ ! -f RSBot*.jar ]; then
echo "[INFO] RSBot could not be found."
echo "[NOTE] Please ensure one copy of RSBot is in the same directory as compile-scripts.sh"
echo "Press any key to continue..."
awk "BEGIN{getline}"
exit
fi
if [ ! -d "$src" ]; then
echo "[INFO] Creating src directory..."
mkdir "$src"
fi
if [ ! -d "$bin" ]; then
echo "[INFO] Creating bin directory..."
mkdir "$bin"
fi
for file in $src/*.java
do
if [ ! -f "${file}" ]; then
echo "[INFO] No .java script source files found."
echo "[NOTE] If this is the first time running compile-scripts.sh"
echo "[NOTE] You now need to move your .java files into the src folder."
echo "Press any key to continue..."
awk "BEGIN{getline}"
exit
fi
done
echo "[INFO] Setting chmod +x to all scripts..."
find "$src" -type f -exec chmod +x {} \;
echo "[INFO] Compiling scripts..."
for file in $src/*.class
do
if [ -f $src/*.class ]; then
rm -R $src/*.class
break
fi
done
"$cc" "$cflags" -cp RSBot*.jar -d "$bin" $src/*.java
if [ $? != 0 ]; then
echo "[INFO] Scripts failed to compile."
else
echo "[INFO] Scripts compiled successfully."
fi
echo "Press any key to continue..."
awk "BEGIN{getline}"
exit