Skip to content
Newer
Older
100644 380 lines (309 sloc) 9.58 KB
de564de Initial revision
jimweirich authored Oct 18, 2003
1 # Rakefile for rake -*- ruby -*-
2
dd80335 Added rf abbreviation.
jimweirich authored Jan 17, 2006
3 # Copyright 2003, 2004, 2005 by Jim Weirich (jim@weirichhouse.org)
47fb00b Added comments.
jimweirich authored Nov 12, 2003
4 # All rights reserved.
5
ac681d3 modified rakefile to Bil Klebs suggestions
jimweirich authored Apr 16, 2006
6 # This file may be distributed under an MIT style license. See
47fb00b Added comments.
jimweirich authored Nov 12, 2003
7 # MIT-LICENSE for details.
8
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
9 begin
10 require 'rubygems'
77a0ad2 Added 2004 to copyright.
jimweirich authored May 4, 2004
11 require 'rake/gempackagetask'
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
12 rescue Exception
13 nil
14 end
2337d2a require clean was missing in the main Rakefile ... how could that be?
jimweirich authored Nov 12, 2003
15 require 'rake/clean'
1bd831f Started the splitup of rubyapp into smaller, reusable components (e.g…
jimweirich authored Nov 9, 2003
16 require 'rake/testtask'
8bd21da Broke rubyapp into smaller pieces.
jimweirich authored Nov 11, 2003
17 require 'rake/rdoctask'
18
3210a02 Added require rubygems to a test, cleaning dot files, parameterized tar
jimweirich authored Feb 14, 2007
19 CLEAN.include('**/*.o', '*.dot')
e5a65e1 Added testdata to clobber.
jimweirich authored Jan 29, 2005
20 CLOBBER.include('doc/example/main', 'testdata')
b819a17 Added temp files from dry run test to clobber.
jimweirich authored Mar 25, 2005
21 CLOBBER.include('test/data/**/temp_*')
6f834d6 Added chains temp files to clobber list.
jimweirich authored Apr 8, 2005
22 CLOBBER.include('test/data/chains/play.*')
ceb84f1 version 0.5.4.3 -- fowler directory fixes
jimweirich authored Jul 2, 2005
23 CLOBBER.include('test/data/file_creation_task/build')
24 CLOBBER.include('test/data/file_creation_task/src')
df6dea6 Clobber TAGS.
jimweirich authored Sep 5, 2005
25 CLOBBER.include('TAGS')
c8197eb added rcov and unit tests
jimweirich authored Jun 1, 2006
26 CLOBBER.include('coverage')
0482ac8 The Jamis rdoc template is only used if it is present.
jimweirich authored Mar 6, 2005
27
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
28 def announce(msg='')
29 STDERR.puts msg
30 end
0482ac8 The Jamis rdoc template is only used if it is present.
jimweirich authored Mar 6, 2005
31
47fb00b Added comments.
jimweirich authored Nov 12, 2003
32 # Determine the current version of the software
33
5e23db9 Make version detection more robust.
jimweirich authored Oct 4, 2005
34 if `ruby -Ilib ./bin/rake --version` =~ /rake, version ([0-9.]+)$/
35 CURRENT_VERSION = $1
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
36 else
37 CURRENT_VERSION = "0.0.0"
38 end
39
40 if ENV['REL']
41 PKG_VERSION = ENV['REL']
8bd21da Broke rubyapp into smaller pieces.
jimweirich authored Nov 11, 2003
42 else
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
43 PKG_VERSION = CURRENT_VERSION
8bd21da Broke rubyapp into smaller pieces.
jimweirich authored Nov 11, 2003
44 end
1bd831f Started the splitup of rubyapp into smaller, reusable components (e.g…
jimweirich authored Nov 9, 2003
45
b461240 Lines task now counts all source files.
jimweirich authored Mar 25, 2004
46 SRC_RB = FileList['lib/**/*.rb']
47
47fb00b Added comments.
jimweirich authored Nov 12, 2003
48 # The default task is run if rake is given no explicit arguments.
49
8bd21da Broke rubyapp into smaller pieces.
jimweirich authored Nov 11, 2003
50 desc "Default Task"
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
51 task :default => :test_all
de564de Initial revision
jimweirich authored Oct 18, 2003
52
9b9204a Changed test tasks back to using the rake provided task macros.
jimweirich authored Jul 11, 2004
53 # Test Tasks ---------------------------------------------------------
1bd831f Started the splitup of rubyapp into smaller, reusable components (e.g…
jimweirich authored Nov 9, 2003
54
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
55 # Common Abbreviations ...
43d4081 Added Test abbreviations to Rakefile.
jimweirich authored Apr 7, 2005
56
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
57 task :ta => :test_all
58 task :tf => :test_functional
59 task :tu => :test_units
60 task :tc => :test_contribs
61 task :test => :test_units
62
63 Rake::TestTask.new(:test_all) do |t|
ef833eb Make testall the default task.
jimweirich authored Dec 22, 2004
64 t.test_files = FileList[
65 'test/test*.rb',
66 'test/contrib/test*.rb',
67 'test/fun*.rb'
68 ]
ddd28f9 bump version to intermediate 0.5.3.1. changed tests to non-verbose
jimweirich authored Apr 9, 2005
69 t.warning = true
ea538b2 Added explicit test task.
jimweirich authored May 5, 2005
70 t.verbose = true
ef833eb Make testall the default task.
jimweirich authored Dec 22, 2004
71 end
72
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
73 Rake::TestTask.new(:test_units) do |t|
1c46548 Switched to file list in test definition.
jimweirich authored Jul 25, 2004
74 t.test_files = FileList['test/test*.rb']
ddd28f9 bump version to intermediate 0.5.3.1. changed tests to non-verbose
jimweirich authored Apr 9, 2005
75 t.warning = true
76 t.verbose = false
a94b20c Changed the Rakefile to run the test raw (i.e. without the test task).
jimweirich authored May 10, 2004
77 end
de564de Initial revision
jimweirich authored Oct 18, 2003
78
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
79 Rake::TestTask.new(:test_functional) do |t|
ddd28f9 bump version to intermediate 0.5.3.1. changed tests to non-verbose
jimweirich authored Apr 9, 2005
80 t.test_files = FileList['test/fun*.rb']
81 t.warning = true
82 t.warning = true
9b9204a Changed test tasks back to using the rake provided task macros.
jimweirich authored Jul 11, 2004
83 end
84
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
85 Rake::TestTask.new(:test_contribs) do |t|
ddd28f9 bump version to intermediate 0.5.3.1. changed tests to non-verbose
jimweirich authored Apr 9, 2005
86 t.test_files = FileList['test/contrib/test*.rb']
87 t.verbose = false
88 t.warning = true
f521baa Added comments to test task.
jimweirich authored Jun 19, 2004
89 end
90
c8197eb added rcov and unit tests
jimweirich authored Jun 1, 2006
91 require 'rcov/rcovtask'
92
93 Rcov::RcovTask.new do |t|
94 t.libs << "test"
95 t.rcov_opts = ['-xRakefile', '-xrakefile', '-xpublish.rf', '--text-report']
96 t.test_files = FileList[
97 'test/test*.rb',
98 'test/contrib/test*.rb'
99 ]
100 t.verbose = true
101 end
102
de564de Initial revision
jimweirich authored Oct 18, 2003
103 directory 'testdata'
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
104 [:test_all, :test_units, :test_contribs, :test_functional].each do |t|
a4b6d36 updated comments in est file.
jimweirich authored Apr 2, 2005
105 task t => ['testdata']
106 end
47fb00b Added comments.
jimweirich authored Nov 12, 2003
107
9b9204a Changed test tasks back to using the rake provided task macros.
jimweirich authored Jul 11, 2004
108 # CVS Tasks ----------------------------------------------------------
47fb00b Added comments.
jimweirich authored Nov 12, 2003
109
110 # Install rake using the standard install.rb script.
8bd21da Broke rubyapp into smaller pieces.
jimweirich authored Nov 11, 2003
111
112 desc "Install the application"
113 task :install do
114 ruby "install.rb"
115 end
1bd831f Started the splitup of rubyapp into smaller, reusable components (e.g…
jimweirich authored Nov 9, 2003
116
47fb00b Added comments.
jimweirich authored Nov 12, 2003
117 # Create a task to build the RDOC documentation tree.
118
c65dccd Switched to css2 template (for now)
jimweirich authored Nov 27, 2003
119 rd = Rake::RDocTask.new("rdoc") { |rdoc|
47fb00b Added comments.
jimweirich authored Nov 12, 2003
120 rdoc.rdoc_dir = 'html'
c65dccd Switched to css2 template (for now)
jimweirich authored Nov 27, 2003
121 # rdoc.template = 'kilmer'
b461240 Lines task now counts all source files.
jimweirich authored Mar 25, 2004
122 # rdoc.template = 'css2'
05a9e50 Added shame task to the Rakefile.
jimweirich authored Oct 26, 2006
123 rdoc.template = 'doc/jamis.rb'
8362f33 Fixed title.
jimweirich authored Nov 28, 2003
124 rdoc.title = "Rake -- Ruby Make"
ac681d3 modified rakefile to Bil Klebs suggestions
jimweirich authored Apr 16, 2006
125 rdoc.options << '--line-numbers' << '--inline-source' <<
126 '--main' << 'README' <<
127 '--title' << 'Rake -- Ruby Make'
c65dccd Switched to css2 template (for now)
jimweirich authored Nov 27, 2003
128 rdoc.rdoc_files.include('README', 'MIT-LICENSE', 'TODO', 'CHANGES')
129 rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
130 rdoc.rdoc_files.exclude(/\bcontrib\b/)
47fb00b Added comments.
jimweirich authored Nov 12, 2003
131 }
132
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
133 # ====================================================================
47fb00b Added comments.
jimweirich authored Nov 12, 2003
134 # Create a task that will package the Rake software into distributable
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
135 # tar, zip and gem files.
136
137 PKG_FILES = FileList[
138 'install.rb',
139 '[A-Z]*',
140 'bin/**/*',
141 'lib/**/*.rb',
142 'test/**/*.rb',
ea538b2 Added explicit test task.
jimweirich authored May 5, 2005
143 'test/**/*.rf',
144 'test/**/*.mf',
145 'test/**/Rakefile',
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
146 'doc/**/*'
147 ]
4649238 removed temporary examples files from package spec
jimweirich authored Jul 2, 2004
148 PKG_FILES.exclude('doc/example/*.o')
149 PKG_FILES.exclude(%r{doc/example/main$})
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
150
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
151 if ! defined?(Gem)
152 puts "Package Target requires RubyGEMs"
153 else
154 spec = Gem::Specification.new do |s|
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
155
156 #### Basic information.
157
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
158 s.name = 'rake'
159 s.version = PKG_VERSION
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
160 s.summary = "Ruby based make-like utility."
161 s.description = <<-EOF
162 Rake is a Make-like program implemented in Ruby. Tasks
163 and dependencies are specified in standard Ruby syntax.
164 EOF
165
166 #### Dependencies and requirements.
167
168 #s.add_dependency('log4r', '> 1.0.4')
169 #s.requirements << ""
170
171 #### Which files are to be included in this gem? Everything! (Except CVS directories.)
172
0c88263 fixed gem building
jimweirich authored Nov 29, 2003
173 s.files = PKG_FILES.to_a
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
174
175 #### C code extensions.
176
177 #s.extensions << "ext/rmagic/extconf.rb"
178
179 #### Load-time details: library and application (you will need one or both).
180
181 s.require_path = 'lib' # Use these for libraries.
182
183 s.bindir = "bin" # Use these for applications.
184 s.executables = ["rake"]
185 s.default_executable = "rake"
186
187 #### Documentation and testing.
188
5649f91 Updated Gem Package Generation.
jimweirich authored Nov 28, 2003
189 s.has_rdoc = true
3cd17e4 Updated Rakefile to support rdoc file lists and options.
jimweirich authored Jun 6, 2004
190 s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
ac681d3 modified rakefile to Bil Klebs suggestions
jimweirich authored Apr 16, 2006
191 s.rdoc_options = rd.options
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
192
193 #### Author and project details.
194
195 s.author = "Jim Weirich"
196 s.email = "jim@weirichhouse.org"
50e3ca7 pointed gem web page reference to the rake rubyforge page.
jimweirich authored Nov 11, 2004
197 s.homepage = "http://rake.rubyforge.org"
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
198 s.rubyforge_project = "rake"
618a61c Commented out the cert file stuff until rubygems fixes signing problem.
jimweirich authored Sep 14, 2005
199 # if ENV['CERT_DIR']
200 # s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
201 # s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
202 # end
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
203 end
44fa75b Updated the gem spec to use almost all the options.
jimweirich authored May 1, 2004
204
df6dea6 Clobber TAGS.
jimweirich authored Sep 5, 2005
205 package_task = Rake::GemPackageTask.new(spec) do |pkg|
40ccfa2 Make RubyGems optional, but wont build packages without it.
jimweirich authored Nov 27, 2003
206 pkg.need_zip = true
207 pkg.need_tar = true
208 end
0a5d4ac updated docs and comments. getting ready for 0.3.0
jimweirich authored Nov 22, 2003
209 end
91ac08e Minor change.
jimweirich authored Nov 28, 2003
210
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
211 # Misc tasks =========================================================
212
b461240 Lines task now counts all source files.
jimweirich authored Mar 25, 2004
213 def count_lines(filename)
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
214 lines = 0
215 codelines = 0
b461240 Lines task now counts all source files.
jimweirich authored Mar 25, 2004
216 open(filename) { |f|
217 f.each do |line|
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
218 lines += 1
219 next if line =~ /^\s*$/
220 next if line =~ /^\s*#/
221 codelines += 1
222 end
223 }
b461240 Lines task now counts all source files.
jimweirich authored Mar 25, 2004
224 [lines, codelines]
225 end
226
227 def show_line(msg, lines, loc)
228 printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
229 end
230
231 desc "Count lines in the main rake file"
232 task :lines do
233 total_lines = 0
234 total_code = 0
235 show_line("File Name", "LINES", "LOC")
236 SRC_RB.each do |fn|
237 lines, codelines = count_lines(fn)
238 show_line(fn, lines, codelines)
239 total_lines += lines
240 total_code += codelines
241 end
242 show_line("TOTAL", total_lines, total_code)
686d615 Added RubyGem support.
jimweirich authored Nov 16, 2003
243 end
244
245 ARCHIVEDIR = '/mnt/usb'
246
247 task :archive => [:package] do
248 cp FileList["pkg/*.tgz", "pkg/*.zip", "pkg/*.gem"], ARCHIVEDIR
249 end
250
47fb00b Added comments.
jimweirich authored Nov 12, 2003
251 # Define an optional publish target in an external file. If the
252 # publish.rf file is not found, the publish targets won't be defined.
8934145 make contrib_test of sys work
jimweirich authored Nov 11, 2003
253
254 load "publish.rf" if File.exist? "publish.rf"
b412f1a Added support tasks to Rakefile: dbg, todo, and rubyfiles
jimweirich authored Mar 25, 2005
255
256 # Support Tasks ------------------------------------------------------
257
258 desc "Look for TODO and FIXME tags in the code"
259 task :todo do
c8197eb added rcov and unit tests
jimweirich authored Jun 1, 2006
260 FileList['**/*.rb'].exclude('pkg').egrep(/#.*(FIXME|TODO|TBD)/)
b412f1a Added support tasks to Rakefile: dbg, todo, and rubyfiles
jimweirich authored Mar 25, 2005
261 end
262
263 desc "Look for Debugging print lines"
264 task :dbg do
c8197eb added rcov and unit tests
jimweirich authored Jun 1, 2006
265 FileList['**/*.rb'].egrep(/\bDBG|\bbreakpoint\b/)
b412f1a Added support tasks to Rakefile: dbg, todo, and rubyfiles
jimweirich authored Mar 25, 2005
266 end
267
268 desc "List all ruby files"
269 task :rubyfiles do
270 puts Dir['**/*.rb'].reject { |fn| fn =~ /^pkg/ }
271 puts Dir['bin/*'].reject { |fn| fn =~ /CVS|(~$)|(\.rb$)/ }
272 end
dd80335 Added rf abbreviation.
jimweirich authored Jan 17, 2006
273 task :rf => :rubyfiles
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
274
275 # --------------------------------------------------------------------
276 # Creating a release
277
278 desc "Make a new release"
279 task :release => [
280 :prerelease,
281 :clobber,
538b7b7 renamed test targets
jimweirich authored Jan 18, 2006
282 :test_all,
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
283 :update_version,
284 :package,
285 :tag] do
286
287 announce
288 announce "**************************************************************"
289 announce "* Release #{PKG_VERSION} Complete."
290 announce "* Packages ready to upload."
291 announce "**************************************************************"
292 announce
293 end
294
295 # Validate that everything is ready to go for a release.
296 task :prerelease do
297 announce
298 announce "**************************************************************"
299 announce "* Making RubyGem Release #{PKG_VERSION}"
300 announce "* (current version #{CURRENT_VERSION})"
301 announce "**************************************************************"
302 announce
303
304 # Is a release number supplied?
305 unless ENV['REL']
306 fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
307 end
308
309 # Is the release different than the current release.
310 # (or is REUSE set?)
311 if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
312 fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
313 end
314
315 # Are all source files checked in?
316 if ENV['RELTEST']
317 announce "Release Task Testing, skipping checked-in file test"
318 else
319 announce "Checking for unchecked-in files..."
320 data = `cvs -q update`
321 unless data =~ /^$/
322 fail "CVS update is not clean ... do you have unchecked-in files?"
323 end
324 announce "No outstanding checkins found ... OK"
325 end
326 end
327
328 task :update_version => [:prerelease] do
329 if PKG_VERSION == CURRENT_VERSION
330 announce "No version change ... skipping version update"
331 else
332 announce "Updating Rake version to #{PKG_VERSION}"
4c1c728 pre-tag commit
jimweirich authored Mar 25, 2005
333 open("lib/rake.rb") do |rakein|
334 open("lib/rake.rb.new", "w") do |rakeout|
335 rakein.each do |line|
336 if line =~ /^RAKEVERSION\s*=\s*/
337 rakeout.puts "RAKEVERSION = '#{PKG_VERSION}'"
338 else
339 rakeout.puts line
340 end
341 end
342 end
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
343 end
4c1c728 pre-tag commit
jimweirich authored Mar 25, 2005
344 mv "lib/rake.rb.new", "lib/rake.rb"
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
345 if ENV['RELTEST']
346 announce "Release Task Testing, skipping commiting of new version"
347 else
05a9e50 Added shame task to the Rakefile.
jimweirich authored Oct 26, 2006
348 sh %{cvs commit -m "Updated to version #{PKG_VERSION}" lib/rake.rb} # "
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
349 end
350 end
351 end
352
4a96a5e adding release management task
jimweirich authored Mar 25, 2005
353 desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
da7cb40 Added release management to Rakefile
jimweirich authored Mar 25, 2005
354 task :tag => [:prerelease] do
355 reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
356 reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
357 announce "Tagging CVS with [#{reltag}]"
358 if ENV['RELTEST']
359 announce "Release Task Testing, skipping CVS tagging"
360 else
361 sh %{cvs tag #{reltag}}
362 end
363 end
df6dea6 Clobber TAGS.
jimweirich authored Sep 5, 2005
364
3096101 Added installation task for missing jamis template.
jimweirich authored Jan 19, 2006
365 desc "Install the jamis RDoc template"
366 task :install_jamis_template do
367 require 'rbconfig'
368 dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
369 fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
370 install "doc/jamis.rb", dest_dir, :verbose => true
371 end
372
df6dea6 Clobber TAGS.
jimweirich authored Sep 5, 2005
373 # Require experimental XForge/Metaproject support.
374
375 load 'xforge.rf' if File.exist?('xforge.rf')
3210a02 Added require rubygems to a test, cleaning dot files, parameterized tar
jimweirich authored Feb 14, 2007
376
377 task :where_am_i do
378 puts Rake.original_dir
379 end
Something went wrong with that request. Please try again.