summaryrefslogtreecommitdiffstats
path: root/compress/compress_with_closure.sh
blob: fe57755703b1e70f4d778aa86e55cbdace4527c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

DIR=`dirname $0`

URL="https://dl.google.com/closure-compiler/compiler-latest.zip"
FILE=`echo $URL | sed 's#.*/##'`
unzip > /dev/null 2> /dev/null
if [ $? -eq 0 ] ; then
  wget -V > /dev/null 2> /dev/null
  if [ $? -eq 0 ] ; then
    pushd . > /dev/null
    cd $DIR
    wget -q -N $URL
    popd > /dev/null
  else
    curl -V > /dev/null 2> /dev/null
    if [ $? -eq 0 ] ; then
      curl -s -z $DIR/$FILE -o $DIR/$FILE $URL > /dev/null 2> /dev/null
    fi
  fi
  if [ -s $DIR/$FILE ] ; then
    pushd . > /dev/null
    cd $DIR
    unzip -o $FILE compiler.jar > /dev/null 2> /dev/null
    popd > /dev/null
  fi
fi

$DIR/remove_constants.pl $1 | $DIR/opacify.pl > ._tmpRC.js

echo -n '"use strict";'
java -jar $DIR/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS \
     --js ._tmpRC.js \
     | $DIR/digitize.pl \
     | $DIR/dewindowize.pl
     

rm -f ._tmpRC.js