Thomas Bruederli
2012-07-30 6843acc9fced3dc1261e019ad4552b6e4c340ec7
commit | author | age
bc9c02 1 #!/bin/sh
T 2 JS_DIR=`dirname "$0"`/../program/js
54f1af 3 JAR_DIR='/tmp'
bc9c02 4 CLOSURE_COMPILER_URL='http://closure-compiler.googlecode.com/files/compiler-latest.zip'
T 5
6 do_shrink() {
7     rm -f "$2"
54f1af 8     java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --js_output_file="$2"
bc9c02 9 }
T 10
11 if [ ! -d "$JS_DIR" ]; then
12     echo "Directory $JS_DIR not found."
13     exit 1
54f1af 14 fi
T 15
16 if [ ! -w "$JAR_DIR" ]; then
17     JAR_DIR=`dirname "$0"`
bc9c02 18 fi
T 19
20 if java -version >/dev/null 2>&1; then
21     :
22 else
23     echo "Java not found. Please ensure that the 'java' program is in your PATH."
24     exit 1
25 fi
26
54f1af 27 if [ ! -r "$JAR_DIR/compiler.jar" ]; then
bc9c02 28     if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
T 29         wget "$CLOSURE_COMPILER_URL" -O "/tmp/$$.zip"
30     elif which curl >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
31         curl "$CLOSURE_COMPILER_URL" -o "/tmp/$$.zip"
32     else
54f1af 33         echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/."
bc9c02 34         exit 1
T 35     fi
54f1af 36     (cd $JAR_DIR && unzip "/tmp/$$.zip" "compiler.jar")
bc9c02 37     rm -f "/tmp/$$.zip"
T 38 fi
39
40 for fn in app common googiespell list; do
41     if [ -r "$JS_DIR/${fn}.js.src" ]; then
42         echo "$JS_DIR/${fn}.js.src already exists, not overwriting"
43     else
44         mv "$JS_DIR/${fn}.js" "$JS_DIR/${fn}.js.src"
45     fi
46     echo "Shrinking $JS_DIR/${fn}.js"
47     do_shrink "$JS_DIR/${fn}.js.src" "$JS_DIR/${fn}.js"
48 done