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