require 'rubygems'
Gem::manage_gems

require 'rake/gempackagetask'
require 'rake/testtask'

require 'lib/mxx_ru/version'

spec = Gem::Specification.new do |s|
  s.name = "Mxx_ru"
  s.version = MXX_RU_VERSION
  s.author = "The Mxx_ru Project"
  s.email = "eao197@yahoo.com"
  s.homepage = "http://www.rubyforge.com/projects/mxx-ru"
  s.platform = Gem::Platform::RUBY
  s.summary = "Mxx_ru (Make++ on Ruby) is a cross-platform build tool"
  s.files = FileList[ "{bin,tests,lib,docs,examples}/**/*" ].
      exclude( "rdoc" ).to_a + [ "THANKS" ]
  s.executables = 'mxxrugen'
  s.require_path = "lib"
  s.has_rdoc = true
  s.rdoc_options = [ '-S', '--main', 'README' ]
  s.extra_rdoc_files = [ "README", "Rakefile", "COPYING", "NEWS" ] + FileList[ "docs/**/*" ].to_a
end

gem = Rake::GemPackageTask.new( spec ) do |pkg|
  pkg.need_zip = true
  pkg.need_tar = true
end

test = Rake::TestTask.new do |t|
  test_files = FileList[ 'tests/**/{tc,ts}*.rb' ]

  # Visual C++ 8.0-9.0 specific files must be excluded when working with
  # another compiler.
  test_files = test_files.delete_if { |n| /\/vc[89]/ =~ n } unless
      /(mxx_ru\/cpp\/toolsets\/){0,1}vc[89]/ =~ ENV[ 'MXX_RU_CPP_TOOLSET' ]

  # Visual C++ specific files must be excluded when working with
  # another compiler.
  test_files = test_files.delete_if { |n| /\/vc/ =~ n } unless
      /(mxx_ru\/cpp\/toolsets\/){0,1}vc\d/ =~ ENV[ 'MXX_RU_CPP_TOOLSET' ]

  # MSWin specific files must be excluded if not Windows platform.
  test_files = test_files.delete_if { |n| /mswin/ =~ n } unless 
      /^mswin/ =~ Config::CONFIG[ 'host_os' ]

  # Unix specific files must be excluded on Windows platform.
  test_files = test_files.delete_if { |n| /unix/ =~ n } if
      /^mswin/ =~ Config::CONFIG[ 'host_os' ]

  t.test_files = test_files
  t.verbose = true
end

task :default => [ gem.package_dir + "/" + gem.name + "-" + gem.version.version + ".gem" ]

