-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
178 lines (157 loc) · 4.04 KB
/
Rakefile
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# Rakefile for VexFlow
# Copyright 2013 Mohit Cheppudira <[email protected]>
require 'bundler/setup'
require 'fileutils'
require 'rake/testtask'
require 'time'
require 'erb'
require 'uglifier'
DIR = File.dirname(__FILE__)
TARGET_DIR = "build/vexflow"
TARGET = "#{TARGET_DIR}/vexflow-min.js"
TARGET_RAW = "#{TARGET_DIR}/vexflow-debug.js"
BUILD_VERSION = "1.2 Custom"
BUILD_PREFIX = "0xFE"
BUILD_DATE = Time.now()
BUILD_COMMIT = `git rev-list --max-count=1 HEAD`.chomp
JSHINT = "./node_modules/jshint/bin/jshint"
DOCCO = "./node_modules/.bin/docco"
directory TARGET_DIR
directory 'build/tests'
directory 'build/tests/support'
# Ordered list of Vexflow source files. If you have dependencies
# between files, order them here.
base_sources = [
"src/vex.js",
"src/flow.js",
"src/fraction.js",
"src/tables.js",
"src/fonts/vexflow_font.js",
"src/glyph.js",
"src/stave.js",
"src/staveconnector.js",
"src/tabstave.js",
"src/tickcontext.js",
"src/tickable.js",
"src/note.js",
"src/notehead.js",
"src/stem.js",
"src/stemmablenote.js",
"src/stavenote.js",
"src/tabnote.js",
"src/ghostnote.js",
"src/clefnote.js",
"src/timesignote.js",
"src/beam.js",
"src/voice.js",
"src/voicegroup.js",
"src/modifier.js",
"src/modifiercontext.js",
"src/accidental.js",
"src/dot.js",
"src/formatter.js",
"src/stavetie.js",
"src/tabtie.js",
"src/tabslide.js",
"src/bend.js",
"src/vibrato.js",
"src/annotation.js",
"src/articulation.js",
"src/tuning.js",
"src/stavemodifier.js",
"src/keysignature.js",
"src/timesignature.js",
"src/clef.js",
"src/music.js",
"src/keymanager.js",
"src/renderer.js",
"src/raphaelcontext.js",
"src/canvascontext.js",
"src/stavebarline.js",
"src/stavehairpin.js",
"src/stavevolta.js",
"src/staverepetition.js",
"src/stavesection.js",
"src/stavetempo.js",
"src/stavetext.js",
"src/barnote.js",
"src/tremolo.js",
"src/tuplet.js",
"src/boundingbox.js",
"src/textnote.js",
"src/frethandfinger.js",
"src/stringnumber.js",
"src/strokes.js",
"src/curve.js",
"src/staveline.js",
"src/crescendo.js",
# MusicXML files
"src/measure.js",
"src/musicxml.js",
"src/document.js",
"src/documentformatter.js"
]
# Don't minify these files.
reject = [
"src/header.js",
"src/container.js"
]
# Catch other missing JS files
js_files = Dir.glob('src/*.js')
js_files.reject! {|file| base_sources.include?(file)}
js_files.reject! {|file| reject.include?(file)}
vexflow_sources = base_sources + js_files
# Creates a rake task named "name" to copy files
# from "path_glob" to "dest_dir"
def copy_path(path_glob, dest_dir, name)
FileList[path_glob].each do |source|
target = "#{dest_dir}/#{File.basename(source)}"
file target => [source, dest_dir] do
if not File.directory? source
cp source, target, :verbose => true
end
end
desc "Copy data in: #{path_glob}"
task name => target
end
end
# Rake task to compile and minify VexFlow.
file TARGET => vexflow_sources do
# Fill fields in header
header = ERB.new(File.read("src/header.js")).result(binding)
raw_file = File.open(TARGET_RAW, "w")
min_file = File.open(TARGET, "w")
raw_file.write header
min_file.write header
vexflow_sources.each do |file|
puts "Minifying: " + file
contents = File.read(file)
min = Uglifier.new(
{:output =>
{:comments => :none}
}).compile(contents)
raw_file.write(contents)
min_file.write(min)
end
raw_file.close()
min_file.close()
puts "Generated: " + TARGET
puts "Unminified: " + TARGET_RAW
end
copy_path("tests/*", "build/tests", :build_copy)
copy_path("tests/support/*", "build/tests/support", :build_copy)
task :clean do
sh 'rm -rf build'
end
task :lint do
# Requires JSHint to be installed
puts "Checking VexFlow sources for lint errors..."
system "#{JSHINT} --show-non-errors --config jshintrc src/*.js"
end
task :docs do
# Requires JSHint to be installed
puts "Generating documentation..."
system "#{DOCCO} -l linear src/*.js"
end
task :make => [:build_copy, TARGET_DIR, TARGET]
task :default => [:make]