Permalink
Browse files

on the way to fat binaries

  • Loading branch information...
copiousfreetime committed Jun 28, 2009
1 parent 8b10f59 commit 5759048f301e1bdb6c092380f3d1876cd4b49d97
Showing with 43 additions and 191 deletions.
  1. +2 −1 HISTORY
  2. +3 −4 TODO.taskpaper
  3. +7 −1 ext/extconf.rb
  4. +0 −178 ext/rbconfig-mingw-1.8.rb
  5. +1 −0 gemspec.rb
  6. +7 −1 lib/hitimes.rb
  7. +1 −0 tasks/config.rb
  8. +1 −1 tasks/distribution.rake
  9. +21 −5 tasks/extension.rake
View
@@ -1,7 +1,8 @@
= Changelog
== Version 1.0.2
-* Fix bug where CLOCK_MONOTONIC not found on linode (reported by Roger Pack)
+* Fix bug with time.h on linode (reported by Roger Pack)
+* Fix potential garbage collection issue with Interval class
== Version 1.0.1 2009-06-12
View
@@ -1,14 +1,13 @@
Future Release:
- fat binaries
+ - a replacement for Time.now that only gets a new Time value if the time has
+ passed 1 sec.
- how to get current timeofday in nanoseconds from all systems
- create a pure ruby version
- do not blow up on install if unable to compile, fall back to pure ruby
version
- - push Timer down to C level
- - timer to_json to report the base stats and the
+ - timer to_json to report the base stats
- add string format for stats
- - a replacement for Time.now that only gets a new Time value if the time has
- passed 1 sec.
Breaking ideas:
- how about converting all times to nanosecond units?
View
@@ -12,4 +12,10 @@
end
end
-create_makefile('hitimes_ext')
+# 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")
View
@@ -1,178 +0,0 @@
-
-# This file was created by mkconfig.rb when ruby was built. Any
-# changes made to this file will be lost the next time ruby is built.
-
-module Config
- RUBY_VERSION == "1.8.6" or
- raise "ruby lib version (1.8.6) doesn't match executable version (#{RUBY_VERSION})"
-
- TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/1.8/i386-mingw32")
- DESTDIR = '' unless defined? DESTDIR
- CONFIG = {}
- CONFIG["DESTDIR"] = DESTDIR
- CONFIG["INSTALL"] = '/opt/local/bin/ginstall -c'
- CONFIG["prefix"] = (TOPDIR || DESTDIR + "#{ENV["HOME"]}/ruby-mingw32")
- CONFIG["EXEEXT"] = ".exe"
- CONFIG["ruby_install_name"] = "ruby"
- CONFIG["RUBY_INSTALL_NAME"] = "ruby"
- CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
- CONFIG["SHELL"] = "/bin/sh"
- CONFIG["PATH_SEPARATOR"] = ":"
- CONFIG["PACKAGE_NAME"] = ""
- CONFIG["PACKAGE_TARNAME"] = ""
- CONFIG["PACKAGE_VERSION"] = ""
- CONFIG["PACKAGE_STRING"] = ""
- CONFIG["PACKAGE_BUGREPORT"] = ""
- CONFIG["exec_prefix"] = "$(prefix)"
- CONFIG["bindir"] = "$(exec_prefix)/bin"
- CONFIG["sbindir"] = "$(exec_prefix)/sbin"
- CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
- CONFIG["datarootdir"] = "$(prefix)/share"
- CONFIG["datadir"] = "$(datarootdir)"
- CONFIG["sysconfdir"] = "$(prefix)/etc"
- CONFIG["sharedstatedir"] = "$(prefix)/com"
- CONFIG["localstatedir"] = "$(prefix)/var"
- CONFIG["includedir"] = "$(prefix)/include"
- CONFIG["oldincludedir"] = "/usr/include"
- CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"
- CONFIG["infodir"] = "$(datarootdir)/info"
- CONFIG["htmldir"] = "$(docdir)"
- CONFIG["dvidir"] = "$(docdir)"
- CONFIG["pdfdir"] = "$(docdir)"
- CONFIG["psdir"] = "$(docdir)"
- CONFIG["libdir"] = "$(exec_prefix)/lib"
- CONFIG["localedir"] = "$(datarootdir)/locale"
- CONFIG["mandir"] = "$(datarootdir)/man"
- CONFIG["ECHO_C"] = ""
- CONFIG["ECHO_N"] = "-n"
- CONFIG["ECHO_T"] = ""
- CONFIG["LIBS"] = "-lwsock32 "
- CONFIG["build_alias"] = "i686-darwin9.2.2"
- CONFIG["host_alias"] = "i386-mingw32"
- CONFIG["target_alias"] = "i386-mingw32"
- CONFIG["MAJOR"] = "1"
- CONFIG["MINOR"] = "8"
- CONFIG["TEENY"] = "6"
- CONFIG["build"] = "i686-pc-darwin9.2.2"
- CONFIG["build_cpu"] = "i686"
- CONFIG["build_vendor"] = "pc"
- CONFIG["build_os"] = "darwin9.2.2"
- CONFIG["host"] = "i386-pc-mingw32"
- CONFIG["host_cpu"] = "i386"
- CONFIG["host_vendor"] = "pc"
- CONFIG["host_os"] = "mingw32"
- CONFIG["target"] = "i386-pc-mingw32"
- CONFIG["target_cpu"] = "i386"
- CONFIG["target_vendor"] = "pc"
- CONFIG["target_os"] = "mingw32"
- CONFIG["CC"] = "i386-mingw32-gcc"
- CONFIG["CFLAGS"] = "-g -O2 "
- CONFIG["LDFLAGS"] = "-L. "
- CONFIG["CPPFLAGS"] = ""
- CONFIG["OBJEXT"] = "o"
- CONFIG["CPP"] = "i386-mingw32-gcc -E"
- CONFIG["GREP"] = "/usr/bin/grep"
- CONFIG["EGREP"] = "/usr/bin/grep -E"
- CONFIG["GNU_LD"] = "yes"
- CONFIG["CPPOUTFILE"] = "-o conftest.i"
- CONFIG["OUTFLAG"] = "-o "
- CONFIG["YACC"] = "bison -y"
- CONFIG["YFLAGS"] = ""
- CONFIG["RANLIB"] = "i386-mingw32-ranlib"
- CONFIG["AR"] = "i386-mingw32-ar"
- CONFIG["AS"] = "i386-mingw32-as"
- CONFIG["ASFLAGS"] = ""
- CONFIG["NM"] = "i386-mingw32-nm"
- CONFIG["WINDRES"] = "i386-mingw32-windres"
- CONFIG["DLLWRAP"] = "i386-mingw32-dllwrap"
- CONFIG["OBJDUMP"] = "i386-mingw32-objdump"
- CONFIG["LN_S"] = "ln -s"
- CONFIG["SET_MAKE"] = ""
- CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
- CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
- CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
- CONFIG["RM"] = "rm -f"
- CONFIG["CP"] = "cp"
- CONFIG["MAKEDIRS"] = "mkdir -p"
- CONFIG["ALLOCA"] = ""
- CONFIG["DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all"
- CONFIG["ARCH_FLAG"] = ""
- CONFIG["STATIC"] = ""
- CONFIG["CCDLFLAGS"] = ""
- CONFIG["LDSHARED"] = "i386-mingw32-gcc -shared -s"
- CONFIG["DLEXT"] = "so"
- CONFIG["DLEXT2"] = "dll"
- CONFIG["LIBEXT"] = "a"
- CONFIG["LINK_SO"] = ""
- CONFIG["LIBPATHFLAG"] = " -L\"%s\""
- CONFIG["RPATHFLAG"] = ""
- CONFIG["LIBPATHENV"] = ""
- CONFIG["TRY_LINK"] = ""
- CONFIG["STRIP"] = "strip"
- CONFIG["EXTSTATIC"] = ""
- CONFIG["setup"] = "Setup"
- CONFIG["MINIRUBY"] = "ruby -I#{ENV['HOME']}/pkgs/ruby-1.8.6-p114 -rfake"
- CONFIG["PREP"] = "fake.rb"
- CONFIG["RUNRUBY"] = "$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`"
- CONFIG["EXTOUT"] = ".ext"
- CONFIG["ARCHFILE"] = ""
- CONFIG["RDOCTARGET"] = ""
- CONFIG["XCFLAGS"] = " -DRUBY_EXPORT"
- CONFIG["XLDFLAGS"] = " -Wl,--stack,0x02000000"
- CONFIG["LIBRUBY_LDSHARED"] = "i386-mingw32-gcc -shared -s"
- CONFIG["LIBRUBY_DLDFLAGS"] = " -Wl,--enable-auto-image-base,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBRUBY)"
- CONFIG["rubyw_install_name"] = "rubyw"
- CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
- CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
- CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
- CONFIG["LIBRUBY_ALIASES"] = ""
- CONFIG["LIBRUBY"] = "lib$(LIBRUBY_SO).a"
- CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
- CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"
- CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
- CONFIG["SOLIBS"] = "$(LIBS)"
- CONFIG["DLDLIBS"] = ""
- CONFIG["ENABLE_SHARED"] = "yes"
- CONFIG["MAINLIBS"] = ""
- CONFIG["COMMON_LIBS"] = "m"
- CONFIG["COMMON_MACROS"] = ""
- CONFIG["COMMON_HEADERS"] = "windows.h winsock.h"
- CONFIG["EXPORT_PREFIX"] = ""
- CONFIG["MAKEFILES"] = "Makefile GNUmakefile"
- CONFIG["arch"] = "i386-mingw32"
- CONFIG["sitearch"] = "i386-msvcrt"
- CONFIG["sitedir"] = "$(prefix)/lib/ruby/site_ruby"
- CONFIG["configure_args"] = " '--host=i386-mingw32' '--target=i386-mingw32' '--build=i686-darwin9.2.2' '--prefix=#{ENV['HOME']}/ruby-mingw32' 'build_alias=i686-darwin9.2.2' 'host_alias=i386-mingw32' 'target_alias=i386-mingw32'"
- CONFIG["NROFF"] = "/usr/bin/nroff"
- CONFIG["MANTYPE"] = "doc"
- CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
- CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
- CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
- CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
- CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
- CONFIG["topdir"] = File.dirname(__FILE__)
- MAKEFILE_CONFIG = {}
- CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
- def Config::expand(val, config = CONFIG)
- val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
- if !(v = $1 || $2)
- '$'
- elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
- pat, sub = $1, $2
- config[v] = false
- Config::expand(key, config)
- config[v] = key
- key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
- key
- else
- var
- end
- end
- val
- end
- CONFIG.each_value do |val|
- Config::expand(val)
- end
-end
-RbConfig = Config # compatibility for ruby-1.9
-CROSS_COMPILING = nil unless defined? CROSS_COMPILING
View
@@ -24,6 +24,7 @@
spec.add_dependency("configuration", " ~> 0.0.5")
spec.add_development_dependency( "json", "~> 1.1.3")
+ spec.add_development_dependency( "rake-compiler", "~> 0.5.0")
if ext_conf = Configuration.for_if_exist?("extension") then
spec.extensions << ext_conf.configs
View
@@ -18,7 +18,13 @@ class Error < ::StandardError; end
end
require 'hitimes/paths'
require 'hitimes/version'
-require 'hitimes_ext'
+
+# 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
require 'hitimes/stats'
require 'hitimes/mutexed_stats'
require 'hitimes/metric'
View
@@ -92,6 +92,7 @@
#-----------------------------------------------------------------------
Configuration.for('extension') {
configs Configuration.for('packaging').files.ext.find_all { |x| %w[ mkrf_conf.rb extconf.rb ].include?(File.basename(x)) }
+ cross_rbconfig YAML.load_file( File.expand_path("~/.rake-compiler/config.yml"))
}
#-----------------------------------------------------------------------
View
@@ -36,7 +36,7 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
desc "package up a windows gem"
task :package_win => "ext:build_win" do
- cp "ext/hitimes_ext.so", "lib", :verbose => true
+ #cp "ext/hitimes_ext.so", "lib", :verbose => true
Gem::Builder.new( Hitimes::GEM_SPEC_WIN ).build
mv Dir["*.gem"].first, "pkg"
end
View
@@ -8,7 +8,7 @@ require 'pathname'
if ext_config = Configuration.for_if_exist?('extension') then
namespace :ext do
desc "Build the extension(s)"
- task :build do
+ task :build => :clobber do
Hitimes::GEM_SPEC.extensions.each do |extension|
path = Pathname.new(extension)
parts = path.split
@@ -17,24 +17,40 @@ if ext_config = Configuration.for_if_exist?('extension') then
ruby conf.to_s
#sh "rake default"
sh "make"
+ sh "make install"
end
end
end
- desc "Build the extension for windows"
- task :build_win => :clobber do
+ def build_win( version = "1.8.6" )
+ ext_config = Configuration.for("extension")
+ rbconfig = ext_config.cross_rbconfig["rbconfig-#{version}"]
+ raise ArgumentError, "No cross compiler for version #{version}, we have #{ext_config.cross_rbconfig.keys.join(",")}" unless rbconfig
+ ruby_exe = if version =~ /1\.8/ then
+ "ruby"
+ else
+ "ruby1.9"
+ end
Hitimes::GEM_SPEC.extensions.each do |extension|
path = Pathname.new(extension)
parts = path.split
conf = parts.last
Dir.chdir(path.dirname) do |d|
- cp "rbconfig-mingw.rb", "rbconfig.rb"
- sh "ruby -I. extconf.rb"
+ cp "#{rbconfig}", "rbconfig.rb"
+ sh "#{ruby_exe} -I. extconf.rb"
sh "make"
end
end
end
+ ext_config.cross_rbconfig.keys.each do |v|
+ s = v.split("-").last
+ desc "Build the extension for windows version #{s}"
+ task "build_win-#{s}" => :clobber do
+ build_win( s )
+ end
+ end
+
task :clean do
ext_config.configs.each do |extension|
path = Pathname.new(extension)

0 comments on commit 5759048

Please sign in to comment.