Permalink
Newer
Older
100755 49 lines (42 sloc) 1.28 KB
1
#!/bin/sh
2
JS_DIR=`dirname "$0"`/../program/js
4
CLOSURE_COMPILER_URL='http://closure-compiler.googlecode.com/files/compiler-latest.zip'
5
6
do_shrink() {
7
rm -f "$2"
8
java -jar $JAR_DIR/compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$1" --js_output_file="$2"
9
}
10
11
if [ ! -d "$JS_DIR" ]; then
12
echo "Directory $JS_DIR not found."
13
exit 1
14
fi
15
16
if [ ! -w "$JAR_DIR" ]; then
17
JAR_DIR=`dirname "$0"`
18
fi
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
27
if [ ! -r "$JAR_DIR/compiler.jar" ]; then
28
if which wget >/dev/null 2>&1 && which unzip >/dev/null 2>&1; then
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
33
echo "Please download $CLOSURE_COMPILER_URL and extract compiler.jar to $JAR_DIR/."
36
(cd $JAR_DIR && unzip "/tmp/$$.zip" "compiler.jar")
37
rm -f "/tmp/$$.zip"
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