File:  [LON-CAPA] / loncom / html / adm / LC_math_editor / build.sh
Revision 1.2: download - view: text, annotated - select for diffs
Tue Feb 24 15:20:36 2015 UTC (9 years, 4 months ago) by damieng
Branches: MAIN
CVS tags: version_2_12_X, HEAD
updated to git version (see git for log history), and changed param separator to ,

#!/bin/bash

# this builds dist/LC_math_editor.min.js using google closure compiler.
# It must be run in the math_editor directory.

cd "$(dirname "$0")"
mkdir -p dist
tmp=$(mktemp)
cat <<% >$tmp
"use strict";
var LCMATH = function () {
%
cat src/*.js >>$tmp
cat <<% >>$tmp
    return({
        "Definitions": Definitions,
        "ENode": ENode,
        "Operator": Operator,
        "ParseException": ParseException,
        "Parser": Parser,
        "initEditors": initEditors,
        "updateMathSpanAndDiv": updateMathSpanAndDiv
    });
}();
%

# use the local application if Java is available
if hash java 2>/dev/null; then
    java -jar lib/compiler.jar --language_in=ECMASCRIPT5_STRICT --compilation_level=SIMPLE_OPTIMIZATIONS $tmp >dist/LC_math_editor.min.js
    exit 0
fi

# otherwise use the web service with compressjs.sh
NEWFILE="c`date +"%d%m%y"`.js"
/bin/sh ./compressjs.sh -strict $tmp
mv "$NEWFILE" ./dist/LC_math_editor.min.js
rm -f $tmp

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>