Browse files

add in support for mingw32 gem

  • Loading branch information...
1 parent 988e33b commit b32bad4ef5403f84b5ce309b693a7a24f515fa0a @copiousfreetime committed Aug 1, 2009
Showing with 40 additions and 28 deletions.
  1. +2 −6 ext/hitimes/extconf.rb
  2. +8 −5 gemspec.rb
  3. +3 −6 lib/hitimes.rb
  4. +1 −1 spec/interval_spec.rb
  5. +1 −1 spec/mutex_stats_spec.rb
  6. +0 −1 spec/spec_helper.rb
  7. +5 −1 tasks/announce.rake
  8. +7 −4 tasks/distribution.rake
  9. +13 −3 tasks/extension.rake
View
8 ext/hitimes/extconf.rb
@@ -13,9 +13,5 @@
end
# put in a different location if on windows so we can have fat binaries
-parent_dir = "hitimes"
-if RUBY_PLATFORM =~ /(mswin|mingw)/i then
- v = RUBY_VERSION.gsub(/\.\d$/,'')
- parent_dir = File.join( parent_dir, v )
-end
-create_makefile("#{parent_dir}/hitimes_ext")
+subdir = RUBY_VERSION.gsub(/\.\d$/,'')
+create_makefile("hitimes/#{subdir}/hitimes_ext")
View
13 gemspec.rb
@@ -49,9 +49,12 @@
end
end
-Hitimes::GEM_SPEC_WIN = Hitimes::GEM_SPEC.clone
-Hitimes::GEM_SPEC_WIN.platform = ::Gem::Platform.new( "i386-mswin32_60" )
-Hitimes::GEM_SPEC_WIN.extensions = []
-#Hitimes::GEM_SPEC_WIN.files +=
+Hitimes::GEM_SPEC_MSWIN32 = Hitimes::GEM_SPEC.clone
+Hitimes::GEM_SPEC_MSWIN32.platform = ::Gem::Platform.new( "i386-mswin32" )
+Hitimes::GEM_SPEC_MSWIN32.extensions = []
-Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_WIN ]
+Hitimes::GEM_SPEC_MINGW32= Hitimes::GEM_SPEC.clone
+Hitimes::GEM_SPEC_MINGW32.platform = ::Gem::Platform.new( "i386-mingw32" )
+Hitimes::GEM_SPEC_MINGW32.extensions = []
+
+Hitimes::SPECS = [ Hitimes::GEM_SPEC, Hitimes::GEM_SPEC_MSWIN32, Hitimes::GEM_SPEC_MINGW32 ]
View
9 lib/hitimes.rb
@@ -19,12 +19,9 @@ class Error < ::StandardError; end
require 'hitimes/paths'
require 'hitimes/version'
-# support for fat binaries on windows
-if RUBY_PLATFORM =~ /(mswin|mingw)/i
- require "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}/hitimes_ext"
-else
- require 'hitimes/hitimes_ext'
-end
+# use a version subdirectory for extensions, initially to support windows, but
+# why make a special case. It doesn't hurt anyone to have an extra subdir.
+require "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}/hitimes_ext"
require 'hitimes/stats'
require 'hitimes/mutexed_stats'
require 'hitimes/metric'
View
2 spec/interval_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-require 'hitimes/hitimes_ext'
+require 'hitimes'
describe Hitimes::Interval do
it "has a 0 duration when newly created" do
View
2 spec/mutex_stats_spec.rb
@@ -1,6 +1,6 @@
require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
-require 'hitimes/hitimes_ext'
+require 'hitimes'
require 'hitimes/mutexed_stats'
describe Hitimes::MutexedStats do
View
1 spec/spec_helper.rb
@@ -1,6 +1,5 @@
require 'rubygems'
require 'spec'
-$: << File.expand_path(File.join(File.dirname(__FILE__),"..","ext"))
$: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
View
6 tasks/announce.rake
@@ -21,10 +21,14 @@ namespace :announce do
mail.puts
mail.puts info[:release_notes]
mail.puts
- mail.puts info[:urls]
+ mail.puts " #{info[:urls]}"
mail.puts
+ mail.puts "=== Installation"
+ mail.puts
mail.puts " gem install #{Hitimes::GEM_SPEC.name}"
mail.puts
+ mail.puts "=== Description"
+ mail.puts
mail.puts info[:description]
end
puts "Created the following as email.txt:"
View
11 tasks/distribution.rake
@@ -49,10 +49,13 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
cp "ext/hitimes/hitimes_ext.so", "lib/hitimes/#{s}/", :verbose => true
end
- Hitimes::GEM_SPEC_WIN.files += FileList["lib/hitimes/{1.8,1.9}/**.{dll,so}"]
- Gem::Builder.new( Hitimes::GEM_SPEC_WIN ).build
- mkdir "pkg" unless File.directory?( 'pkg' )
- mv Dir["*.gem"].first, "pkg"
+ Hitimes::SPECS.each do |spec|
+ next if spec.platform == "ruby"
+ spec.files += FileList["lib/hitimes/{1.8,1.9}/**.{dll,so}"]
+ Gem::Builder.new( spec ).build
+ mkdir "pkg" unless File.directory?( 'pkg' )
+ mv Dir["*.gem"].first, "pkg"
+ end
end
task :clobber do
View
16 tasks/extension.rake
@@ -9,13 +9,19 @@ if ext_config = Configuration.for_if_exist?('extension') then
namespace :ext do
desc "Build the extension(s)"
task :build => :clean do
- Hitimes::GEM_SPEC.extensions.each do |extension|
- path = Pathname.new(extension)
+ ext_config.configs.each do |extension|
+ path = Pathname.new(extension)
parts = path.split
- conf = parts.last
+ conf = parts.last
Dir.chdir(path.dirname) do |d|
ruby conf.to_s
sh "make"
+
+ # install into requireable location so specs will run
+ subdir = "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}"
+ dest_dir = Hitimes::Paths.lib_path( subdir )
+ mkdir_p dest_dir, :verbose => true
+ cp "hitimes_ext.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
end
end
end
@@ -34,6 +40,9 @@ if ext_config = Configuration.for_if_exist?('extension') then
parts = path.split
conf = parts.last
Dir.chdir(path.dirname) do |d|
+ if File.exist?( "Makefile" ) then
+ sh "make clean distclean"
+ end
cp "#{rbconfig}", "rbconfig.rb"
sh "#{ruby_exe} -I. extconf.rb"
sh "make"
@@ -61,6 +70,7 @@ if ext_config = Configuration.for_if_exist?('extension') then
if File.exist?( "Makefile" ) then
sh "make clean"
end
+ rm_f "rbconfig.rb"
end
end
end

0 comments on commit b32bad4

Please sign in to comment.