Commits

Michael Granger  committed 86c8058

Updated build system

  • Participants
  • Parent commits ca82fcb

Comments (0)

Files changed (2)

 #
 # Based on various other Rakefiles, especially one by Ben Bleything
 #
-# Copyright (c) 2008 The FaerieMUD Consortium
+# Copyright (c) 2007-2009 The FaerieMUD Consortium
 #
 # Authors:
 #  * Michael Granger <ged@FaerieMUD.org>
 	$LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
 }
 
+begin
+	require 'readline'
+	include Readline
+rescue LoadError
+	# Fall back to a plain prompt
+	def readline( text )
+		$stderr.print( text.chomp )
+		return $stdin.gets
+	end
+end
 
 require 'rbconfig'
-require 'rubygems'
 require 'rake'
-require 'rake/rdoctask'
 require 'rake/testtask'
 require 'rake/packagetask'
 require 'rake/clean'
+# require 'rake/191_compat.rb'
 
 $dryrun = false
 
 ### Config constants
 BASEDIR       = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
+BINDIR        = BASEDIR + 'bin'
 LIBDIR        = BASEDIR + 'lib'
 EXTDIR        = BASEDIR + 'ext'
 DOCSDIR       = BASEDIR + 'docs'
 PKGDIR        = BASEDIR + 'pkg'
+DATADIR       = BASEDIR + 'data'
 
-PKG_NAME      = 'io-reactor'
+MANUALDIR     = DOCSDIR + 'manual'
+
+PROJECT_NAME  = 'IO-Reactor'
+PKG_NAME      = PROJECT_NAME.downcase
 PKG_SUMMARY   = 'Multiplexed IO Reactor class'
+
+# Cruisecontrol stuff
+CC_BUILD_LABEL     = ENV['CC_BUILD_LABEL']
+CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
+
 VERSION_FILE  = LIBDIR + 'io/reactor.rb'
-PKG_VERSION   = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ]
+if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
+	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
+elsif VERSION_FILE.exist?
+	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ]
+else
+	PKG_VERSION = '0.0.0'
+end
+
 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
 
-ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
+# Universal VCS constants
+DEFAULT_EDITOR  = 'vi'
+COMMIT_MSG_FILE = 'commit-msg.txt'
+FILE_INDENT     = " " * 12
+LOG_INDENT      = " " * 3
 
-TEXT_FILES    = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
-LIB_FILES     = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
-EXT_FILES     = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
+EXTCONF       = EXTDIR + 'extconf.rb'
+
+ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
+
+TEXT_FILES    = Rake::FileList.new( %w[Rakefile ChangeLog README LICENSE] )
+BIN_FILES     = Rake::FileList.new( "#{BINDIR}/*" )
+LIB_FILES     = Rake::FileList.new( "#{LIBDIR}/**/*.rb" )
+EXT_FILES     = Rake::FileList.new( "#{EXTDIR}/**/*.{c,h,rb}" )
+DATA_FILES    = Rake::FileList.new( "#{DATADIR}/**/*" )
 
 SPECDIR       = BASEDIR + 'spec'
-SPEC_FILES    = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ }
+SPECLIBDIR    = SPECDIR + 'lib'
+SPEC_FILES    = Rake::FileList.new( "#{SPECDIR}/**/*_spec.rb", "#{SPECLIBDIR}/**/*.rb" )
 
 TESTDIR       = BASEDIR + 'tests'
-TEST_FILES    = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ }
+TEST_FILES    = Rake::FileList.new( "#{TESTDIR}/**/*.tests.rb" )
 
 RAKE_TASKDIR  = BASEDIR + 'rake'
-RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' )
+RAKE_TASKLIBS = Rake::FileList.new( "#{RAKE_TASKDIR}/*.rb" )
+PKG_TASKLIBS  = Rake::FileList.new( "#{RAKE_TASKDIR}/{191_compat,helpers,packaging,rdoc,testing}.rb" )
+PKG_TASKLIBS.include( "#{RAKE_TASKDIR}/manual.rb" ) if MANUALDIR.exist?
+
+RAKE_TASKLIBS_URL = 'http://repo.deveiate.org/rake-tasklibs'
 
 LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
 
-EXTRA_PKGFILES = []
-EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'examples/*.rb' ).delete_if {|item| item =~ /\.svn/ } 
+EXTRA_PKGFILES = Rake::FileList.new
+EXTRA_PKGFILES.include( "#{BASEDIR}/examples/*.rb" )
 
 RELEASE_FILES = TEXT_FILES + 
 	SPEC_FILES + 
 	TEST_FILES + 
+	BIN_FILES +
 	LIB_FILES + 
 	EXT_FILES + 
+	DATA_FILES + 
 	RAKE_TASKLIBS +
 	EXTRA_PKGFILES
 
-RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
+
+RELEASE_FILES << LOCAL_RAKEFILE.to_s if LOCAL_RAKEFILE.exist?
 
 COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
 RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
   ]
 
 
-# Subversion constants -- directory names for releases and tags
-SVN_TRUNK_DIR    = 'trunk'
-SVN_RELEASES_DIR = 'releases'
-SVN_BRANCHES_DIR = 'branches'
-SVN_TAGS_DIR     = 'tags'
+### Load some task libraries that need to be loaded early
+if !RAKE_TASKDIR.exist?
+	$stderr.puts "It seems you don't have the build task directory. Shall I fetch it "
+	ans = readline( "for you? [y]" )
+	ans = 'y' if !ans.nil? && ans.empty?
 
-SVN_DOTDIR       = BASEDIR + '.svn'
-SVN_ENTRIES      = SVN_DOTDIR + 'entries'
+	if ans =~ /^y/i
+		$stderr.puts "Okay, fetching #{RAKE_TASKLIBS_URL} into #{RAKE_TASKDIR}..."
+		system 'hg', 'clone', RAKE_TASKLIBS_URL, RAKE_TASKDIR
+		if ! $?.success?
+			fail "Damn. That didn't work. Giving up; maybe try manually fetching?"
+		end
+	else
+		$stderr.puts "Then I'm afraid I can't continue. Best of luck."
+		fail "Rake tasklibs not present."
+	end
 
+	RAKE_TASKLIBS.include( "#{RAKE_TASKDIR}/*.rb" )
+end
 
-### Load some task libraries that need to be loaded early
 require RAKE_TASKDIR + 'helpers.rb'
-require RAKE_TASKDIR + 'svn.rb'
-require RAKE_TASKDIR + 'verifytask.rb'
 
 # Define some constants that depend on the 'svn' tasklib
-PKG_BUILD = get_svn_rev( BASEDIR ) || 0
+if hg = which( 'hg' )
+	id = IO.read('|-') or exec hg, 'id', '-q'
+	PKG_BUILD = id.chomp
+else
+	PKG_BUILD = 0
+end
 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
 
 # Documentation constants
+RDOCDIR = DOCSDIR + 'api'
 RDOC_OPTIONS = [
 	'-w', '4',
-	'-SHN',
+	'-HN',
 	'-i', '.',
 	'-m', 'README',
-	'-W', 'http://deveiate.org/projects/IO-Reactor//browser/trunk/'
+	'-t', PKG_NAME,
+	'-W', 'http://deveiate.org/projects/IO-Reactor/browser/'
   ]
 
 # Release constants
 SMTP_PORT = 465 # SMTP + SSL
 
 # Project constants
-PROJECT_HOST = 'deveiate.org'
-PROJECT_PUBDIR = "/usr/local/www/public/code"
+PROJECT_HOST = 'deveiate'
+PROJECT_PUBDIR = '/usr/local/www/code'
 PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
 PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
 PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
 DEPENDENCIES = {
 }
 
+# Developer Gem dependencies: gemname => version
+DEVELOPMENT_DEPENDENCIES = {
+	'amatch'      => '>= 0.2.3',
+	'rake'        => '>= 0.8.1',
+	'rcodetools'  => '>= 0.7.0.0',
+	'rcov'        => '>= 0',
+	'RedCloth'    => '>= 4.0.3',
+	'rspec'       => '>= 0',
+	'rubyforge'   => '>= 0',
+	'termios'     => '>= 0',
+	'text-format' => '>= 1.0.0',
+	'tmail'       => '>= 1.2.3.1',
+	'ultraviolet' => '>= 0.10.2',
+	'libxml-ruby' => '>= 0.8.3',
+	'rdoc'        => '>= 2.4.3',
+}
+
 # Non-gem requirements: packagename => version
 REQUIREMENTS = {
 }
 	gem.version           = PKG_VERSION
 
 	gem.summary           = PKG_SUMMARY
-	gem.description       = <<-EOD
-	A pure-Ruby implementation of an asynchronous multiplexed IO
-	Reactor which is based on the Reactor design pattern found in _Pattern-Oriented
-	Software Architecture, Volume 2: Patterns for Concurrent and Networked
-	Objects_. It allows a single thread to demultiplex and dispatch events from one
-	or more IO objects to the appropriate handler.
-	EOD
+	gem.description       = [
+		"A pure-Ruby implementation of an asynchronous multiplexed IO",
+		"Reactor which is based on the Reactor design pattern found in _Pattern-Oriented",
+		"Software Architecture, Volume 2: Patterns for Concurrent and Networked",
+		"Objects_. It allows a single thread to demultiplex and dispatch events from one",
+		"or more IO objects to the appropriate handler.",
+  	  ].join( "\n" )
 
-	gem.authors           = 'Michael Granger'
-	gem.email             = 'ged@FaerieMUD.org'
+	gem.authors           = "Michael Granger"
+	gem.email             = ["ged@FaerieMUD.org"]
 	gem.homepage          = 'http://deveiate.org/projects/IO-Reactor/'
 	gem.rubyforge_project = RUBYFORGE_PROJECT
 
 	gem.has_rdoc          = true
 	gem.rdoc_options      = RDOC_OPTIONS
+	gem.extra_rdoc_files  = %w[ChangeLog README LICENSE]
 
-	gem.files             = RELEASE_FILES.
-		collect {|f| f.relative_path_from(BASEDIR).to_s }
-	gem.test_files        = SPEC_FILES.
-		collect {|f| f.relative_path_from(BASEDIR).to_s }
-		
+	gem.bindir            = BINDIR.relative_path_from(BASEDIR).to_s
+	gem.executables       = BIN_FILES.select {|pn| File.executable?(pn) }.
+	                            collect {|pn| File.basename(pn) }
+	gem.require_paths << EXTDIR.relative_path_from( BASEDIR ).to_s if EXTDIR.exist?
+
+	if EXTCONF.exist?
+		gem.extensions << EXTCONF.relative_path_from( BASEDIR ).to_s
+	end
+
+	gem.files             = RELEASE_FILES
+	gem.test_files        = SPEC_FILES
+
 	DEPENDENCIES.each do |name, version|
 		version = '>= 0' if version.length.zero?
-		gem.add_dependency( name, version )
+		gem.add_runtime_dependency( name, version )
 	end
-	
+
+	# Developmental dependencies don't work as of RubyGems 1.2.0
+	unless Gem::Version.new( Gem::RubyGemsVersion ) <= Gem::Version.new( "1.2.0" )
+		DEVELOPMENT_DEPENDENCIES.each do |name, version|
+			version = '>= 0' if version.length.zero?
+			gem.add_development_dependency( name, version )
+		end
+	end
+
 	REQUIREMENTS.each do |name, version|
 		gem.requirements << [ name, version ].compact.join(' ')
 	end
 
 # Load any remaining task libraries
 RAKE_TASKLIBS.each do |tasklib|
-	next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
+	next if tasklib.to_s =~ %r{/helpers\.rb$}
 	begin
-		require tasklib
+		trace "  loading tasklib %s" % [ tasklib ]
+		import tasklib
 	rescue ScriptError => err
 		fail "Task library '%s' failed to load: %s: %s" %
 			[ tasklib, err.class.name, err.message ]
 CLEAN.include 'coverage'
 CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
 
-# Target to hinge on ChangeLog updates
-file SVN_ENTRIES
-
 ### Task: changelog
-file 'ChangeLog' => SVN_ENTRIES.to_s do |task|
+file 'ChangeLog' do |task|
 	log "Updating #{task.name}"
 
-	changelog = make_svn_changelog()
+	changelog = make_changelog()
 	File.open( task.name, 'w' ) do |fh|
 		fh.print( changelog )
 	end
 
 ### Task: cruise (Cruisecontrol task)
 desc "Cruisecontrol build"
-task :cruise => [:clean, :spec, :package] do |task|
+task :cruise => [:clean, 'spec:quiet', :package] do |task|
 	raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
-	artifact_dir = ARTIFACTS_DIR.cleanpath
+	artifact_dir = ARTIFACTS_DIR.cleanpath + (CC_BUILD_LABEL || Time.now.strftime('%Y%m%d-%T'))
 	artifact_dir.mkpath
-	
+
 	coverage = BASEDIR + 'coverage'
 	if coverage.exist? && coverage.directory?
 		$stderr.puts "Copying coverage stats..."
 		FileUtils.cp_r( 'coverage', artifact_dir )
 	end
-	
+
 	$stderr.puts "Copying packages..."
 	FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
 end
 desc "Update the build system to the latest version"
 task :update_build do
 	log "Updating the build system"
-	sh 'svn', 'up', RAKE_TASKDIR
+	run 'hg', '-R', RAKE_TASKDIR, 'pull', '-u'
 	log "Updating the Rakefile"
 	sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
 end
 --- 
+excluded_pkgfiles: []
+
 rubyforge_project: io-reactor
 project_requirements: {}
 
+project_pubdir: /usr/local/www/code
 project_description: |-
   A pure-Ruby implementation of an asynchronous multiplexed IO
   Reactor which is based on the Reactor design pattern found in _Pattern-Oriented
   Objects_. It allows a single thread to demultiplex and dispatch events from one
   or more IO objects to the appropriate handler.
 rubyforge_group: deveiate
-author_name: Michael Granger
+project_pubhost: deveiate
 project_homepage: http://deveiate.org/projects/IO-Reactor/
 project_dependencies: {}
 
 version_file: io/reactor.rb
 additional_pkgfiles: 
 - examples/*.rb
-author_email: ged@FaerieMUD.org
+dev_dependencies: {}
+
+authors: 
+  Michael Granger: ged@FaerieMUD.org
+post_install_message: ""