Commits

Michael Granger committed 405a85e

Updated build system

Comments (0)

Files changed (3)

 
   URL: http://deveiate.org/projects/Ruby-WordNet
 
-* LinkParser (>= 1.0.2) - adds integration for the Ruby Link Grammar Parser by
-  Martin Chase.
+* LinkParser (>= 1.0.5)
 
-  URL: http://dev.faeriemud.org/~stillflame/linkparse.html
-  Download: http://www.faeriemud.org/code/Ruby-LinkParser-0.0.4.tgz
+  URL: http://deveiate.org/projects/Ruby-LinkParser
 
 
 == General Information
 #
 # 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 )
 }
 
-require 'rubygems'
-gem 'rake', '>= 0.8.3'
+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 'rake'
-require 'rake/rdoctask'
 require 'rake/testtask'
 require 'rake/packagetask'
 require 'rake/clean'
+# require 'rake/191_compat.rb'
 
 $dryrun = false
 
 PKGDIR        = BASEDIR + 'pkg'
 DATADIR       = BASEDIR + 'data'
 
+MANUALDIR     = DOCSDIR + 'manual'
+
 PROJECT_NAME  = 'Linguistics'
 PKG_NAME      = PROJECT_NAME.downcase
 PKG_SUMMARY   = 'a framework for building linguistic utilities for Ruby objects'
 
+# Cruisecontrol stuff
+CC_BUILD_LABEL     = ENV['CC_BUILD_LABEL']
+CC_BUILD_ARTIFACTS = ENV['CC_BUILD_ARTIFACTS'] || 'artifacts'
+
 VERSION_FILE  = LIBDIR + 'linguistics.rb'
 if VERSION_FILE.exist? && buildrev = ENV['CC_BUILD_LABEL']
 	PKG_VERSION = VERSION_FILE.read[ /VERSION\s*=\s*['"](\d+\.\d+\.\d+)['"]/, 1 ] + '.' + buildrev
 PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
 GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
 
+# Universal VCS constants
+DEFAULT_EDITOR  = 'vi'
+COMMIT_MSG_FILE = 'commit-msg.txt'
+FILE_INDENT     = " " * 12
+LOG_INDENT      = " " * 3
+
 EXTCONF       = EXTDIR + 'extconf.rb'
 
-ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
+ARTIFACTS_DIR = Pathname.new( CC_BUILD_ARTIFACTS )
 
-TEXT_FILES    = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
-BIN_FILES     = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ }
-LIB_FILES     = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
-EXT_FILES     = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
-DATA_FILES    = Pathname.glob( DATADIR + '**/*' ).delete_if {|item| item =~ /\.svn/ }
+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'
 SPECLIBDIR    = SPECDIR + 'lib'
-SPEC_FILES    = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } +
-                Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
+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.concat Pathname.glob( BASEDIR + 'README.english' ).delete_if {|item| item =~ /\.svn/ } 
+EXTRA_PKGFILES = Rake::FileList.new
+EXTRA_PKGFILES.include( "#{BASEDIR}/examples/*.rb" )
+EXTRA_PKGFILES.include( "#{BASEDIR}/README.english" )
 
 RELEASE_FILES = TEXT_FILES + 
 	SPEC_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"
 
 RDOCDIR = DOCSDIR + 'api'
 RDOC_OPTIONS = [
 	'-w', '4',
-	'-SHN',
+	'-HN',
 	'-i', '.',
 	'-m', 'README',
 	'-t', PKG_NAME,
-	'-W', 'http://deveiate.org/projects/Linguistics/browser/trunk/'
+	'-W', 'http://deveiate.org/projects/Linguistics/browser/'
   ]
 
 # Release constants
 	'tmail'       => '>= 1.2.3.1',
 	'ultraviolet' => '>= 0.10.2',
 	'libxml-ruby' => '>= 0.8.3',
+	'rdoc'        => '>= 2.4.3',
 	'wordnet' => '>=0.0.5',
 	'linkparser' => '>=1.0.3',
 }
 		"contains various English-language utilities.",
   	  ].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/Linguistics/'
 	gem.rubyforge_project = RUBYFORGE_PROJECT
 
 	gem.extra_rdoc_files  = %w[ChangeLog README LICENSE]
 
 	gem.bindir            = BINDIR.relative_path_from(BASEDIR).to_s
-	gem.executables       = BIN_FILES.select {|pn| pn.executable? }.
-		collect {|pn| pn.relative_path_from(BINDIR).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.
-		collect {|f| f.relative_path_from(BASEDIR).to_s }
-	gem.test_files        = SPEC_FILES.
-		collect {|f| f.relative_path_from(BASEDIR).to_s }
-		
+	gem.files             = RELEASE_FILES
+	gem.test_files        = SPEC_FILES
+
 	DEPENDENCIES.each do |name, version|
 		version = '>= 0' if version.length.zero?
 		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|
 			gem.add_development_dependency( name, version )
 		end
 	end
-	
+
 	REQUIREMENTS.each do |name, version|
 		gem.requirements << [ name, version ].compact.join(' ')
 	end
 end
 
-# Manual-generation config
-MANUALDIR = DOCSDIR + 'manual'
-
 $trace = Rake.application.options.trace ? true : false
 $dryrun = Rake.application.options.dryrun ? true : false
 
 
 # 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
 desc "Cruisecontrol build"
 task :cruise => [:clean, 'spec:quiet', :package] do |task|
 	raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
-	artifact_dir = ARTIFACTS_DIR.cleanpath + ENV['CC_BUILD_LABEL']
+	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
 --- 
-project_pubdir: /usr/local/www/public/code
-project_pubhost: deveiate
-project_homepage: http://deveiate.org/projects/Linguistics/
-rubyforge_group: deveiate
+excluded_pkgfiles: []
+
+rubyforge_project: linguistics
 project_requirements: {}
 
-author_name: Michael Granger
+project_pubdir: /usr/local/www/public/code
 project_description: |-
   in any language. It includes a generic language-independant front end, a
   module for mapping language codes into language names, and a module which
   contains various English-language utilities.
+rubyforge_group: deveiate
+project_pubhost: deveiate
+project_homepage: http://deveiate.org/projects/Linguistics/
 project_dependencies: {}
 
 project_summary: a framework for building linguistic utilities for Ruby objects
+project_name: Linguistics
 version_file: linguistics.rb
 additional_pkgfiles: 
 - examples/*.rb
 dev_dependencies: 
   wordnet: ">=0.0.5"
   linkparser: ">=1.0.3"
-author_email: ged@FaerieMUD.org
+authors: 
+  Michael Granger: ged@FaerieMUD.org
 post_install_message: ""
-project_name: Linguistics
-rubyforge_project: linguistics