$:.unshift( '.' )

require 'rubygems'

require 'rubygems/package_task'
require 'rake/testtask'

require 'lib/mxx_ru/version'

spec = Gem::Specification.new do |s|
  s.name = "Mxx_ru"
  s.version = MXX_RU_VERSION
  s.licenses = ['BSD-3-Clause']
  s.author = "The Mxx_ru Project"
  s.email = "eao197@yahoo.com"
  s.homepage = "http://sourceforge.net/projects/mxxru"
  s.platform = Gem::Platform::RUBY
  s.summary = "Mxx_ru (Make++ on Ruby) is a cross-platform build tool"
  s.description = "Mxx_ru is a cross-platform build tool primarily focused " +
    "to C/C++ projects"
  s.files = FileList[ "{bin,tests,lib,docs,examples}/**/*" ].
      exclude( "rdoc" ).to_a + [ "THANKS" ]
  s.executables = [ 'mxxrugen', 'mxxruexternals' ]
  s.require_path = "lib"
  s.rdoc_options = [ '--main', 'README' ]
  s.extra_rdoc_files = [ "README", "Rakefile", "COPYING", "NEWS" ] + FileList[ "docs/**/*" ].to_a
end

gem = Gem::PackageTask.new( spec ) do |pkg|
  pkg.need_zip = true
  pkg.need_tar = true
end

test = Rake::TestTask.new do |t|
  is_mswin = (/^mswin/ =~ RbConfig::CONFIG[ 'host_os' ] ||
       /^mingw/ =~ RbConfig::CONFIG[ 'host_os' ])

  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[189]/ =~ n } unless
      /(mxx_ru\/cpp\/toolsets\/){0,1}vc[189]/ =~ 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 is_mswin

  # Unix specific files must be excluded on Windows platform.
  test_files = test_files.delete_if { |n| /unix/ =~ n } if is_mswin

  # Darwin specific files must be excluded if not MacOS platform.
  test_files = test_files.delete_if { |n| /darwin/ =~ n } unless 
      /^darwin/ =~ RbConfig::CONFIG[ 'host_os' ]

  t.test_files = test_files
  t.verbose = true
end

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

