-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.build.sh
55 lines (46 loc) · 1.17 KB
/
.build.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
#!/bin/bash
declare out
declare -a dep
wanted() {
if ! [ -e "$out" ]; then return 0; fi
for f in "${dep[@]}"; do
if [ "$f" -nt "$out" ]; then return 0; fi
done
return 1
}
if [ "$1" = "-B" ] || [ "$1" = force ] || [ "$1" = clean ]; then
echo cleaning
grep ^out= "${BASH_SOURCE[0]}" | sed s,^out=,, | while read line; do rm -f "$line"; done
if [ "$1" = clean ]; then exit 0; fi
fi
out=.w.txt
dep=(.a.js .utils.js .writewords.js)
if wanted; then
echo building $out
cat "${dep[@]}" | deno run - > $out
fi
out=.p.txt
dep=(.a.js .utils.js .calcuniqprefix.js)
if wanted; then
echo building $out
cat "${dep[@]}" | deno run - > $out
fi
out=a.gz
dep=(.a.txt .w.txt .p.txt)
if wanted; then
echo building $out
cat "${dep[@]}" | perl -ne '/[0-9]/ ? ($ans .= $_) : print; END { print $ans }' | gzip --best > $out
# that perl is to collect answers at the end for better compression (-22K)
fi
out=.g.js
dep=(.g.ts .g.sh)
if wanted; then
echo building $out
bash .g.sh
fi
out=index.html
dep=(a.gz .g.js .g.js .utils.js .init.js .make.js .logic.js .style.css .index.html .process.pl)
if wanted; then
echo building $out
perl -CDAS .process.pl .index.html > index.html
fi