forked from 0xfe/vexflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
148 lines (130 loc) · 3.35 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
# 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"
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"
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/ghostnote.js",
"src/notehead.js",
"src/stem.js",
"src/stavenote.js",
"src/tabnote.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/stavebarline.js",
"src/stavehairpin.js",
"src/stavevolta.js",
"src/staverepetition.js",
"src/stavesection.js",
"src/stavetempo.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"
]
# Don't minify these files.
reject = [
"src/header.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)
File.open(TARGET, "w") do |f|
f.write header
vexflow_sources.each do |file|
puts "Minifying: " + file
min = Uglifier.new(
{:output =>
{:comments => :none}
}).compile(File.read(file))
f.write(min)
end
end
puts "Generated: " + TARGET
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 :make => [:build_copy, TARGET_DIR, TARGET]
task :default => [:make]