forked from rubygame/rubygame
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
277 lines (200 loc) · 5.55 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
#
# This is the Rakefile for Rubygame. It's used for packaging,
# installing, generating the documentation, and running specs.
#
# The version number for Rubygame.
# If you update this, also update lib/rubygame/main.rb.
RUBYGAME_VERSION = [2,6,4]
require 'rubygems'
require 'rake'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require "rbconfig"
include Config
#######
# GEM #
#######
gem_spec = Gem::Specification.new do |s|
s.name = "rubygame"
s.version = RUBYGAME_VERSION.join(".")
s.author = "John Croisant"
s.email = "[email protected]"
s.homepage = "http://rubygame.org/"
s.summary = "Clean and powerful library for game programming"
s.rubyforge_project = "rubygame"
s.files = FileList.new do |fl|
fl.include("{lib,samples,doc}/**/*")
end
s.require_paths = ["lib"]
s.has_rdoc = true
s.extra_rdoc_files = FileList.new do |fl|
fl.include "doc/*.rdoc", "./*.rdoc", "LICENSE.txt"
end
s.required_ruby_version = ">= 1.8"
s.add_dependency( "rake", ">=0.7.0" )
s.add_dependency( "ruby-sdl-ffi", ">=0.4.0" )
s.requirements = ["SDL >= 1.2.7",
"SDL_gfx >= 2.0.10 (optional)",
"SDL_image >= 1.2.3 (optional)",
"SDL_mixer >= 1.2.7 (optional)",
"SDL_ttf >= 2.0.6 (optional)"]
end
Rake::GemPackageTask.new(gem_spec) do |pkg|
pkg.need_tar_bz2 = true
end
########
# RDOC #
########
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.title = "Rubygame #{RUBYGAME_VERSION.join(".")} Docs"
rd.rdoc_files.include("lib/rubygame/**/*.rb",
"doc/*.rdoc",
"./*.rdoc",
"LICENSE.txt")
end
desc "Generate RI-formatted docs."
task(:ri) do
sh('rdoc --ri --threads=1 --force-update --output "./ri" ./lib')
end
###########
# VERBOSE #
###########
desc "Run tasks more verbosely"
task :verbose do
ENV["SPEC_OPTS"] = "--format documentation #{ENV["SPEC_OPTS"]}"
end
#########
# CLEAN #
#########
require 'rake/clean'
task(:clean) { puts "Cleaning out temporary generated files" }
task(:clobber) { puts "Cleaning out final generated files" }
CLOBBER.include("ri")
###########
# INSTALL #
###########
task :install do |task|
sitelibdir = (ENV["RUBYLIBDIR"] or CONFIG["sitelibdir"])
puts "Installing to #{sitelibdir}"
files = FileList.new do |fl|
fl.include("lib/**/*.rb")
end
files.each do |f|
dir = File.join(sitelibdir, File.dirname(f).sub('lib',''), "")
mkdir_p dir
cp f, dir
end
end
#########
# SPECS #
#########
begin
require 'rspec/core/rake_task'
rspec_opts = '-r spec/spec_helper.rb'
desc "Run all specs"
RSpec::Core::RakeTask.new do |t|
ENV["RUBYGAME_NEWRECT"] = "true"
t.pattern = 'spec/*_spec.rb'
t.rspec_opts = rspec_opts
end
namespace :spec do
desc "Run all specs"
RSpec::Core::RakeTask.new(:all) do |t|
ENV["RUBYGAME_NEWRECT"] = "true"
t.pattern = 'spec/*_spec.rb'
t.rspec_opts = rspec_opts
end
desc "Run spec/[name]_spec.rb (e.g. 'color')"
task :name do
puts( "This is just a stand-in spec.",
"Run rake spec:[name] where [name] is e.g. 'color', 'music'." )
end
desc "Run specific examples from spec/[name]_spec.rb"
task "name:\"example\"" do
puts( "This is just a stand-in spec.",
"Run rake spec:[name]:\"[example]\" where [name] is e.g."+
"'color', and [example] is a pattern matching an example." )
end
end
rule(/spec:.+/) do |t|
# Matches e.g. 'spec:foo' and 'spec:foo:"Example pattern"'
spec_regexp = /spec:([^:]+)(?::(.+))?/
match = t.name.match(spec_regexp)
unless match
puts "Invalid spec task: #{t.name}"
exit 1
end
name = match[1]
example = match[2] # optional
pattern = File.join('spec', '%s_spec.rb'%name)
path = File.join( File.dirname(__FILE__), pattern )
if File.exist? path
RSpec::Core::RakeTask.new(name) do |t|
t.pattern = pattern
t.rspec_opts = rspec_opts
if example
t.rspec_opts += " -e #{example.inspect}"
end
end
puts "\nRunning %s"%pattern
Rake::Task[name].invoke
else
puts "File does not exist: %s"%pattern
end
end
########
# RCOV #
########
desc "Run all specs with rcov"
RSpec::Core::RakeTask.new(:rcov) do |t|
ENV["RUBYGAME_NEWRECT"] = "true"
t.pattern = 'spec/*_spec.rb'
t.rcov = true
t.rspec_opts = rspec_opts
end
namespace :rcov do
desc "Run all specs with rcov"
RSpec::Core::RakeTask.new(:all) do |t|
ENV["RUBYGAME_NEWRECT"] = "true"
t.pattern = 'spec/*_spec.rb'
t.rcov = true
t.rspec_opts = rspec_opts
end
desc "Run spec/[name]_spec.rb (e.g. 'color') with rcov"
task :name do
puts( "This is just a stand-in spec.",
"Run rake rcov:[name] where [name] is e.g. 'color', 'music'." )
end
end
rule(/rcov:.+/) do |t|
name = t.name.gsub("rcov:","")
pattern = File.join('spec', '%s_spec.rb'%name)
path = File.join( pattern )
if File.exist? path
RSpec::Core::RakeTask.new(name) do |t|
t.pattern = pattern
t.rcov = true
t.rspec_opts = rspec_opts
end
puts "\nRunning %s"%pattern
Rake::Task[name].invoke
else
puts "File does not exist: %s"%pattern
end
end
rescue LoadError
error = "ERROR: rspec >= 2.0 is not installed?"
task :spec do
puts error
end
rule( /spec:.*/ ) do
puts error
end
task :rcov do
puts error
end
rule( /rcov:.*/ ) do
puts error
end
end