PageRenderTime 43ms CodeModel.GetById 26ms app.highlight 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Rakefile.old

https://bitbucket.org/laika/thingfish
Unknown | 151 lines | 121 code | 30 blank | 0 comment | 0 complexity | 9007c42b9bec9fe8293df038dbfd7114 MD5 | raw file
Possible License(s): BSD-3-Clause
  1#!rake -*- ruby -*-
  2#
  3# ThingFish rakefile
  4#
  5# Based on Ben Bleything's Rakefile for Linen (URL?)
  6#
  7# Copyright (c) 2007-2009, Michael Granger and Mahlon E. Smith
  8#
  9# Mistakes:
 10#  * Michael Granger <ged@FaerieMUD.org>
 11#
 12
 13BEGIN {
 14	require 'pathname'
 15	basedir = Pathname.new( __FILE__ ).dirname
 16	libdir = basedir + 'lib'
 17	docsdir = basedir + 'docs'
 18
 19	$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
 20	$LOAD_PATH.unshift( docsdir.to_s ) unless $LOAD_PATH.include?( docsdir.to_s )
 21}
 22
 23
 24require 'rake'
 25require 'tmpdir'
 26require 'pathname'
 27
 28$dryrun = false
 29
 30# Pathname constants
 31BASEDIR         = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
 32BINDIR          = BASEDIR + 'bin'
 33LIBDIR          = BASEDIR + 'lib'
 34EXTDIR          = BASEDIR + 'ext'
 35DOCSDIR         = BASEDIR + 'docs'
 36VARDIR          = BASEDIR + 'var'
 37MISCDIR         = BASEDIR + 'misc'
 38WWWDIR          = VARDIR  + 'www'
 39STATICWWWDIR    = WWWDIR  + 'static'
 40MANUALDIR       = DOCSDIR + 'manual'
 41MANUALOUTPUTDIR = STATICWWWDIR    + 'manual'
 42RDOCDIR         = MANUALOUTPUTDIR + 'api'
 43PKGDIR          = BASEDIR + 'pkg'
 44ARTIFACTS_DIR   = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || '' )
 45RAKE_TASKDIR    = MISCDIR + 'rake'
 46
 47TEXT_FILES    = %w( Rakefile README LICENSE QUICKSTART ).
 48	collect {|filename| BASEDIR + filename }
 49
 50SPECDIR       = BASEDIR + 'spec'
 51SPEC_FILES    = Pathname.glob( SPECDIR + '**/*_spec.rb' ).
 52	delete_if {|item| item =~ /\.svn/ }
 53# Ideally, this should be automatically generated.
 54SPEC_EXCLUDES = 'spec,monkeypatches,/Library/Ruby,/var/lib,/usr/local/lib'
 55
 56BIN_FILES     = Pathname.glob( BINDIR + '*').
 57	delete_if {|item| item =~ /\.svn/ }
 58LIB_FILES     = Pathname.glob( LIBDIR + '**/*.rb').
 59	delete_if {|item| item =~ /\.svn/ }
 60
 61RELEASE_FILES = BIN_FILES + TEXT_FILES + LIB_FILES + SPEC_FILES
 62
 63# Plugin constants
 64PLUGINDIR        = BASEDIR + 'plugins'
 65PLUGINS          = Pathname.glob( PLUGINDIR + '*' ).select {|path| path.directory? }
 66PLUGIN_LIBS      = PLUGINS.collect {|dir| Pathname.glob(dir + 'lib/**/*.rb') }.flatten
 67PLUGIN_RAKEFILES = PLUGINS.collect {|dir| dir + 'Rakefile' }
 68PLUGIN_SPECFILES = PLUGINS.collect {|dir| Pathname.glob(dir + 'spec/**/*_spec.rb') }.flatten
 69
 70require RAKE_TASKDIR + 'helpers.rb'
 71
 72### Package constants
 73PKG_NAME      = 'thingfish'
 74PKG_VERSION   = find_pattern_in_file( /VERSION = '(\d+\.\d+\.\d+)'/, LIBDIR + 'thingfish.rb' ).first
 75PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
 76
 77RELEASE_NAME  = "REL #{PKG_VERSION}"
 78
 79if Rake.application.options.trace
 80	$trace = true
 81	log "$trace is enabled"
 82end
 83
 84if Rake.application.options.dryrun
 85	$dryrun = true
 86	log "$dryrun is enabled"
 87	Rake.application.options.dryrun = false
 88end
 89
 90### Load task libraries
 91require RAKE_TASKDIR + 'svn.rb'
 92require RAKE_TASKDIR + 'verifytask.rb'
 93Pathname.glob( RAKE_TASKDIR + '*.rb' ).each do |tasklib|
 94	next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
 95	begin
 96		require tasklib
 97	rescue ScriptError => err
 98		fail "Task library '%s' failed to load: %s: %s" %
 99			[ tasklib, err.class.name, err.message ]
100		trace "Backtrace: \n  " + err.backtrace.join( "\n  " )
101	rescue => err
102		log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
103			[ tasklib, err.class.name, err.message ]
104		trace "Backtrace: \n  " + err.backtrace.join( "\n  " )
105	end
106end
107
108
109### Default task
110task :default  => [:clean, :build, :spec, :verify, :package]
111
112
113### Task: clean
114desc "Clean pkg, coverage, and rdoc; remove .bak files"
115task :clean => [ :clobber_rdoc, :clobber_package, :clobber_coverage, :clobber_manual ] do
116	files = FileList['**/*.bak']
117	files.clear_exclude
118	File.rm( files ) unless files.empty?
119	FileUtils.rm_rf( 'artifacts' )
120end
121
122
123### Task: docs -- Convenience task for rebuilding dynamic docs, including coverage, api 
124### docs, and manual
125multitask :docs => [ :manual, :coverage, :rdoc ] do
126	log "All documentation built."
127end
128
129
130### Task: generate ctags
131### This assumes exuberant ctags, since ctags 'native' doesn't support ruby anyway.
132desc "Generate a ctags 'tags' file from ThingFish source"
133task :ctags do
134	run %w{ ctags -R lib plugins misc }
135end
136
137
138### Cruisecontrol task
139desc "Cruisecontrol build"
140task :cruise => [:clean, 'spec:text', :package] do |task|
141	raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
142	artifact_dir = ARTIFACTS_DIR.cleanpath
143	artifact_dir.mkpath
144	
145	$stderr.puts "Copying coverage stats..."
146	FileUtils.cp_r( 'coverage', artifact_dir )
147	
148	$stderr.puts "Copying packages..."
149	FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
150end
151