Rakefile in ruby-vpi-8.2.0 vs Rakefile in ruby-vpi-9.0.0

- old
+ new

@@ -1,5 +1,8 @@ +# = Environment variables +# CFLAGS:: Arguments to the compiler. +# LDFLAGS:: Arguments to the linker. =begin Copyright 2006 Suraj N. Kurapati This file is part of Ruby-VPI. @@ -16,26 +19,27 @@ 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' require 'tempfile' require 'rbconfig' -$:.unshift File.join(File.dirname(__FILE__), 'lib') +PROJECT_LIBS = File.join(File.dirname(__FILE__), 'lib') + +$:.unshift PROJECT_LIBS +require 'ruby-vpi' require 'ruby-vpi/rake' -PROJECT_ID = 'ruby-vpi' -PROJECT_NAME = 'Ruby-VPI' -PROJECT_URL = "http://#{PROJECT_ID}.rubyforge.org" -PROJECT_SUMMARY = "Ruby interface to Verilog VPI." -PROJECT_DETAIL = "#{PROJECT_NAME} is a #{PROJECT_SUMMARY}. It lets you create complex Verilog test benches easily and wholly in Ruby." +include RubyVpi::Config PROJECT_SSH_URL = "snk@rubyforge.org:/var/www/gforge-projects/#{PROJECT_ID}" File.read('HISTORY') =~ /Version\s+([\d\.]+)\s*\((.*?)\)/ PROJECT_VERSION = $1 PROJECT_BIRTHDAY = $2 @@ -54,17 +58,22 @@ task :default => :build -task :clobber do |t| - 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 - files.each do |f| - cd File.dirname(f) do - sh 'rake', t.name + # 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 + end end end end @@ -72,50 +81,37 @@ ## extension desc "Builds object files for all simulators." task :build -DEFAULT_SHARED_OBJ = "#{PROJECT_ID}.so" -DEFAULT_NORMAL_OBJ = "#{PROJECT_ID}.o" - directory 'obj' CLOBBER.include 'obj' -{ - :cver => ['-DPRAGMATIC_CVER', '-export-dynamic'], - :ivl => ['-DICARUS_VERILOG'], - :vcs => ['-DSYNOPSYS_VCS'], - :vsim => ['-DMENTOR_MODELSIM'], -}.each_pair do |target, (cflags, ldflags)| - # object files that are needed to be built - objFiles = [DEFAULT_NORMAL_OBJ, DEFAULT_SHARED_OBJ].inject({}) do |memo, src| - dstName = src.sub(/#{File.extname src}$/, ".#{target}\\&") - dst = File.expand_path(File.join('obj', dstName)) +SIMULATORS.each do |sim| + taskName = "build_#{sim.id}" - memo[src] = dst - memo - end + desc "Builds object files for #{sim.name} simulator." + task taskName => ['obj', 'ext'] do + src = "#{PROJECT_ID}.so" + dst = "#{PROJECT_ID}.#{sim.id}.so" - # task to build the object files - targetTask = "build_#{target}" + dst = File.expand_path(File.join('obj', dst)) - desc "Builds object files for #{target} simulator." - task targetTask => ['obj', 'ext'] do |t| - unless objFiles.values.reject {|f| File.exist? f}.empty? - cd t.prerequisites[1] do - ENV['CFLAGS'], ENV['LDFLAGS'] = cflags, ldflags - sh %w(rake clean default) + unless File.exist? dst + cd 'ext' do + ENV['CFLAGS'] = "#{CFLAGS} #{sim.compiler_args}" + ENV['LDFLAGS'] = "#{LDFLAGS} #{sim.linker_args}" - objFiles.each_pair do |src, dst| - mv src, dst - end + sh 'rake' + mv src, dst + sh 'rake clean' end end end - task :build => targetTask + task :build => taskName end ## documentation @@ -190,11 +186,11 @@ task :dist_info => distDocs desc "Prepare for distribution." task :dist => ['ext', :doc, :dist_info] do |t| - cd t.prerequisites[0] do + cd 'ext' do sh 'rake swig' end end @@ -272,10 +268,10 @@ ## 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'] = File.join(File.dirname(__FILE__), 'lib') + ENV['RUBYLIB'] = PROJECT_LIBS FileList['samp/*/'].each do |s| cd s do sh 'rake', ENV['SIMULATOR'] || 'cver' end