-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
302 lines (252 loc) · 6.61 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
require "fileutils"
require "erb"
require "time"
def template_io ipath, opath, bind
template = ERB.new File.read ipath
f = File.new opath, "w"
f.write template.result bind
f.close
end
def run cmd
if windows?
sh "start #{cmd}"
else
sh cmd
end
end
def gracket args
run "gracket -W info -l errortrace -t #{args}"
end
def racket args
run "racket -W info -l errortrace -t #{args}"
end
def windows?
RUBY_PLATFORM =~ /(win|w)32$/
end
# location of solumns binary after build
def solumns_bin
"work/solumns"
end
desc "Test a game where the columns are shuffled."
task :test_shuffle do
gracket "test/gui/shuffler.rkt"
end
desc "Check we can shuffle a list"
task :test_shuffling do
racket "test/shuffle.rkt"
end
desc "Check cycles can be detected and prevented"
task :test_cycle do
racket "test/cycle-detector.rkt"
end
desc "Check that we can play a game without cycles occuring"
task :test_acyclic do
gracket "test/gui/acyclic.rkt"
end
desc "Check the GUI looks correct."
task :test_draw do
gracket "test/gui/draw.rkt"
end
desc "Test a game that occasionally gives random columns to reduce cycles."
task :test_occasional do
gracket "test/gui/occasional.rkt"
end
desc "Check the GUI can be resized and redrawn okay."
task :test_refresh do
gracket "test/gui/refresh.rkt"
end
desc "Check that the player can move blocks with the arrow keys"
task :test_drop do
gracket "test/gui/drop.rkt"
end
desc "Test that we can keep a record of high scores okay."
task :test_record do
gracket "test/gui/record.rkt"
end
desc "Try a minimal prototype of solumns"
task :test_game do
gracket "test/gui/game.rkt"
end
desc "Try a prototype of solumns with score information displayed."
task :test_score do
gracket "test/gui/score.rkt"
end
desc "Test a version of solumns with high score gathering"
task :test_hiscore do
gracket "test/gui/hiscore.rkt"
end
desc "Test a version of solumns that can be restarted."
task :test_restart do
gracket "test/gui/restart.rkt"
end
desc "Test a version of solumns that fades out eliminated blocks."
task :test_fade do
gracket "test/gui/fade.rkt"
end
desc "Check to see if we can fill in a high score properly"
task :test_fill_hiscore do
gracket "test/gui/fill-hiscore.rkt"
end
desc "Check that the algorithms can create colours"
task :test_cmap do
gracket "test/gui/colour-mapping.rkt"
end
desc "Test user input"
task :test_input do
gracket "test/gui/input.rkt"
end
desc "Test gravity, neighbouring column elimination."
task :test_grid => [:build_c] do
racket "test/grid.rkt"
end
desc "Test the brute-force sub-optimising algorithm."
task :test_bruteforce do
racket "test/brute-force.rkt"
end
desc "Test the pause status machine is sane"
task :test_pause_status do
racket "test/pause.rkt"
end
desc "Test a game that can be paused"
task :test_pause do
gracket "test/gui/pauser.rkt"
end
desc "Test generation of random columns."
task :test_random do
racket "test/random.rkt"
end
desc "Test game where output columns are randomly rotated."
task :test_rotate do
gracket "test/gui/rotator.rkt"
end
desc "Run all (automated) tests"
task :test => [:test_grid, :test_random,
:test_bruteforce, :test_cmap, :test_record,
:test_shuffling, :test_cycle, :test_pause_status]
desc "Run solumns"
task :run => [:build] do
run solumns_bin
end
file "work" do
mkdir "work"
end
file "release" do
mkdir "release"
end
desc "Create distribution"
task :dist => ["release"] do
if windows?
sh "windows/release.bat"
else
sh "raco distribute release #{solumns_bin}"
end
FileUtils.cp_r "data", "release/"
end
desc "Clean"
task :clean do
FileUtils.rm_rf "work"
FileUtils.rm_rf "release"
FileUtils.rm_rf "lib"
FileUtils.rm_rf "profile/lib"
end
desc "Create windows installer"
task :wix => [:build, :dist] do
if windows?
FileUtils.cp "windows/installer/solumns.wxs", "release"
FileUtils.cp "windows/installer/COPYING.rtf", "release"
FileUtils.cp "lib/elimination.dll", "release/lib"
sh "windows/create-installer.bat"
else
raise "Only works on windows"
end
end
file "lib" do
FileUtils.mkdir "lib"
FileUtils.mkdir "lib/solumns"
end
desc "Build the C libray."
task :build_c => ["work", "lib"] do
if windows?
if ENV["DEBUG"]
sh "windows/debug_build_c.bat"
else
sh "windows/build_c.bat"
end
else
flags = "-std=c99 -shared -Wall -fPIC "
if ENV["DEBUG"]
flags += "-g"
else
flags += "-O3"
end
sh "gcc #{flags} -o lib/solumns/elimination.so cbits/elimination.c"
end
end
task :build => ["work", :build_c] do
if windows?
sh "windows/build.bat"
else
sh "raco exe --gui -o #{solumns_bin} solumns/main.rkt"
end
end
def udeb_usage_message
"rake udeb VERSION=x.y-z"
end
def udeb_usage_error
raise "USAGE: #{udeb_usage_message}"
end
desc "Build ubuntu .deb package. #{udeb_usage_message}"
task :udeb => [:clean, :build, :dist] do
version = ENV["VERSION"]
if version
if version =~ /^(\d+)\.(\d+)-(\d+)$/
deb_name = "solumns_#{version}"
package_path = "release/ubuntu/#{deb_name}"
fs_path = "#{package_path}/usr/"
share_path = "#{fs_path}/share/"
logo_path = "#{share_path}/solumns/"
pixmap_path = "#{share_path}/pixmaps/"
icon_path = "#{share_path}/icons/"
doc_path = "#{share_path}/doc/solumns/"
menu_path = "#{share_path}/menu/"
debian_path = "#{package_path}/DEBIAN/"
desktop_path = "#{share_path}/applications"
games_path = "#{fs_path}/games/"
FileUtils.mkdir_p package_path
FileUtils.mkdir_p share_path
FileUtils.mkdir_p debian_path
FileUtils.mkdir_p logo_path
FileUtils.mkdir_p icon_path
FileUtils.mkdir_p pixmap_path
FileUtils.mkdir_p doc_path
FileUtils.mkdir_p menu_path
FileUtils.mkdir_p desktop_path
FileUtils.mkdir_p games_path
FileUtils.cp "release/bin/solumns", games_path
FileUtils.cp_r "release/lib", fs_path
FileUtils.cp_r "lib/solumns", "#{fs_path}/lib/"
FileUtils.cp "data/logo.png", logo_path
FileUtils.cp "data/solumns-frame-icon.png", logo_path
FileUtils.cp_r "data/hicolor", icon_path
FileUtils.cp "data/solumns.xpm", pixmap_path
FileUtils.cp "ubuntu/postinst", debian_path
FileUtils.cp "ubuntu/postrm", debian_path
FileUtils.cp "ubuntu/menu", "#{menu_path}/solumns"
FileUtils.cp "ubuntu/solumns.desktop", desktop_path
bind = binding
template_io "ubuntu/build-package.sh.erb", "release/ubuntu/build-package.sh", bind
template_io "ubuntu/control.erb", "#{debian_path}/control", bind
template_io "ubuntu/copyright.erb", "#{debian_path}/copyright", bind
FileUtils.chmod 0744, "release/ubuntu/build-package.sh"
sh "cd release/ubuntu && fakeroot ./build-package.sh"
else
udeb_usage_error
end
else
udeb_usage_error
end
end
desc "Wordcount"
task :words do
run "wc `find -regex '.+.rkt'` | sort -n"
end