author | Mahlon E. Smith <mahlon@martini.nu> |
Tue, 03 Mar 2009 22:23:45 +0000 | |
changeset 7 | 4460fc10c6a3 |
parent 3 | 7f6da371e2ce |
permissions | -rw-r--r-- |
0 | 1 |
#!rake |
2 |
# |
|
3 |
# jparallel rakefile |
|
4 |
# |
|
5 |
# Based on various other Rakefiles, especially one by Ben Bleything |
|
6 |
# |
|
7 |
# Copyright (c) 2008 The FaerieMUD Consortium |
|
8 |
# |
|
9 |
# Authors: |
|
2 | 10 |
# * Michael Granger and Mahlon Smith <ged@FaerieMUD.org, mahlon@martini.nu> |
0 | 11 |
# |
12 |
||
13 |
BEGIN { |
|
14 |
require 'pathname' |
|
15 |
basedir = Pathname.new( __FILE__ ).dirname |
|
16 |
||
17 |
libdir = basedir + "lib" |
|
18 |
extdir = basedir + "ext" |
|
19 |
||
20 |
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s ) |
|
21 |
$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s ) |
|
22 |
} |
|
23 |
||
2 | 24 |
require 'rubygems' |
25 |
gem 'rake', '>= 0.8.3' |
|
0 | 26 |
|
27 |
require 'rbconfig' |
|
28 |
require 'rake' |
|
29 |
require 'rake/rdoctask' |
|
30 |
require 'rake/testtask' |
|
31 |
require 'rake/packagetask' |
|
32 |
require 'rake/clean' |
|
33 |
||
34 |
$dryrun = false |
|
35 |
||
36 |
### Config constants |
|
37 |
BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd ) |
|
2 | 38 |
BINDIR = BASEDIR + 'bin' |
0 | 39 |
LIBDIR = BASEDIR + 'lib' |
40 |
EXTDIR = BASEDIR + 'ext' |
|
41 |
DOCSDIR = BASEDIR + 'docs' |
|
42 |
PKGDIR = BASEDIR + 'pkg' |
|
2 | 43 |
DATADIR = BASEDIR + 'data' |
0 | 44 |
|
2 | 45 |
PROJECT_NAME = 'jparallel' |
46 |
PKG_NAME = PROJECT_NAME.downcase |
|
0 | 47 |
PKG_SUMMARY = 'A "parallel jail shell" written in Ruby' |
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
48 |
|
0 | 49 |
VERSION_FILE = LIBDIR + 'jparallel.rb' |
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
50 |
if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL'] |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
51 |
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
52 |
elsif VERSION_FILE.exist? |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
53 |
PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
54 |
else |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
55 |
PKG_VERSION = '0.0.0' |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
56 |
end |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
57 |
|
0 | 58 |
PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}" |
59 |
GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem" |
|
60 |
||
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
61 |
EXTCONF = EXTDIR + 'extconf.rb' |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
62 |
|
0 | 63 |
ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' ) |
64 |
||
65 |
TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename } |
|
2 | 66 |
BIN_FILES = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ } |
0 | 67 |
LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } |
68 |
EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ } |
|
2 | 69 |
DATA_FILES = Pathname.glob( DATADIR + '**/*' ).delete_if {|item| item =~ /\.svn/ } |
0 | 70 |
|
71 |
SPECDIR = BASEDIR + 'spec' |
|
2 | 72 |
SPECLIBDIR = SPECDIR + 'lib' |
73 |
SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } + |
|
74 |
Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } |
|
0 | 75 |
|
76 |
TESTDIR = BASEDIR + 'tests' |
|
77 |
TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ } |
|
78 |
||
79 |
RAKE_TASKDIR = BASEDIR + 'rake' |
|
80 |
RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' ) |
|
81 |
||
82 |
LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local' |
|
83 |
||
84 |
EXTRA_PKGFILES = [] |
|
2 | 85 |
EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ } |
0 | 86 |
|
87 |
RELEASE_FILES = TEXT_FILES + |
|
88 |
SPEC_FILES + |
|
89 |
TEST_FILES + |
|
2 | 90 |
BIN_FILES + |
0 | 91 |
LIB_FILES + |
92 |
EXT_FILES + |
|
2 | 93 |
DATA_FILES + |
0 | 94 |
RAKE_TASKLIBS + |
95 |
EXTRA_PKGFILES |
|
96 |
||
97 |
RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist? |
|
98 |
||
99 |
COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0 |
|
100 |
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib' |
|
101 |
RCOV_OPTS = [ |
|
102 |
'--exclude', RCOV_EXCLUDES, |
|
103 |
'--xrefs', |
|
104 |
'--save', |
|
105 |
'--callsites', |
|
106 |
#'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0 |
|
107 |
] |
|
108 |
||
109 |
||
110 |
# Subversion constants -- directory names for releases and tags |
|
111 |
SVN_TRUNK_DIR = 'trunk' |
|
112 |
SVN_RELEASES_DIR = 'releases' |
|
113 |
SVN_BRANCHES_DIR = 'branches' |
|
114 |
SVN_TAGS_DIR = 'tags' |
|
115 |
||
116 |
SVN_DOTDIR = BASEDIR + '.svn' |
|
117 |
SVN_ENTRIES = SVN_DOTDIR + 'entries' |
|
118 |
||
119 |
||
120 |
### Load some task libraries that need to be loaded early |
|
121 |
require RAKE_TASKDIR + 'helpers.rb' |
|
122 |
require RAKE_TASKDIR + 'svn.rb' |
|
123 |
require RAKE_TASKDIR + 'verifytask.rb' |
|
124 |
||
125 |
# Define some constants that depend on the 'svn' tasklib |
|
126 |
PKG_BUILD = get_svn_rev( BASEDIR ) || 0 |
|
127 |
SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}" |
|
128 |
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem" |
|
129 |
||
130 |
# Documentation constants |
|
2 | 131 |
RDOCDIR = DOCSDIR + 'api' |
0 | 132 |
RDOC_OPTIONS = [ |
133 |
'-w', '4', |
|
134 |
'-SHN', |
|
135 |
'-i', '.', |
|
136 |
'-m', 'README', |
|
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
137 |
'-W', 'http://deveiate.org/projects/jParallel//browser/trunk/' |
0 | 138 |
] |
139 |
||
140 |
# Release constants |
|
141 |
SMTP_HOST = 'mail.faeriemud.org' |
|
142 |
SMTP_PORT = 465 # SMTP + SSL |
|
143 |
||
144 |
# Project constants |
|
145 |
PROJECT_HOST = 'deveiate.org' |
|
146 |
PROJECT_PUBDIR = "/usr/local/www/public/code" |
|
147 |
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}" |
|
2 | 148 |
PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}" |
149 |
PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}" |
|
0 | 150 |
|
151 |
# Rubyforge stuff |
|
152 |
RUBYFORGE_GROUP = 'deveiate' |
|
153 |
RUBYFORGE_PROJECT = 'jparallel' |
|
154 |
||
155 |
# Gem dependencies: gemname => version |
|
156 |
DEPENDENCIES = { |
|
157 |
} |
|
158 |
||
2 | 159 |
# Developer Gem dependencies: gemname => version |
160 |
DEVELOPMENT_DEPENDENCIES = { |
|
161 |
'amatch' => '>= 0.2.3', |
|
162 |
'rake' => '>= 0.8.1', |
|
163 |
'rcodetools' => '>= 0.7.0.0', |
|
164 |
'rcov' => '>= 0', |
|
165 |
'RedCloth' => '>= 4.0.3', |
|
166 |
'rspec' => '>= 0', |
|
167 |
'rubyforge' => '>= 0', |
|
168 |
'termios' => '>= 0', |
|
169 |
'text-format' => '>= 1.0.0', |
|
170 |
'tmail' => '>= 1.2.3.1', |
|
171 |
'ultraviolet' => '>= 0.10.2', |
|
172 |
'libxml-ruby' => '>= 0.8.3', |
|
173 |
} |
|
174 |
||
0 | 175 |
# Non-gem requirements: packagename => version |
176 |
REQUIREMENTS = { |
|
2 | 177 |
'FreeBSD' => '>= 5.0', |
0 | 178 |
} |
179 |
||
180 |
# RubyGem specification |
|
181 |
GEMSPEC = Gem::Specification.new do |gem| |
|
182 |
gem.name = PKG_NAME.downcase |
|
183 |
gem.version = PKG_VERSION |
|
184 |
||
185 |
gem.summary = PKG_SUMMARY |
|
186 |
gem.description = <<-EOD |
|
187 |
This is shell that can be used to interact with multiple FreeBSD jail instances |
|
188 |
simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions. |
|
189 |
EOD |
|
190 |
||
2 | 191 |
gem.authors = 'Michael Granger and Mahlon Smith' |
0 | 192 |
gem.email = 'ged@FaerieMUD.org, mahlon@martini.nu' |
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
193 |
gem.homepage = 'http://deveiate.org/projects/jParallel/' |
0 | 194 |
gem.rubyforge_project = RUBYFORGE_PROJECT |
195 |
||
196 |
gem.has_rdoc = true |
|
197 |
gem.rdoc_options = RDOC_OPTIONS |
|
198 |
||
2 | 199 |
gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s |
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
200 |
|
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
201 |
if EXTCONF.exist? |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
202 |
gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s |
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
203 |
end |
2 | 204 |
|
0 | 205 |
gem.files = RELEASE_FILES. |
206 |
collect {|f| f.relative_path_from(BASEDIR).to_s } |
|
207 |
gem.test_files = SPEC_FILES. |
|
208 |
collect {|f| f.relative_path_from(BASEDIR).to_s } |
|
209 |
||
210 |
DEPENDENCIES.each do |name, version| |
|
211 |
version = '>= 0' if version.length.zero? |
|
2 | 212 |
gem.add_runtime_dependency( name, version ) |
213 |
end |
|
214 |
||
215 |
# Developmental dependencies don't work as of RubyGems 1.2.0 |
|
216 |
unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" ) |
|
217 |
DEVELOPMENT_DEPENDENCIES.each do |name, version| |
|
218 |
version = '>= 0' if version.length.zero? |
|
219 |
gem.add_development_dependency( name, version ) |
|
220 |
end |
|
0 | 221 |
end |
222 |
||
223 |
REQUIREMENTS.each do |name, version| |
|
224 |
gem.requirements << [ name, version ].compact.join(' ') |
|
225 |
end |
|
226 |
end |
|
227 |
||
2 | 228 |
# Manual-generation config |
229 |
MANUALDIR = DOCSDIR + 'manual' |
|
230 |
||
0 | 231 |
$trace = Rake.application.options.trace ? true : false |
232 |
$dryrun = Rake.application.options.dryrun ? true : false |
|
233 |
||
234 |
||
235 |
# Load any remaining task libraries |
|
236 |
RAKE_TASKLIBS.each do |tasklib| |
|
237 |
next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$} |
|
238 |
begin |
|
239 |
require tasklib |
|
240 |
rescue ScriptError => err |
|
241 |
fail "Task library '%s' failed to load: %s: %s" % |
|
242 |
[ tasklib, err.class.name, err.message ] |
|
243 |
trace "Backtrace: \n " + err.backtrace.join( "\n " ) |
|
244 |
rescue => err |
|
245 |
log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." % |
|
246 |
[ tasklib, err.class.name, err.message ] |
|
247 |
trace "Backtrace: \n " + err.backtrace.join( "\n " ) |
|
248 |
end |
|
249 |
end |
|
250 |
||
251 |
# Load any project-specific rules defined in 'Rakefile.local' if it exists |
|
252 |
import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist? |
|
253 |
||
254 |
||
255 |
##################################################################### |
|
256 |
### T A S K S |
|
257 |
##################################################################### |
|
258 |
||
259 |
### Default task |
|
2 | 260 |
task :default => [:clean, :local, :spec, :rdoc, :package] |
261 |
||
262 |
### Task the local Rakefile can append to -- no-op by default |
|
263 |
task :local |
|
0 | 264 |
|
265 |
||
266 |
### Task: clean |
|
267 |
CLEAN.include 'coverage' |
|
268 |
CLOBBER.include 'artifacts', 'coverage.info', PKGDIR |
|
269 |
||
270 |
# Target to hinge on ChangeLog updates |
|
271 |
file SVN_ENTRIES |
|
272 |
||
273 |
### Task: changelog |
|
274 |
file 'ChangeLog' => SVN_ENTRIES.to_s do |task| |
|
275 |
log "Updating #{task.name}" |
|
276 |
||
277 |
changelog = make_svn_changelog() |
|
278 |
File.open( task.name, 'w' ) do |fh| |
|
279 |
fh.print( changelog ) |
|
280 |
end |
|
281 |
end |
|
282 |
||
283 |
||
284 |
### Task: cruise (Cruisecontrol task) |
|
285 |
desc "Cruisecontrol build" |
|
2 | 286 |
task :cruise => [:clean, 'spec:quiet', :package] do |task| |
0 | 287 |
raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty? |
3
7f6da371e2ce
* Converted from Mkrf-based build back to mkmf.
Michael Granger <ged@FaerieMUD.org>
parents:
2
diff
changeset
|
288 |
artifact_dir = ARTIFACTS_DIR.cleanpath + ENV['CC_BUILD_LABEL'] |
0 | 289 |
artifact_dir.mkpath |
290 |
||
2 | 291 |
coverage = BASEDIR + 'coverage' |
292 |
if coverage.exist? && coverage.directory? |
|
293 |
$stderr.puts "Copying coverage stats..." |
|
294 |
FileUtils.cp_r( 'coverage', artifact_dir ) |
|
295 |
end |
|
0 | 296 |
|
297 |
$stderr.puts "Copying packages..." |
|
298 |
FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir ) |
|
299 |
end |
|
300 |
||
301 |
||
302 |
desc "Update the build system to the latest version" |
|
303 |
task :update_build do |
|
304 |
log "Updating the build system" |
|
305 |
sh 'svn', 'up', RAKE_TASKDIR |
|
306 |
log "Updating the Rakefile" |
|
307 |
sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile' |
|
308 |
end |
|
309 |