This repository has been archived by the owner on Aug 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtatu.sh
executable file
·125 lines (104 loc) · 3.18 KB
/
tatu.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# Closure library settings
CLOSURE_LIBRARY_REVISION="4bbe2636012f81eafc3341539f25bcd3ae1ab09a"
CLOSURE_LIBRARY_PATH="closure/library"
# Closure compiler settings
CLOSURE_COMPILER_REVISION="20130722"
CLOSURE_COMPILER_PATH="closure/compiler"
CLOSURE_COMPILER_SOURCE="http://closure-compiler.googlecode.com/files"
# Closure compiler files
CLOSURE_COMPILER_DIST="$CLOSURE_COMPILER_PATH/dist.tar.gz"
CLOSURE_COMPILER_JAR="$CLOSURE_COMPILER_PATH/compiler.jar"
# Deps writer settings
CLOSURE_DEPS_WRITER="$CLOSURE_LIBRARY_PATH/closure/bin/build/depswriter.py"
CLOSURE_DEPS_ROOT_WITH_PREFIX="src/tatu ../../../../src/tatu"
CLOSURE_DEPS_OUTPUT="src/tatu/deps.js"
# Build settings
CLOSURE_BUILDER="$CLOSURE_LIBRARY_PATH/closure/bin/build/closurebuilder.py"
CLOSURE_ROOT_LIST=("$CLOSURE_LIBRARY_PATH/closure/goog"
"$CLOSURE_LIBRARY_PATH/third_party/closure/goog"
"src/tatu")
CLOSURE_NAMESPACE_LIST=("tatu.Manager")
CLOSURE_MIN_FLAG="--compilation_level=ADVANCED_OPTIMIZATIONS"
CLOSURE_JS_OUTPUT="build/tatu.js"
CLOSURE_JS_OUTPUT_MIN="build/tatu.min.js"
# Tests
TEST_PHANTOM="phantomjs"
TEST_PATH="./test/"
TEST_FILE="test.js"
get_closure_compiler() {
url="$CLOSURE_COMPILER_SOURCE/compiler-$CLOSURE_COMPILER_REVISION.tar.gz"
if [ -z "`ls $CLOSURE_COMPILER_DIST 2> /dev/null`" ]; then
wget $url -O $CLOSURE_COMPILER_DIST
fi
if [ -z "`ls $CLOSURE_COMPILER_JAR 2> /dev/null`" ]; then
tar xf $CLOSURE_COMPILER_DIST -C $CLOSURE_COMPILER_PATH
fi
}
get_closure_library() {
git_dir="--git-dir=$CLOSURE_LIBRARY_PATH/.git"
git_work_tree="--work-tree=$CLOSURE_LIBRARY_PATH"
git="git $git_dir $git_work_tree"
if [ -z "`ls $CLOSURE_LIBRARY_PATH`" ]; then
git submodule init
git submodule update
$git checkout $CLOSURE_LIBRARY_REVISION
fi
}
get() {
get_closure_compiler
get_closure_library
}
configure() {
command="python $CLOSURE_DEPS_WRITER"
command="$command --root_with_prefix=\"$CLOSURE_DEPS_ROOT_WITH_PREFIX\""
command="$command > $CLOSURE_DEPS_OUTPUT"
eval $command
}
build() {
command="python $CLOSURE_BUILDER --output_mode=compiled --compiler_jar=\"$CLOSURE_COMPILER_PATH/compiler.jar\""
for root in ${CLOSURE_ROOT_LIST[*]}; do
command="$command --root=\"$root\""
done
for namespace in ${CLOSURE_NAMESPACE_LIST[*]}; do
command="$command --namespace=\"$namespace\""
done
if [ "$1" == "min" ]; then
command="$command --compiler_flags=\"$CLOSURE_MIN_FLAG\""
command="$command > $CLOSURE_JS_OUTPUT_MIN"
else
command="$command > $CLOSURE_JS_OUTPUT"
fi
eval $command
}
test() {
cd $TEST_PATH
$TEST_PHANTOM $TEST_FILE
}
run() {
if hash http-server 2> /dev/null; then
echo "http://127.0.0.1:8080/example/"
http-server -c 3600
else
echo "http://127.0.0.1:8000/example/"
python -m SimpleHTTPServer
fi
}
if [ "$1" = "get" ]; then
get
elif [ "$1" = "configure" ]; then
configure
elif [ "$1" = "build" ]; then
build
build "min"
elif [ "$1" = "test" ]; then
test
elif [ "$1" = "run" ]; then
run
else
get
configure
build
build "min"
test
fi