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