begin require 'rake/gempackagetask' require 'rake/extensiontask' rescue LoadError end require 'rbconfig' include Config require 'rake/clean' CLEAN.include 'doc', 'coverage', FileList["**/*.dump"], FileList["ext/*.{o,so,#{CONFIG['DLEXT']}}"], 'lib/*.so', 'ext/Makefile' MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') } PKG_NAME = 'neuro' PKG_VERSION = File.read('VERSION').chomp PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|doc|tmp|coverage|(\.dump\Z)/).to_a task :default => :test desc "Run unit tests" task :test => :compile_ext do sh 'testrb -Iext:lib tests/test_*.rb' end desc "Creating documentation" task :doc do sh 'rdoc -t "neuro - Neural Network Extension for Ruby" -m doc-main.txt -o doc doc-main.txt ext/neuro.c lib/neuro/version.rb' # lib/neuro/display.rb' end desc "Compiling library" task :compile_ext do cd 'ext' do ruby 'extconf.rb' sh MAKE end end desc "Installing library" task :install => :test do src = "ext/neuro.#{CONFIG['DLEXT']}" filename = File.basename(src) dst = File.join(CONFIG["sitelibdir"], filename) install(src, dst, :verbose => true, :mode => 0644) src = 'lib/neuro/display.rb' filename = File.basename(src) dst_dir = File.join(CONFIG["sitelibdir"], 'neuro') mkdir_p dst_dir dst = File.join(dst_dir, filename) install(src, dst, :verbose => true, :mode => 0644) end if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask) then spec_src = <<-GEM Gem::Specification.new do |s| s.name = '#{PKG_NAME}' s.version = '#{PKG_VERSION}' s.summary = "Neural Network Extension for Ruby" s.description = < [ :version, :gemspec, :test ] desc "Build all gems and archives for a new release." task :release => [ :clean, :version, :gemspec, :cross, :native, :gem ] do system "#$0 clean native gem" system "#$0 clean package" end