Rakefile in ruby-vpi-15.0.2 vs Rakefile in ruby-vpi-16.0.0

- old
+ new

@@ -1,28 +1,12 @@ # = Environment variables # CFLAGS:: Arguments to the compiler. # LDFLAGS:: Arguments to the linker. -=begin - Copyright 2006 Suraj N. Kurapati +#-- +# Copyright 2006-2007 Suraj N. Kurapati +# See the file named LICENSE for details. - This file is part of Ruby-VPI. - - Ruby-VPI is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - Ruby-VPI is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Ruby-VPI; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -=end - CFLAGS, LDFLAGS = ENV['CFLAGS'], ENV['LDFLAGS'] require 'rake/clean' require 'rake/rdoctask' require 'rake/gempackagetask' @@ -34,247 +18,240 @@ $:.unshift PROJECT_LIBS require 'ruby-vpi' require 'ruby-vpi/rake' +task :default => :build -include RubyVpi::Config -PROJECT_SSH_URL = "snk@rubyforge.org:/var/www/gforge-projects/#{PROJECT_ID}" -load 'doc/history.rb' -head = @history.first -PROJECT_VERSION = head['Version'] -PROJECT_BIRTHDAY = head['Date'] +# load project information + include RubyVpi::Config + PROJECT_SSH_URL = "snk@rubyforge.org:/var/www/gforge-projects/#{PROJECT_ID}" + load 'doc/history.rb' + head = @history.first + PROJECT_VERSION = head['Version'] + PROJECT_BIRTHDAY = head['Date'] -# Returns a temporary, unique path ready for use. No file exists at the returned path. -def generate_temp_path - rm_f path = Tempfile.new($$).path - path -end -# uploads the given sources to the given destination URL -def upload aDestUrl, *aSources - sh 'rsync', '-avz', '--delete', aSources, aDestUrl -end +# utility + # Returns a temporary, unique path ready for use. No file exists at the + # returned path. + def generate_temp_path + rm_f path = Tempfile.new($$).path + path + end + # uploads the given sources to the given destination URL + def upload aDestUrl, *aSources + sh 'rsync', '-avz', '--delete', aSources, aDestUrl + end -task :default => :build + # propogate cleaning tasks recursively to lower levels + [:clean, :clobber].each do |t| + task t do + files = FileList['**/Rakefile'].exclude('_darcs') + files.shift # avoid infinite loop on _this_ file -[:clean, :clobber].each do |t| - task t do - files = FileList['**/Rakefile'].exclude('_darcs') - files.shift # avoid infinite loop on _this_ file + # allows propogation to lower levels when gem not installed + ENV['RUBYLIB'] = PROJECT_LIBS - # allows propogation to lower levels when gem not installed - ENV['RUBYLIB'] = PROJECT_LIBS - - files.each do |f| - cd File.dirname(f) do - sh 'rake', t.to_s + files.each do |f| + cd File.dirname(f) do + sh 'rake', t.to_s + end end end end -end +# extension -## extension + desc "Builds object files for all simulators." + task :build -desc "Builds object files for all simulators." -task :build + directory 'obj' + CLOBBER.include 'obj' -directory 'obj' -CLOBBER.include 'obj' + SIMULATORS.each_pair do |id, sim| + taskName = "build_#{id}" + desc "Builds object files for #{sim.name}." + task taskName => ['obj', 'ext'] do + src = "#{PROJECT_ID}.so" + dst = "#{PROJECT_ID}.#{id}.so" -SIMULATORS.each do |sim| - taskName = "build_#{sim.id}" + dst = File.expand_path(File.join('obj', dst)) - desc "Builds object files for #{sim.name} simulator." - task taskName => ['obj', 'ext'] do - src = "#{PROJECT_ID}.so" - dst = "#{PROJECT_ID}.#{sim.id}.so" + unless File.exist? dst + cd 'ext' do + ENV['CFLAGS'] = "#{CFLAGS} #{sim.compiler_args}" + ENV['LDFLAGS'] = "#{LDFLAGS} #{sim.linker_args}" - dst = File.expand_path(File.join('obj', dst)) - - unless File.exist? dst - cd 'ext' do - ENV['CFLAGS'] = "#{CFLAGS} #{sim.compiler_args}" - ENV['LDFLAGS'] = "#{LDFLAGS} #{sim.linker_args}" - - sh 'rake' - mv src, dst - sh 'rake clean' + sh 'rake' + mv src, dst + sh 'rake clean' + end end end + + task :build => taskName end - task :build => taskName -end +# documentation - -## documentation - -desc 'Generate user documentation.' -task :doc do |t| - cd t.name do - sh 'rake' + desc 'Generate user documentation.' + task :doc do |t| + cd t.name do + sh 'rake' + end end -end -directory 'ref' -CLOBBER.include 'ref' + directory 'ref' + CLOBBER.include 'ref' -desc 'Generate reference documentation.' -file 'ref' => ['ref/c', 'ref/ruby'] + desc 'Generate reference documentation.' + file 'ref' => ['ref/c', 'ref/ruby'] -directory 'ref/ruby' -CLOBBER.include 'ref/ruby' + directory 'ref/ruby' + CLOBBER.include 'ref/ruby' -desc 'Generate reference for Ruby.' -Rake::RDocTask.new 'ref/ruby' do |t| - t.rdoc_dir = t.name - t.title = "#{PROJECT_NAME}: #{PROJECT_SUMMARY}" - t.options.concat %w(--charset utf-8 --line-numbers) - t.rdoc_files.include '{bin,lib/**}/*.rb' -end - - -directory 'ref/c' -CLOBBER.include 'ref/c' - -desc 'Generate reference for C.' -file 'ref/c' do |t| - # doxygen outputs to this temporary destination - tempDest = 'ext/html' - - cd File.dirname(tempDest) do - sh "doxygen" + desc 'Generate reference for Ruby.' + Rake::RDocTask.new 'ref/ruby' do |t| + t.rdoc_dir = t.name + t.title = "#{PROJECT_NAME}: #{PROJECT_SUMMARY}" + t.options.concat %w(--charset utf-8 --line-numbers) + t.rdoc_files.include '{bin,lib/**}/*.rb' end - mv FileList[tempDest + '/*'].to_a, t.name - rmdir tempDest -end + directory 'ref/c' + CLOBBER.include 'ref/c' -desc 'Generate release announcement.' -task :ann => 'doc/history.rb' do |t| - require t.prerequisites[0] - text = [ - PROJECT_DETAIL, - "* " + PROJECT_URL, - "---", - format_history_entry(@history.first) - ].join "\n\n" + desc 'Generate reference for C.' + file 'ref/c' do |t| + # doxygen outputs to this temporary destination + tempDest = 'ext/html' - require 'doc/lib/doc_format' - html = text.redcloth + cd File.dirname(tempDest) do + sh "doxygen" + end - IO.popen('w3m -T text/html -dump -cols 60', 'w+') do |pipe| - pipe.write html - pipe.close_write - puts pipe.read + mv FileList[tempDest + '/*'].to_a, t.name + rmdir tempDest end -end +# distribution -## distribution - -desc "Prepare for distribution." -task :dist => ['ext', 'ref', :doc] do |t| - cd 'ext' do - sh 'rake swig' + desc "Prepare for distribution." + task :dist => ['ext', 'ref', :doc] do |t| + cd 'ext' do + sh 'rake swig' + end end -end + desc 'Publish documentation to website.' + task :web => [:web_ref, :web_doc] -desc 'Publish documentation to website.' -task :web => [:web_ref, :web_doc] + desc "Publish reference documentation." + task :web_ref => 'ref' do |t| + upload PROJECT_SSH_URL, *t.prerequisites + end -desc "Publish reference documentation." -task :web_ref => 'ref' do |t| - upload PROJECT_SSH_URL, *t.prerequisites -end + desc "Publish user documentation." + task :web_doc => 'doc' do |t| + upload PROJECT_SSH_URL, *t.prerequisites + end -desc "Publish user documentation." -task :web_doc => 'doc' do |t| - upload PROJECT_SSH_URL, *t.prerequisites -end + desc 'Connect to website FTP.' + task :ftp do + sh 'lftp', "sftp://#{PROJECT_SSH_URL}" + end -desc 'Connect to website FTP.' -task :ftp do - sh 'lftp', "sftp://#{PROJECT_SSH_URL}" -end + desc 'Generate release announcement.' + task :ann => 'doc/history.rb' do |t| + require t.prerequisites[0] + $: << File.join(File.dirname(__FILE__), 'doc', 'lib') + require 'doc_proxy' -desc "Generate release packages." -task :release => [:clobber, :dist] do - sh 'rake package' -end + text = [ + PROJECT_DETAIL, + "* See #{PROJECT_URL} for details.", + "---", + @history.first + ].join "\n\n" -spec = Gem::Specification.new do |s| - s.name = s.rubyforge_project = PROJECT_ID - s.summary = PROJECT_SUMMARY - s.description = PROJECT_DETAIL - s.homepage = PROJECT_URL - s.version = PROJECT_VERSION + IO.popen('w3m -T text/html -dump -cols 60', 'w+') do |pipe| + pipe.write text.to_html + pipe.close_write + puts pipe.read + end + end - s.add_dependency 'rake', '>= 0.7.0' - s.add_dependency 'rspec', '>= 0.7.0' - s.add_dependency 'rcov', '>= 0.7.0' - s.add_dependency 'xx' # needed by rcov - s.add_dependency 'ruby-debug', '>= 0.5.2' - s.requirements << "POSIX threads library" - s.requirements << "C language compiler" +# packaging - s.files = FileList['**/*'].exclude('_darcs') - s.autorequire = PROJECT_ID - s.extensions << 'gem_extconf.rb' + desc "Generate release packages." + task :release => [:clobber, :dist] do + sh 'rake package' + end - # make tools executable - tools = FileList['bin/*.rb'] + spec = Gem::Specification.new do |s| + s.name = s.rubyforge_project = PROJECT_ID + s.summary = PROJECT_SUMMARY + s.description = PROJECT_DETAIL + s.homepage = PROJECT_URL + s.version = PROJECT_VERSION - tools.each do |f| - chmod 0755, f - end + s.add_dependency 'rake', '>= 0.7.0' + s.add_dependency 'rspec', '>= 0.7.0' + s.add_dependency 'rcov', '>= 0.7.0' + s.add_dependency 'xx' # needed by rcov + s.add_dependency 'ruby-debug', '>= 0.5.2' - s.executables = tools.map {|f| File.basename f} -end + s.requirements << "POSIX threads library" + s.requirements << "C language compiler" -Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar = true -end + s.files = FileList['**/*'].exclude('_darcs') + s.autorequire = PROJECT_ID + s.extensions << 'gem_extconf.rb' + s.executables = FileList['bin/*.rb'].map {|f| File.basename f} + end + Rake::GemPackageTask.new(spec) do |pkg| + pkg.need_tar = true + end -desc "Configures the gem during installation." -task :gem_config_inst do |t| - # make documentation available to gem_server - gemDir = File.dirname(__FILE__) - gemName = File.basename(gemDir) - docDir = File.join('..', '..', 'doc', gemName) - mkdir_p docDir - ln_s gemDir, File.join(docDir, 'rdoc') -end +# installation + desc "Configures the gem during installation." + task :gem_config_inst do |t| + # make documentation available to gem_server + gemDir = File.dirname(__FILE__) + gemName = File.basename(gemDir) + docDir = File.join('..', '..', 'doc', gemName) + mkdir_p docDir + ln_s gemDir, File.join(docDir, 'rdoc') + end -## testing -desc "Ensure that examples work with $SIMULATOR" -task :test => :build do - # ensures that current sources are tested instead of the installed gem - ENV['RUBYLIB'] = PROJECT_LIBS +# testing - FileList['samp/*/'].each do |s| - cd s do - sh 'rake', ENV['SIMULATOR'] || 'cver' + desc "Ensure that examples work with $SIMULATOR" + task :test => :build do + # ensures that current sources are tested instead of the installed gem + ENV['RUBYLIB'] = PROJECT_LIBS + + FileList['samp/*/'].each do |s| + cd s do + sh 'rake', ENV['SIMULATOR'] || 'cver' + end end end -end