-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·79 lines (68 loc) · 2.44 KB
/
build
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
#!/bin/bash
set -e
cd $(dirname "$0")
coffee=node_modules/.bin/coffee
if [ ! -x $coffee ]; then
npm install
fi
cp_uv() {
if [[ $1 -nt $2 ]]; then
cp -v "$1" "$2"
fi
}
# xcat INPUTFILES OUTPUTFILE
# Concatenates INPUTFILES into OUTPUTFILE only if at least one of them is newer than OUTPUTFILE
xcat() { [ -e $2 ] && [ -z "$(find $1 -newer $2)" ] || ( echo "$1 -> $2" && cat $1 >$2 ); }
# xcoffee COFFEEFILE OUTPUTDIR
# Compiles COFFEEFILE only if newer than the corresponding .js file in OUTPUTDIR
xcoffee() { if [ $1 -nt $2/`basename $1 .coffee`.js ]; then echo "Compiling $1"; $coffee -o $2 -bc $1; fi; }
# Build lib/apl.js
f=lib/apl.js
if [ ! -e $f ] || [ -n "$(find src \( -name '*.coffee' -o -name '*.apl' \) -newer $f)" ]; then
echo "Building $f"
mkdir -p lib
echo '//usr/bin/env node "$0" $@ ; exit $?' >$f
$coffee -cp src/apl.coffee >>$f
chmod +x $f
fi
# Build web demo
mkdir -p web web-tmp
xcoffee web-src/index.coffee web-tmp
cp_uv web-src/index.html web/index.html
cp_uv web-src/tipsy.gif web/tipsy.gif
xcoffee web-src/examples-gen.coffee web-tmp
i=web-tmp/examples-gen.js ; o=web-tmp/examples.js ; [ $i -nt $o ] && echo "Building $o" && node $i
xcoffee test/collectdoctests.coffee test
xcoffee test/rundoctest.coffee test
xcoffee test/rundoctests.coffee test
o=web/all.js
if [ ! -e $o ] || [ -n "$(find src web-src web-tmp test lib -newer $o)" ]; then
echo "Building $o"
(
cat lib/apl.js \
web-src/jquery.min.js \
web-src/jquery.fieldselection.min.js \
web-src/jquery.keyboard.js \
web-src/jquery.keyboard.extension-typing.js \
web-src/jquery.tipsy.js \
web-tmp/examples.js \
web-tmp/index.js \
test/rundoctest.js
echo -n 'var aplTests = '
node test/collectdoctests.js
) >$o
fi
xcat 'web-src/index.css web-src/keyboard.css web-src/tipsy.css' web/all.css
# Build mobile demo
mkdir -p m/images m-tmp
xcoffee m-src/index.coffee m-tmp
cp_uv m-src/index.html m/index.html
cp_uv m-src/images/cursor.png m/images/cursor.png
xcat 'lib/apl.js web-src/jquery.min.js m-tmp/index.js' m/all.js
xcat m-src/index.css m/all.css
# Test
echo 'Running doctests'
node test/collectdoctests.js | node test/rundoctests.js
echo 'Running example tests'
examples/test
echo 'OK'