-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.ninja
134 lines (116 loc) · 4.57 KB
/
build.ninja
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
126
127
128
129
130
131
132
133
134
# rules for ninja (ninja-build)
# 'uglifyjs' may be disabled running
# NOMIN=1 ninja -v
MAJOR=1
rule cp
command = cp $in $out
rule cpm
command = sed "s+@MAJOR@+$MAJOR+" $in > $out
rule font
command = fontforge -c 'open("font/abc2svg.sfd").generate("abc2svg.ttf")';$
fontforge -c 'open("font/abc2svg.sfd").generate("abc2svg.woff")';$
echo "// abc2svg music font" > font.js;$
echo "var musicfont = 'url(\"data:application/font-ttf;base64,\\" >> font.js;$
base64 abc2svg.ttf | sed 's/$$/\\/' >> font.js;$
echo "\")'" >> font.js
rule jsc
command = if [ -x /usr/bin/git -a -d .git ]; then$
VERSION=`git describe`;$
VERSION=$${VERSION#v};$
DATE=`git log -1 --pretty=format:%ci HEAD | cut -d' ' -f1`;$
else$
VERSION=`grep '"version"' package.json|cut -d'"' -f4`;$
DATE=`stat --printf=%y build.ninja | cut -d' ' -f1`;$
fi;$
cp core/license $out;$
echo "var abc2svg={version:\"$$VERSION\",vdate:\"$$DATE\"}" >> $out;$
if [ "x$$NOMIN" = "x" ]; then$
cat $in | uglifyjs >> $out;$
else$
cat $in >> $out;$
fi
rule jscu
command = if [ -x /usr/bin/git -a -d .git ]; then$
VERSION=`git describe`;$
VERSION=$${VERSION#v};$
DATE=`git log -1 --pretty=format:%ci HEAD | cut -d' ' -f1`;$
else$
VERSION=`grep '"version"' package.json|cut -d'"' -f4`;$
DATE=`stat --printf=%y build.ninja | cut -d' ' -f1`;$
fi;$
cp core/license $out;$
echo "// $out for abc2svg-$$VERSION ($$DATE)" >> $out;$
if [ "x$$NOMIN" = "x" ]; then$
uglifyjs $in >> $out;$
else$
cat $in >> $out;$
fi
rule edit
command = if [ "x$$NOMIN" = "x" ]; then$
sed "s+@MAJOR@+$MAJOR+" $in | uglifyjs > $out;$
else$
sed "s+@MAJOR@+$MAJOR+" $in > $out;$
fi
# generate all Scc1t2/n.js from sf2-Scc1t2/n.sf2
rule sf
command = for f in sf2-Scc1t2/*.sf2; do $
instr=`basename $$f`; $
o=$${f#sf2-}; $
o=$${o%.sf2}.js; $
if [ ! -r $$o -o $$f -nt $$o ]; then $
echo '// abc2svg sound font' > $$o; $
echo "abcsf2[$${instr%.sf2}] = '\\" >> $$o; $
base64 $$f | sed 's/$$/\\/' >> $$o; $
echo "'" >> $$o; $
fi; $
done
build font: font | font/abc2svg.sfd
build sf: sf | Scc1t2/
build abc2svg-$MAJOR.js: jsc core/abc2svg.js core/deco.js core/draw.js $
font.js core/format.js core/front.js core/music.js core/parse.js core/subs.js $
core/svg.js core/tune.js core/lyrics.js core/gchord.js core/tail.js $
core/modules.js | package.json
build ambitus-$MAJOR.js: jscu modules/ambitus.js | package.json
build break-$MAJOR.js: jscu modules/break.js | package.json
build capo-$MAJOR.js: jscu modules/capo.js | package.json
build clip-$MAJOR.js: jscu modules/clip.js | package.json
build combine-$MAJOR.js: jscu modules/combine.js | package.json
build diag-$MAJOR.js: jscu modules/diag.js | package.json
build grid-$MAJOR.js: jscu modules/grid.js | package.json
build grid2-$MAJOR.js: jscu modules/grid2.js | package.json
build MIDI-$MAJOR.js: jscu modules/MIDI.js | package.json
build perc-$MAJOR.js: jscu modules/perc.js | package.json
build psvg-$MAJOR.js: jscu modules/wps.js modules/psvg.js | package.json
build sth-$MAJOR.js: jscu modules/sth.js | package.json
build edit-$MAJOR.css: cp editor/edit.css
build abcdoc-$MAJOR.js: jscu util/abcdoc.js | package.json
build abcemb-$MAJOR.js: jscu util/abcemb.js | package.json
build follow-$MAJOR.js: jscu util/follow.js | package.json
build json-$MAJOR.js: jscu util/json.js | package.json
build setmidi-$MAJOR.js: jscu util/midi.js | package.json
build play-$MAJOR.js: jscu util/play.js util/toaudio.js $
util/toaudio5.js util/sf2-parser.js util/tomidi5.js | package.json
build toaudio-$MAJOR.js: jscu util/toaudio.js | package.json
build edit-$MAJOR.xhtml: cpm editor/edit.xhtml
build abckbd-$MAJOR.js: edit editor/abckbd.js | package.json
build abckbd2-$MAJOR.js: edit editor/abckbd2.js | package.json
build edit-$MAJOR.js: edit editor/edit.js | package.json
build all: phony abc2svg-$MAJOR.js abcdoc-$MAJOR.js $
abcemb-$MAJOR.js json-$MAJOR.js setmidi-$MAJOR.js $
play-$MAJOR.js toaudio-$MAJOR.js psvg-$MAJOR.js $
ambitus-$MAJOR.js break-$MAJOR.js capo-$MAJOR.js clip-$MAJOR.js $
combine-$MAJOR.js diag-$MAJOR.js grid-$MAJOR.js grid2-$MAJOR.js $
MIDI-$MAJOR.js perc-$MAJOR.js sth-$MAJOR.js $
edit-$MAJOR.css edit-$MAJOR.js edit-$MAJOR.xhtml $
abckbd-$MAJOR.js abckbd2-$MAJOR.js follow-$MAJOR.js
default all
# npm/git new release
# (needs 'npm set git-tag-version false')
rule version
command = npm version $out;$
tag=`grep '"version"' package.json|cut -d'"' -f4`;$
echo "New release v$$tag" | git commit -F- package.json;$
git tag -a v$$tag;$
echo "*** Don't forget: git push --follow-tags; ninja; npm publish"
build minor: version
build patch: version