Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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