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:
|
|
10 |
# * Michae Granger and Mahlon Smith <ged@FaerieMUD.org, mahlon@martini.nu>
|
|
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 |
|
|
24 |
|
|
25 |
require 'rbconfig'
|
|
26 |
require 'rubygems'
|
|
27 |
require 'rake'
|
|
28 |
require 'rake/rdoctask'
|
|
29 |
require 'rake/testtask'
|
|
30 |
require 'rake/packagetask'
|
|
31 |
require 'rake/clean'
|
|
32 |
|
|
33 |
$dryrun = false
|
|
34 |
|
|
35 |
### Config constants
|
|
36 |
BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
|
|
37 |
LIBDIR = BASEDIR + 'lib'
|
|
38 |
EXTDIR = BASEDIR + 'ext'
|
|
39 |
DOCSDIR = BASEDIR + 'docs'
|
|
40 |
PKGDIR = BASEDIR + 'pkg'
|
|
41 |
|
|
42 |
PKG_NAME = 'jparallel'
|
|
43 |
PKG_SUMMARY = 'A "parallel jail shell" written in Ruby'
|
|
44 |
VERSION_FILE = LIBDIR + 'jparallel.rb'
|
|
45 |
PKG_VERSION = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ]
|
|
46 |
PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
|
|
47 |
GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
|
|
48 |
|
|
49 |
ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
|
|
50 |
|
|
51 |
TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
|
|
52 |
LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
|
|
53 |
EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
|
|
54 |
|
|
55 |
SPECDIR = BASEDIR + 'spec'
|
|
56 |
SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ }
|
|
57 |
|
|
58 |
TESTDIR = BASEDIR + 'tests'
|
|
59 |
TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ }
|
|
60 |
|
|
61 |
RAKE_TASKDIR = BASEDIR + 'rake'
|
|
62 |
RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' )
|
|
63 |
|
|
64 |
LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
|
|
65 |
|
|
66 |
EXTRA_PKGFILES = []
|
|
67 |
EXTRA_PKGFILES += Pathname.glob( BASEDIR + 'examples/*.{c,rb}' ).delete_if {|item| item =~ /\.svn/ }
|
|
68 |
|
|
69 |
RELEASE_FILES = TEXT_FILES +
|
|
70 |
SPEC_FILES +
|
|
71 |
TEST_FILES +
|
|
72 |
LIB_FILES +
|
|
73 |
EXT_FILES +
|
|
74 |
RAKE_TASKLIBS +
|
|
75 |
EXTRA_PKGFILES
|
|
76 |
|
|
77 |
RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
|
|
78 |
|
|
79 |
COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
|
|
80 |
RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
|
|
81 |
RCOV_OPTS = [
|
|
82 |
'--exclude', RCOV_EXCLUDES,
|
|
83 |
'--xrefs',
|
|
84 |
'--save',
|
|
85 |
'--callsites',
|
|
86 |
#'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
|
|
87 |
]
|
|
88 |
|
|
89 |
|
|
90 |
# Subversion constants -- directory names for releases and tags
|
|
91 |
SVN_TRUNK_DIR = 'trunk'
|
|
92 |
SVN_RELEASES_DIR = 'releases'
|
|
93 |
SVN_BRANCHES_DIR = 'branches'
|
|
94 |
SVN_TAGS_DIR = 'tags'
|
|
95 |
|
|
96 |
SVN_DOTDIR = BASEDIR + '.svn'
|
|
97 |
SVN_ENTRIES = SVN_DOTDIR + 'entries'
|
|
98 |
|
|
99 |
|
|
100 |
### Load some task libraries that need to be loaded early
|
|
101 |
require RAKE_TASKDIR + 'helpers.rb'
|
|
102 |
require RAKE_TASKDIR + 'svn.rb'
|
|
103 |
require RAKE_TASKDIR + 'verifytask.rb'
|
|
104 |
|
|
105 |
# Define some constants that depend on the 'svn' tasklib
|
|
106 |
PKG_BUILD = get_svn_rev( BASEDIR ) || 0
|
|
107 |
SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
|
|
108 |
SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
|
|
109 |
|
|
110 |
# Documentation constants
|
|
111 |
RDOC_OPTIONS = [
|
|
112 |
'-w', '4',
|
|
113 |
'-SHN',
|
|
114 |
'-i', '.',
|
|
115 |
'-m', 'README',
|
|
116 |
'-W', 'http://deveiate.org/projects/Jparallel//browser/trunk/'
|
|
117 |
]
|
|
118 |
|
|
119 |
# Release constants
|
|
120 |
SMTP_HOST = 'mail.faeriemud.org'
|
|
121 |
SMTP_PORT = 465 # SMTP + SSL
|
|
122 |
|
|
123 |
# Project constants
|
|
124 |
PROJECT_HOST = 'deveiate.org'
|
|
125 |
PROJECT_PUBDIR = "/usr/local/www/public/code"
|
|
126 |
PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
|
|
127 |
PROJECT_SCPURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
|
|
128 |
|
|
129 |
# Rubyforge stuff
|
|
130 |
RUBYFORGE_GROUP = 'deveiate'
|
|
131 |
RUBYFORGE_PROJECT = 'jparallel'
|
|
132 |
|
|
133 |
# Gem dependencies: gemname => version
|
|
134 |
DEPENDENCIES = {
|
|
135 |
}
|
|
136 |
|
|
137 |
# Non-gem requirements: packagename => version
|
|
138 |
REQUIREMENTS = {
|
|
139 |
'FreeBSD' => '>= 7.0',
|
|
140 |
}
|
|
141 |
|
|
142 |
# RubyGem specification
|
|
143 |
GEMSPEC = Gem::Specification.new do |gem|
|
|
144 |
gem.name = PKG_NAME.downcase
|
|
145 |
gem.version = PKG_VERSION
|
|
146 |
|
|
147 |
gem.summary = PKG_SUMMARY
|
|
148 |
gem.description = <<-EOD
|
|
149 |
This is shell that can be used to interact with multiple FreeBSD jail instances
|
|
150 |
|
|
151 |
simultaneously. It includes a Ruby binding to the FreeBSD jail(2) functions.
|
|
152 |
EOD
|
|
153 |
|
|
154 |
gem.authors = 'Michae Granger and Mahlon Smith'
|
|
155 |
gem.email = 'ged@FaerieMUD.org, mahlon@martini.nu'
|
|
156 |
gem.homepage = 'http://deveiate.org/projects/Jparallel/'
|
|
157 |
gem.rubyforge_project = RUBYFORGE_PROJECT
|
|
158 |
|
|
159 |
gem.has_rdoc = true
|
|
160 |
gem.rdoc_options = RDOC_OPTIONS
|
|
161 |
|
|
162 |
gem.files = RELEASE_FILES.
|
|
163 |
collect {|f| f.relative_path_from(BASEDIR).to_s }
|
|
164 |
gem.test_files = SPEC_FILES.
|
|
165 |
collect {|f| f.relative_path_from(BASEDIR).to_s }
|
|
166 |
|
|
167 |
DEPENDENCIES.each do |name, version|
|
|
168 |
version = '>= 0' if version.length.zero?
|
|
169 |
gem.add_dependency( name, version )
|
|
170 |
end
|
|
171 |
|
|
172 |
REQUIREMENTS.each do |name, version|
|
|
173 |
gem.requirements << [ name, version ].compact.join(' ')
|
|
174 |
end
|
|
175 |
end
|
|
176 |
|
|
177 |
$trace = Rake.application.options.trace ? true : false
|
|
178 |
$dryrun = Rake.application.options.dryrun ? true : false
|
|
179 |
|
|
180 |
|
|
181 |
# Load any remaining task libraries
|
|
182 |
RAKE_TASKLIBS.each do |tasklib|
|
|
183 |
next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
|
|
184 |
begin
|
|
185 |
require tasklib
|
|
186 |
rescue ScriptError => err
|
|
187 |
fail "Task library '%s' failed to load: %s: %s" %
|
|
188 |
[ tasklib, err.class.name, err.message ]
|
|
189 |
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
|
190 |
rescue => err
|
|
191 |
log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
|
|
192 |
[ tasklib, err.class.name, err.message ]
|
|
193 |
trace "Backtrace: \n " + err.backtrace.join( "\n " )
|
|
194 |
end
|
|
195 |
end
|
|
196 |
|
|
197 |
# Load any project-specific rules defined in 'Rakefile.local' if it exists
|
|
198 |
import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
|
|
199 |
|
|
200 |
|
|
201 |
#####################################################################
|
|
202 |
### T A S K S
|
|
203 |
#####################################################################
|
|
204 |
|
|
205 |
### Default task
|
|
206 |
task :default => [:clean, :spec, :rdoc, :package]
|
|
207 |
|
|
208 |
|
|
209 |
### Task: clean
|
|
210 |
CLEAN.include 'coverage'
|
|
211 |
CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
|
|
212 |
|
|
213 |
# Target to hinge on ChangeLog updates
|
|
214 |
file SVN_ENTRIES
|
|
215 |
|
|
216 |
### Task: changelog
|
|
217 |
file 'ChangeLog' => SVN_ENTRIES.to_s do |task|
|
|
218 |
log "Updating #{task.name}"
|
|
219 |
|
|
220 |
changelog = make_svn_changelog()
|
|
221 |
File.open( task.name, 'w' ) do |fh|
|
|
222 |
fh.print( changelog )
|
|
223 |
end
|
|
224 |
end
|
|
225 |
|
|
226 |
|
|
227 |
### Task: cruise (Cruisecontrol task)
|
|
228 |
desc "Cruisecontrol build"
|
|
229 |
task :cruise => [:clean, :spec, :package] do |task|
|
|
230 |
raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
|
|
231 |
artifact_dir = ARTIFACTS_DIR.cleanpath
|
|
232 |
artifact_dir.mkpath
|
|
233 |
|
|
234 |
$stderr.puts "Copying coverage stats..."
|
|
235 |
FileUtils.cp_r( 'coverage', artifact_dir )
|
|
236 |
|
|
237 |
$stderr.puts "Copying packages..."
|
|
238 |
FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
|
|
239 |
end
|
|
240 |
|
|
241 |
|
|
242 |
desc "Update the build system to the latest version"
|
|
243 |
task :update_build do
|
|
244 |
log "Updating the build system"
|
|
245 |
sh 'svn', 'up', RAKE_TASKDIR
|
|
246 |
log "Updating the Rakefile"
|
|
247 |
sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
|
|
248 |
end
|
|
249 |
|