Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 348 lines (279 sloc) 9.867 kB
4a89120 Reorganizing for release.
deveiant authored
1 #!rake
2 #
e6e693c Integrated new Rake build system.
deveiant authored
3 # Darkfish-Rdoc rakefile
4a89120 Reorganizing for release.
deveiant authored
4 #
e6e693c Integrated new Rake build system.
deveiant authored
5 # Based on various other Rakefiles, especially one by Ben Bleything
6 #
d9eed3b @ged Updating build system for Mercurial
authored
7 # Copyright (c) 2007-2009 The FaerieMUD Consortium
4a89120 Reorganizing for release.
deveiant authored
8 #
9 # Authors:
460dbb9 * Added README
deveiant authored
10 # * Michael Granger <ged@FaerieMUD.org>
4a89120 Reorganizing for release.
deveiant authored
11 #
12
13 BEGIN {
14 require 'pathname'
15 basedir = Pathname.new( __FILE__ ).dirname
e6e693c Integrated new Rake build system.
deveiant authored
16
17 libdir = basedir + "lib"
18 extdir = basedir + "ext"
4a89120 Reorganizing for release.
deveiant authored
19
20 $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
e6e693c Integrated new Rake build system.
deveiant authored
21 $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
4a89120 Reorganizing for release.
deveiant authored
22 }
23
d9eed3b @ged Updating build system for Mercurial
authored
24 begin
25 require 'readline'
26 include Readline
27 rescue LoadError
28 # Fall back to a plain prompt
29 def readline( text )
30 $stderr.print( text.chomp )
31 return $stdin.gets
32 end
33 end
4a89120 Reorganizing for release.
deveiant authored
34
e6e693c Integrated new Rake build system.
deveiant authored
35 require 'rbconfig'
4a89120 Reorganizing for release.
deveiant authored
36 require 'rake'
e6e693c Integrated new Rake build system.
deveiant authored
37 require 'rake/testtask'
4a89120 Reorganizing for release.
deveiant authored
38 require 'rake/packagetask'
e6e693c Integrated new Rake build system.
deveiant authored
39 require 'rake/clean'
d9eed3b @ged Updating build system for Mercurial
authored
40 # require 'rake/191_compat.rb'
4a89120 Reorganizing for release.
deveiant authored
41
42 $dryrun = false
43
e6e693c Integrated new Rake build system.
deveiant authored
44 ### Config constants
45 BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
d89170d Updated the build system.
deveiant authored
46 BINDIR = BASEDIR + 'bin'
4a89120 Reorganizing for release.
deveiant authored
47 LIBDIR = BASEDIR + 'lib'
e6e693c Integrated new Rake build system.
deveiant authored
48 EXTDIR = BASEDIR + 'ext'
49 DOCSDIR = BASEDIR + 'docs'
4a89120 Reorganizing for release.
deveiant authored
50 PKGDIR = BASEDIR + 'pkg'
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
51 DATADIR = BASEDIR + 'data'
4a89120 Reorganizing for release.
deveiant authored
52
d9eed3b @ged Updating build system for Mercurial
authored
53 MANUALDIR = DOCSDIR + 'manual'
54
d89170d Updated the build system.
deveiant authored
55 PROJECT_NAME = 'Darkfish-Rdoc'
56 PKG_NAME = PROJECT_NAME.downcase
e6e693c Integrated new Rake build system.
deveiant authored
57 PKG_SUMMARY = 'A pretty (different) Rdoc HTML generator'
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
58
d9eed3b @ged Updating build system for Mercurial
authored
59 # Cruisecontrol stuff
60 CC_BUILD_LABEL = ENV['CC_BUILD_LABEL']
61 CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
62
a466b51 * Updated build system
deveiant authored
63 VERSION_FILE = LIBDIR + 'rdoc/generator/darkfish.rb'
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
64 if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
65 PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
66 elsif VERSION_FILE.exist?
67 PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
68 else
69 PKG_VERSION = '0.0.0'
70 end
71
e6e693c Integrated new Rake build system.
deveiant authored
72 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
73 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
4a89120 Reorganizing for release.
deveiant authored
74
d9eed3b @ged Updating build system for Mercurial
authored
75 # Universal VCS constants
76 DEFAULT_EDITOR = 'vi'
77 COMMIT_MSG_FILE = 'commit-msg.txt'
78 FILE_INDENT = " " * 12
79 LOG_INDENT = " " * 3
80
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
81 EXTCONF = EXTDIR + 'extconf.rb'
82
d9eed3b @ged Updating build system for Mercurial
authored
83 ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
e6e693c Integrated new Rake build system.
deveiant authored
84
d9eed3b @ged Updating build system for Mercurial
authored
85 TEXT_FILES = Rake::FileList.new( %w[Rakefile ChangeLog README LICENSE] )
86 BIN_FILES = Rake::FileList.new( "#{BINDIR}/*" )
87 LIB_FILES = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
88 EXT_FILES = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
89 DATA_FILES = Rake::FileList.new( "#{DATADIR}/**/*" )
e6e693c Integrated new Rake build system.
deveiant authored
90
91 SPECDIR = BASEDIR + 'spec'
d89170d Updated the build system.
deveiant authored
92 SPECLIBDIR = SPECDIR + 'lib'
d9eed3b @ged Updating build system for Mercurial
authored
93 SPEC_FILES = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
e6e693c Integrated new Rake build system.
deveiant authored
94
95 TESTDIR = BASEDIR + 'tests'
d9eed3b @ged Updating build system for Mercurial
authored
96 TEST_FILES = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
e6e693c Integrated new Rake build system.
deveiant authored
97
2be4997 Checkpoint commit
deveiant authored
98 RAKE_TASKDIR = BASEDIR + 'rake'
d9eed3b @ged Updating build system for Mercurial
authored
99 RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
100 PKG_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
101 PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
102
103 RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
2be4997 Checkpoint commit
deveiant authored
104
105 LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
106
d9eed3b @ged Updating build system for Mercurial
authored
107 EXTRA_PKGFILES = Rake::FileList.new
108 EXTRA_PKGFILES.include( "#{BASEDIR}/lib/rdoc/generator/**/*.{css,rhtml,png,js}" )
b905bbf * Updated build system.
deveiant authored
109
110 RELEASE_FILES = TEXT_FILES +
111 SPEC_FILES +
112 TEST_FILES +
d89170d Updated the build system.
deveiant authored
113 BIN_FILES +
b905bbf * Updated build system.
deveiant authored
114 LIB_FILES +
115 EXT_FILES +
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
116 DATA_FILES +
b905bbf * Updated build system.
deveiant authored
117 RAKE_TASKLIBS +
118 EXTRA_PKGFILES
119
d9eed3b @ged Updating build system for Mercurial
authored
120
121 RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
e6e693c Integrated new Rake build system.
deveiant authored
122
123 COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
124 RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
125 RCOV_OPTS = [
126 '--exclude', RCOV_EXCLUDES,
127 '--xrefs',
128 '--save',
129 '--callsites',
130 #'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
131 ]
132
133
d9eed3b @ged Updating build system for Mercurial
authored
134 ### Load some task libraries that need to be loaded early
135 if !RAKE_TASKDIR.exist?
136 $stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
137 ans = readline( "for you? [y]" )
138 ans = 'y' if !ans.nil? && ans.empty?
139
140 if ans =~ /^y/i
141 $stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
142 system 'hg', 'clone', RAKE_TASKLIBS_URL, RAKE_TASKDIR
143 if ! $?.success?
144 fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
145 end
146 else
147 $stderr.puts "Then I'm afraid I can't continue. Best of luck."
148 fail "Rake tasklibs not present."
149 end
4a89120 Reorganizing for release.
deveiant authored
150
d9eed3b @ged Updating build system for Mercurial
authored
151 RAKE_TASKLIBS.include( "#{RAKE_TASKDIR}/*.rb" )
152 end
4a89120 Reorganizing for release.
deveiant authored
153
e6e693c Integrated new Rake build system.
deveiant authored
154 require RAKE_TASKDIR + 'helpers.rb'
887082e * Set up rdoc options to use itself for docs.
deveiant authored
155
e6e693c Integrated new Rake build system.
deveiant authored
156 # Define some constants that depend on the 'svn' tasklib
d9eed3b @ged Updating build system for Mercurial
authored
157 if hg = which( 'hg' )
158 id = IO.read('|-') or exec hg, 'id', '-q'
159 PKG_BUILD = id.chomp
160 else
161 PKG_BUILD = 0
162 end
e6e693c Integrated new Rake build system.
deveiant authored
163 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
164 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
165
166 # Documentation constants
d89170d Updated the build system.
deveiant authored
167 RDOCDIR = DOCSDIR + 'api'
887082e * Set up rdoc options to use itself for docs.
deveiant authored
168 RDOC_OPTIONS = [
169 '-w', '4',
d9eed3b @ged Updating build system for Mercurial
authored
170 '-HN',
e6e693c Integrated new Rake build system.
deveiant authored
171 '-i', '.',
887082e * Set up rdoc options to use itself for docs.
deveiant authored
172 '-m', 'README',
d9eed3b @ged Updating build system for Mercurial
authored
173 '-t', PKG_NAME,
174 '-W', 'http://deveiate.org/projects/Darkfish-Rdoc/browser/'
887082e * Set up rdoc options to use itself for docs.
deveiant authored
175 ]
176
e6e693c Integrated new Rake build system.
deveiant authored
177 # Release constants
178 SMTP_HOST = 'mail.faeriemud.org'
179 SMTP_PORT = 465 # SMTP + SSL
4a89120 Reorganizing for release.
deveiant authored
180
e6e693c Integrated new Rake build system.
deveiant authored
181 # Project constants
991ee53 Updated build system.
deveiant authored
182 PROJECT_HOST = 'deveiate'
183 PROJECT_PUBDIR = '/usr/local/www/public/code'
e6e693c Integrated new Rake build system.
deveiant authored
184 PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
3ab6126 * Updated build system
deveiant authored
185 PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
186 PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
4a89120 Reorganizing for release.
deveiant authored
187
11e2451 Checkpoint commit
deveiant authored
188 # Rubyforge stuff
189 RUBYFORGE_GROUP = 'deveiate'
190 RUBYFORGE_PROJECT = 'darkfish-rdoc'
191
e6e693c Integrated new Rake build system.
deveiant authored
192 # Gem dependencies: gemname => version
193 DEPENDENCIES = {
d9eed3b @ged Updating build system for Mercurial
authored
194 'rdoc' => '>= 2.3',
e6e693c Integrated new Rake build system.
deveiant authored
195 }
4a89120 Reorganizing for release.
deveiant authored
196
d89170d Updated the build system.
deveiant authored
197 # Developer Gem dependencies: gemname => version
198 DEVELOPMENT_DEPENDENCIES = {
199 'amatch' => '>= 0.2.3',
200 'rake' => '>= 0.8.1',
201 'rcodetools' => '>= 0.7.0.0',
202 'rcov' => '>= 0',
203 'RedCloth' => '>= 4.0.3',
204 'rspec' => '>= 0',
205 'rubyforge' => '>= 0',
206 'termios' => '>= 0',
207 'text-format' => '>= 1.0.0',
208 'tmail' => '>= 1.2.3.1',
209 'ultraviolet' => '>= 0.10.2',
210 'libxml-ruby' => '>= 0.8.3',
d9eed3b @ged Updating build system for Mercurial
authored
211 'rdoc' => '>= 2.4.3',
d89170d Updated the build system.
deveiant authored
212 }
213
e6e693c Integrated new Rake build system.
deveiant authored
214 # Non-gem requirements: packagename => version
215 REQUIREMENTS = {
216 }
4a89120 Reorganizing for release.
deveiant authored
217
e6e693c Integrated new Rake build system.
deveiant authored
218 # RubyGem specification
219 GEMSPEC = Gem::Specification.new do |gem|
220 gem.name = PKG_NAME.downcase
221 gem.version = PKG_VERSION
4a89120 Reorganizing for release.
deveiant authored
222
e6e693c Integrated new Rake build system.
deveiant authored
223 gem.summary = PKG_SUMMARY
d9eed3b @ged Updating build system for Mercurial
authored
224 gem.description = [
225 "A complete replacement for the default HTML generator for Rdoc, the",
226 "API documentation-extraction system for Ruby. ",
227 ].join( "\n" )
228 gem.post_install_message = [
229 "To use the Darkfish formatter, just add '-f darkfish' to your rdoc command of choice.",
230 ].join( "\n" )
231
232 gem.authors = "Michael Granger"
233 gem.email = ["ged@FaerieMUD.org"]
e6e693c Integrated new Rake build system.
deveiant authored
234 gem.homepage = 'http://deveiate.org/projects/Darkfish-Rdoc/'
11e2451 Checkpoint commit
deveiant authored
235 gem.rubyforge_project = RUBYFORGE_PROJECT
460dbb9 * Added README
deveiant authored
236
e6e693c Integrated new Rake build system.
deveiant authored
237 gem.has_rdoc = true
238 gem.rdoc_options = RDOC_OPTIONS
991ee53 Updated build system.
deveiant authored
239 gem.extra_rdoc_files = %w[ChangeLog README LICENSE]
460dbb9 * Added README
deveiant authored
240
d89170d Updated the build system.
deveiant authored
241 gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
d9eed3b @ged Updating build system for Mercurial
authored
242 gem.executables = BIN_FILES.select {|pn| File.executable?(pn) }.
243 collect {|pn| File.basename(pn) }
244 gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
5e325e3 * Integrated patch from Eric Hodel (drbrain at segment7.net) for RDo…
deveiant authored
245
246 if EXTCONF.exist?
247 gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
248 end
d89170d Updated the build system.
deveiant authored
249
d9eed3b @ged Updating build system for Mercurial
authored
250 gem.files = RELEASE_FILES
251 gem.test_files = SPEC_FILES
252
e6e693c Integrated new Rake build system.
deveiant authored
253 DEPENDENCIES.each do |name, version|
254 version = '>= 0' if version.length.zero?
d89170d Updated the build system.
deveiant authored
255 gem.add_runtime_dependency( name, version )
256 end
d9eed3b @ged Updating build system for Mercurial
authored
257
2a0f6a1 Updated build system to add the workaround for broken developmental d…
deveiant authored
258 # Developmental dependencies don't work as of RubyGems 1.2.0
259 unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" )
260 DEVELOPMENT_DEPENDENCIES.each do |name, version|
261 version = '>= 0' if version.length.zero?
262 gem.add_development_dependency( name, version )
263 end
e6e693c Integrated new Rake build system.
deveiant authored
264 end
d9eed3b @ged Updating build system for Mercurial
authored
265
e6e693c Integrated new Rake build system.
deveiant authored
266 REQUIREMENTS.each do |name, version|
267 gem.requirements << [ name, version ].compact.join(' ')
268 end
460dbb9 * Added README
deveiant authored
269 end
270
e6e693c Integrated new Rake build system.
deveiant authored
271 $trace = Rake.application.options.trace ? true : false
272 $dryrun = Rake.application.options.dryrun ? true : false
273
274
2be4997 Checkpoint commit
deveiant authored
275 # Load any remaining task libraries
276 RAKE_TASKLIBS.each do |tasklib|
d9eed3b @ged Updating build system for Mercurial
authored
277 next if tasklib.to_s =~ %r{/helpers\.rb$}
e6e693c Integrated new Rake build system.
deveiant authored
278 begin
d9eed3b @ged Updating build system for Mercurial
authored
279 trace " loading tasklib %s" % [ tasklib ]
280 import tasklib
e6e693c Integrated new Rake build system.
deveiant authored
281 rescue ScriptError => err
282 fail "Task library '%s' failed to load: %s: %s" %
283 [ tasklib, err.class.name, err.message ]
284 trace "Backtrace: \n " + err.backtrace.join( "\n " )
285 rescue => err
286 log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
287 [ tasklib, err.class.name, err.message ]
288 trace "Backtrace: \n " + err.backtrace.join( "\n " )
289 end
290 end
460dbb9 * Added README
deveiant authored
291
e6e693c Integrated new Rake build system.
deveiant authored
292 # Load any project-specific rules defined in 'Rakefile.local' if it exists
2be4997 Checkpoint commit
deveiant authored
293 import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
4a89120 Reorganizing for release.
deveiant authored
294
887082e * Set up rdoc options to use itself for docs.
deveiant authored
295
e6e693c Integrated new Rake build system.
deveiant authored
296 #####################################################################
297 ### T A S K S
298 #####################################################################
887082e * Set up rdoc options to use itself for docs.
deveiant authored
299
e6e693c Integrated new Rake build system.
deveiant authored
300 ### Default task
3ab6126 * Updated build system
deveiant authored
301 task :default => [:clean, :local, :spec, :rdoc, :package]
302
303 ### Task the local Rakefile can append to -- no-op by default
304 task :local
887082e * Set up rdoc options to use itself for docs.
deveiant authored
305
306
e6e693c Integrated new Rake build system.
deveiant authored
307 ### Task: clean
308 CLEAN.include 'coverage'
309 CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
887082e * Set up rdoc options to use itself for docs.
deveiant authored
310
e6e693c Integrated new Rake build system.
deveiant authored
311 ### Task: changelog
d9eed3b @ged Updating build system for Mercurial
authored
312 file 'ChangeLog' do |task|
e6e693c Integrated new Rake build system.
deveiant authored
313 log "Updating #{task.name}"
887082e * Set up rdoc options to use itself for docs.
deveiant authored
314
d9eed3b @ged Updating build system for Mercurial
authored
315 changelog = make_changelog()
e6e693c Integrated new Rake build system.
deveiant authored
316 File.open( task.name, 'w' ) do |fh|
317 fh.print( changelog )
4a89120 Reorganizing for release.
deveiant authored
318 end
319 end
320
321
e6e693c Integrated new Rake build system.
deveiant authored
322 ### Task: cruise (Cruisecontrol task)
323 desc "Cruisecontrol build"
a85e78f Updated build system.
deveiant authored
324 task :cruise => [:clean, 'spec:quiet', :package] do |task|
e6e693c Integrated new Rake build system.
deveiant authored
325 raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
d9eed3b @ged Updating build system for Mercurial
authored
326 artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
e6e693c Integrated new Rake build system.
deveiant authored
327 artifact_dir.mkpath
d9eed3b @ged Updating build system for Mercurial
authored
328
8f2b434 * Bumped version to 1.1.3
deveiant authored
329 coverage = BASEDIR + 'coverage'
330 if coverage.exist? && coverage.directory?
331 $stderr.puts "Copying coverage stats..."
332 FileUtils.cp_r( 'coverage', artifact_dir )
333 end
d9eed3b @ged Updating build system for Mercurial
authored
334
e6e693c Integrated new Rake build system.
deveiant authored
335 $stderr.puts "Copying packages..."
336 FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
4a89120 Reorganizing for release.
deveiant authored
337 end
338
339
2be4997 Checkpoint commit
deveiant authored
340 desc "Update the build system to the latest version"
341 task :update_build do
342 log "Updating the build system"
d9eed3b @ged Updating build system for Mercurial
authored
343 run 'hg', '-R', RAKE_TASKDIR, 'pull', '-u'
2be4997 Checkpoint commit
deveiant authored
344 log "Updating the Rakefile"
345 sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
346 end
347
Something went wrong with that request. Please try again.