Changeset 454

Show
Ignore:
Timestamp:
07/11/08 18:00:34 (7 weeks ago)
Author:
deveiant
Message:
  • Started conversion to unified cross-project rake-based build system
Location:
trunk
Files:
1 added
1 removed
3 modified

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:externals set to
  • trunk/Rakefile

    r452 r454  
    33# Arrow rakefile 
    44# 
    5 # Originally based on Ben Bleything's Rakefile for Linen 
    6 # 
    7 # Copyright (c) 2007, 2008 The FaerieMUD Consortium 
     5# Based on various other Rakefiles, especially one by Ben Bleything 
     6# 
     7# Copyright (c) 2008 The FaerieMUD Consortium 
    88# 
    99# Authors: 
    1010#  * Michael Granger <ged@FaerieMUD.org> 
    11 #  * Jeremiah Jordan <phaedrus@FaerieMUD.org> 
    1211# 
    1312 
     
    1615    basedir = Pathname.new( __FILE__ ).dirname 
    1716 
    18     libdir = basedir + 'lib' 
    19     docsdir = basedir + 'docs' 
     17    libdir = basedir + "lib" 
     18    extdir = basedir + "ext" 
    2019 
    2120    $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s ) 
    22     $LOAD_PATH.unshift( docsdir.to_s ) unless $LOAD_PATH.include?( docsdir.to_s ) 
     21    $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s ) 
    2322} 
    2423 
     
    2726require 'rubygems' 
    2827require 'rake' 
    29 require 'pathname' 
    30 require 'apache/fakerequest' 
    31  
    32 begin 
    33     require 'arrow' 
    34 rescue LoadError => err 
    35     $stderr.puts "Arrow didn't load cleanly: #{err.message}" 
    36 end 
    37  
    38 include Config 
    39  
    40  
    41 PKG_NAME        = 'arrow' 
    42 PKG_VERSION     = Arrow::VERSION 
    43 PKG_FILE_NAME   = "#{PKG_NAME.capitalize}-#{PKG_VERSION}" 
    44  
    45 PKG_SUMMARY     = "Arrow - A Ruby web application framework" 
    46  
    47 RELEASE_NAME    = PKG_FILE_NAME 
    48  
    49 BASEDIR         = Pathname.new( __FILE__ ).dirname.expand_path.relative_path_from( Pathname.getwd ) 
    50 DOCSDIR         = BASEDIR + 'docs'  
    51 MANUALDIR       = DOCSDIR + 'manual' 
    52 MANUALOUTPUTDIR = MANUALDIR + 'output' 
    53 APIDOCSDIR      = DOCSDIR + 'api' 
    54  
    55 TESTDIR         = BASEDIR + 'tests' 
    56 TEST_FILES      = Pathname.glob( TESTDIR + '**/*.tests.rb' ). 
    57     delete_if {|item| item =~ /\.svn/ } 
    58  
    59 SPECDIR         = BASEDIR + 'spec' 
    60 SPEC_FILES      = Pathname.glob( SPECDIR + '**/*_spec.rb' ). 
    61     delete_if {|item| item =~ /\.svn/ } 
    62  
    63 LIBDIR          = BASEDIR + 'lib' 
    64 LIB_FILES       = Pathname.glob( LIBDIR + '**/*.rb' ). 
    65     delete_if {|item| item =~ /\.svn/ } 
    66  
    67 TEXT_FILES      = %w( Rakefile LICENSE README ) 
    68  
    69 RELEASE_FILES   = TEXT_FILES + LIB_FILES + SPEC_FILES 
    70  
     28require 'rake/rdoctask' 
     29require 'rake/testtask' 
     30require 'rake/packagetask' 
     31require 'rake/clean' 
     32 
     33$dryrun = false 
     34 
     35### Config constants 
     36BASEDIR       = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd ) 
     37LIBDIR        = BASEDIR + 'lib' 
     38EXTDIR        = BASEDIR + 'ext' 
     39DOCSDIR       = BASEDIR + 'docs' 
     40PKGDIR        = BASEDIR + 'pkg' 
     41RAKE_TASKDIR  = BASEDIR + 'rake' 
     42 
     43PKG_NAME      = 'arrow' 
     44PKG_SUMMARY   = '' 
     45VERSION_FILE  = LIBDIR + 'arrow.rb' 
     46PKG_VERSION   = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ] 
     47PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}" 
     48GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem" 
     49 
     50RELEASE_NAME  = "RELEASE_#{PKG_VERSION.gsub(/\./, '_')}" 
     51 
     52ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' ) 
     53 
     54TEXT_FILES    = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename } 
     55LIB_FILES     = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ } 
     56EXT_FILES     = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ } 
     57 
     58SPECDIR       = BASEDIR + 'spec' 
     59SPEC_FILES    = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } 
     60SPEC_EXCLUDES = 'spec,/Library/Ruby,/var/lib,/usr/local/lib' 
     61 
     62TESTDIR       = BASEDIR + 'tests' 
     63TEST_FILES    = Pathname.glob( TESTDIR + '**/*.tests.rb' ) 
     64 
     65RELEASE_FILES = FileList[ TEXT_FILES + SPEC_FILES + TEST_FILES + LIB_FILES + EXT_FILES ] 
     66 
     67 
     68RCOV_OPTS = [ 
     69    '--exclude', SPEC_EXCLUDES, 
     70    '--xrefs', 
     71    '--save', 
     72    '--callsites' 
     73  ] 
     74 
     75 
     76### Load some task libraries that need to be loaded early 
     77require RAKE_TASKDIR + 'helpers.rb' 
     78require RAKE_TASKDIR + 'svn.rb' 
     79require RAKE_TASKDIR + 'verifytask.rb' 
     80 
     81# Define some constants that depend on the 'svn' tasklib 
     82PKG_BUILD = get_svn_rev( BASEDIR ) || 0 
     83SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}" 
     84SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem" 
    7185 
    7286# Documentation constants 
     
    7690    '-i', '.', 
    7791    '-m', 'README', 
    78     '-W', %Q{http://deveiate.org/projects/#{PKG_NAME.capitalize}/browser/trunk/} 
     92    '-W', 'http://deveiate.org/projects/Arrow/browser/trunk/' 
    7993  ] 
    8094 
     
    86100PROJECT_HOST = 'deveiate.org' 
    87101PROJECT_PUBDIR = "/usr/local/www/public/code" 
    88 PROJECT_PUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}" 
    89102PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}" 
    90 PROJECT_DOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}" 
     103PROJECT_SCPURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}" 
     104 
     105# Gem dependencies: gemname => version 
     106DEPENDENCIES = { 
     107#   'mongrel'       => '', 
     108} 
     109 
     110# Non-gem requirements: packagename => version 
     111REQUIREMENTS = { 
     112#   'Apache'  => '>= 2.2.6', 
     113} 
    91114 
    92115# RubyGem specification 
    93 GEMSPEC = Gem::Specification.new do |gem| 
    94     gem.name        = PKG_NAME 
    95     gem.version     = PKG_VERSION 
    96  
    97     gem.summary     = PKG_SUMMARY 
    98     gem.description = <<-EOD 
    99     Arrow is a web application framework for mod_ruby. It was designed to make 
    100     development of web applications under Apache easier and more fun without 
    101     sacrificing the power of being able to access the native Apache API. 
     116GEMSPEC   = Gem::Specification.new do |gem| 
     117    gem.name              = PKG_NAME.downcase 
     118    gem.version           = PKG_VERSION 
     119 
     120    gem.summary           = PKG_SUMMARY 
     121    gem.description       = <<-EOD 
     122 
     123    A mod_ruby web application framework 
     124 
    102125    EOD 
    103126 
    104     gem.authors     = "Michael Granger, Martin Chase, Dave McCorkhill, Jeremiah Jordan" 
    105     gem.email       = "ged@FaerieMUD.org" 
    106     gem.homepage    = "http://deveiate.org/projects/Arrow" 
     127    gem.authors           = 'Michael Granger' 
     128    gem.email             = 'ged@FaerieMUD.org' 
     129    gem.homepage          = 'http://deveiate.org/projects/Arrow' 
    107130    gem.rubyforge_project = 'deveiate' 
    108131 
    109     gem.has_rdoc    = true 
    110  
    111     gem.files       = RELEASE_FILES.collect {|pn| pn.to_s } 
    112     gem.test_files  = [ SPEC_FILES + TEST_FILES ].flatten.collect {|pn| pn.to_s } 
    113  
    114     gem.requirements << "mod_ruby >= 1.2.6" 
    115  
    116     gem.add_dependency( 'ruby-cache', '>= 0.3.0' ) 
    117     gem.add_dependency( 'formvalidator', '>= 0.1.3' ) 
    118     gem.add_dependency( 'pluginfactory', '>= 1.0.2' ) 
    119 end 
    120  
    121 # Load task plugins 
    122 RAKE_TASKDIR = BASEDIR + 'rake' 
     132    gem.has_rdoc          = true 
     133    gem.rdoc_options      = RDOC_OPTIONS 
     134 
     135    gem.files             = RELEASE_FILES. 
     136        collect {|f| f.relative_path_from(BASEDIR).to_s } 
     137    gem.test_files        = SPEC_FILES. 
     138        collect {|f| f.relative_path_from(BASEDIR).to_s } 
     139         
     140    DEPENDENCIES.each do |name, version| 
     141        version = '>= 0' if version.length.zero? 
     142        gem.add_dependency( name, version ) 
     143    end 
     144     
     145    REQUIREMENTS.each do |name, version| 
     146        gem.requirements << [ name, version ].compact.join(' ') 
     147    end 
     148end 
     149 
     150 
     151# Load any remaining task libraries 
    123152Pathname.glob( RAKE_TASKDIR + '*.rb' ).each do |tasklib| 
    124     next if tasklib =~ %r{/helpers.rb$} 
     153    RELEASE_FILES.include( tasklib ) 
     154 
     155    next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$} 
    125156    begin 
    126157        require tasklib 
     
    136167end 
    137168 
    138 # Define some constants that depend on the 'svn' tasklib 
    139 PKG_BUILD = get_svn_rev( BASEDIR ) || 0 
    140 SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}" 
    141 SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem" 
    142  
    143 # Support old-style trace and dryrun 
    144 if Rake.application.options.trace 
    145     $trace = true 
    146     log "$trace is enabled" 
    147 else 
    148     $trace = false 
    149 end 
    150  
    151 if Rake.application.options.dryrun 
    152     $dryrun = true 
    153     log "$dryrun is enabled" 
    154 else 
    155     $dryrun = false 
    156 end 
    157  
     169$trace = Rake.application.options.trace ? true : false 
     170$dryrun = Rake.application.options.dryrun ? true : false 
     171 
     172# Load any project-specific rules defined in 'Rakefile.local' if it exists 
     173LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local' 
     174if LOCAL_RAKEFILE.exist? 
     175    import LOCAL_RAKEFILE  
     176    RELEASE_FILES.include( LOCAL_RAKEFILE.to_s ) 
     177end 
     178 
     179 
     180##################################################################### 
     181### T A S K S    
     182##################################################################### 
    158183 
    159184### Default task 
    160 task :default  => [:all_tests, :docs, :package] 
    161  
    162 ### New and legacy tests 
    163 task :all_tests => ["spec:quiet", :test] 
    164  
    165 ### Documentation task 
    166 task :docs do 
    167     log "Building API docs" 
    168     Rake::Task[:rdoc].invoke 
    169     log "Building the manual" 
    170     Rake::Task[:manual].invoke 
    171 end 
     185task :default  => [:clean, :spec, :rdoc, :package] 
     186 
    172187 
    173188### Task: clean 
    174 desc "Clean pkg, coverage, and rdoc; remove .bak files" 
    175 task :clean => [ :clobber_rdoc, :clobber_manual, :clobber_package, 'coverage:clobber' ] do 
    176     files = FileList['**/*{.bak,~}'] 
    177     files.clear_exclude 
    178     rm( files, :verbose => true ) unless files.empty? 
    179 end 
    180  
    181  
    182 ### Task: rdoc 
    183 begin 
    184     gem 'darkfish-rdoc' 
    185     require 'rake/rdoctask' 
     189CLEAN.include 'coverage' 
     190CLOBBER.include 'artifacts', 'coverage.info', PKGDIR 
     191 
     192 
     193### Cruisecontrol task 
     194desc "Cruisecontrol build" 
     195task :cruise => [:clean, :spec, :package] do |task| 
     196    raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty? 
     197    artifact_dir = ARTIFACTS_DIR.cleanpath 
     198    artifact_dir.mkpath 
    186199     
    187     Rake::RDocTask.new do |rdoc| 
    188         rdoc.rdoc_dir = APIDOCSDIR.to_s 
    189         rdoc.title    = "Arrow #{PKG_VERSION}" 
    190  
    191         rdoc.options += [ 
    192             '-w', '4', 
    193             '-SHN', 
    194             '-i', 'docs', 
    195             '-f', 'darkfish', 
    196             '-m', 'README', 
    197             '-W', 'http://deveiate.org/projects/Arrow/browser/trunk/' 
    198           ] 
     200    $stderr.puts "Copying coverage stats..." 
     201    FileUtils.cp_r( 'coverage', artifact_dir ) 
    199202     
    200         rdoc.rdoc_files.include 'README' 
    201         rdoc.rdoc_files.include LIB_FILES. 
    202             collect {|file| file.relative_path_from(BASEDIR).to_s } 
    203     end 
    204      
    205 rescue LoadError => err 
    206     task :no_rdoc do 
    207         $stderr.puts "API documentation tasks not defined: %s" % [ err.message ] 
    208     end 
    209      
    210     task :rdoc => :no_rdoc 
    211 end 
    212  
    213  
    214 ### Copy method for resources -- passed as a block to the various file tasks that copy 
    215 ### resources to the output directory. 
    216 def copy_resource( task ) 
    217     source = task.prerequisites[ 1 ] 
    218     target = task.name 
    219      
    220     when_writing do 
    221         log "  #{source} -> #{target}" 
    222         mkpath File.dirname( target ) 
    223         cp source, target, :verbose => $trace 
    224     end 
    225 end 
    226      
    227  
    228 ### Task: manual 
    229 Manual::GenTask.new( :manual ) do |manual| 
    230     manual.metadata.version = PKG_VERSION 
    231     manual.metadata.gemspec = GEMSPEC 
    232     manual.base_dir = MANUALDIR 
    233     manual.output_dir = MANUALOUTPUTDIR 
    234 end 
    235 begin 
    236     apidocs = FileList[ APIDOCSDIR + '**/*' ] 
    237     # trace "  apidocs: %p" % [ apidocs ] 
    238     targets = apidocs.pathmap( "%%{#{APIDOCSDIR},%s}p" % [ MANUALOUTPUTDIR + 'api' ] ) 
    239     # trace "  mapped apidocs to targets: %p" % [ targets ] 
    240     copier = self.method( :copy_resource ).to_proc 
    241      
    242     # Create a file task to copy each file to the output directory 
    243     apidocs.each_with_index do |docsfile, i| 
    244         file( targets[i] => [ MANUALOUTPUTDIR.to_s, docsfile ], &copier ) 
    245     end 
    246  
    247     # Now group all the API doc copy tasks into a containing task 
    248     desc "Copy API documentation to the output directory" 
    249     task :copy_apidocs => targets 
    250 end 
    251  
    252 task :manual => :copy_apidocs 
    253 directory MANUALOUTPUTDIR.to_s 
    254  
    255 ### Task: install 
    256 desc "Install Arrow as a conventional library" 
    257 task :install do 
    258     log "Installing Arrow as a convention library" 
    259     sitelib = Pathname.new( CONFIG['sitelibdir'] ) 
    260     Dir.chdir( LIBDIR ) do 
    261         LIB_FILES.each do |libfile| 
    262             relpath = libfile.relative_path_from( LIBDIR ) 
    263             target = sitelib + relpath 
    264             FileUtils.mkpath target.dirname, 
    265                 :mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory? 
    266             FileUtils.install relpath, target, 
    267                 :mode => 0644, :verbose => true, :noop => $dryrun 
    268         end 
    269     end 
    270 end 
    271  
    272 ### Task: install_gem 
    273 desc "Install Arrow as a gem" 
    274 task :install_gem => [:package] do 
    275     installer = Gem::Installer.new( %{pkg/#{PKG_FILE_NAME}.gem} ) 
    276     installer.install 
    277 end 
    278  
    279 ### Task: uninstall 
    280 desc "Uninstall Arrow if it's been installed as a conventional library" 
    281 task :uninstall do 
    282     log "Uninstalling conventionally-installed Arrow library files" 
    283     sitelib = Pathname.new( CONFIG['sitelibdir'] ) 
    284     dir = sitelib + 'arrow' 
    285     FileUtils.rm_rf( dir, :verbose => true, :noop => $dryrun ) 
    286     lib = sitelib + 'arrow.rb' 
    287     FileUtils.rm( lib, :verbose => true, :noop => $dryrun ) 
    288 end 
    289  
    290 ### Task: uninstall_gem 
    291 task :uninstall_gem => [:clean] do 
    292     uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME ) 
    293     uninstaller.uninstall 
    294 end 
    295  
    296  
     203    $stderr.puts "Copying packages..." 
     204    FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir ) 
     205end 
     206 
     207 
  • trunk/lib/arrow.rb

    r452 r454  
    3737 
    3838    # Library version 
    39     VERSION = '0.9.3' 
     39    VERSION = '0.9.4' 
    4040 
    4141