Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working on windows gem

  • Loading branch information...
commit 888773e16d2d1decd05bfaa908d6a5117b6441a2 1 parent b00fd34
@copiousfreetime authored
View
1  .gitignore
@@ -4,6 +4,7 @@
*.o
*.a
ext/Rakefile
+ext/Makefile
*.log
a.out
*.so
View
16 ext/extconf.rb
@@ -0,0 +1,16 @@
+require 'rbconfig'
+require 'mkmf'
+
+if Config::CONFIG['host_os'] =~ /darwin/ then
+ $CFLAGS += " -DUSE_INSTANT_OSX=1"
+ $LDFLAGS += " -framework CoreServices"
+elsif Config::CONFIG['host_os'] =~ /win32/ or Config::CONFIG['host_os'] =~ /mingw/ then
+ $CFLAGS += " -DUSE_INSTANT_WINDOWS=1"
+ puts "going for mingw"
+else
+ if have_library("rt", "clock_gettime") then
+ $CFLAGS += " -DUSE_INSTANT_CLOCK_GETTIME=1"
+ end
+end
+
+create_makefile('hitimes_ext')
View
20 ext/mkrf_conf.rb
@@ -1,20 +0,0 @@
-require 'rubygems'
-require 'mkrf'
-require 'rbconfig'
-
-Mkrf::Generator.new('hitimes_ext') do |g|
- g.logger.level = Logger::WARN
-
- if Config::CONFIG['host_os'] =~ /darwin/ then
- g.add_define "USE_INSTANT_OSX=1"
- g.additional_code = "LIBS.concat(' -framework CoreServices')"
- elsif Config::CONFIG['host_os'] =~ /win32/ then
- g.add_define "USE_INSTANT_WINDOWS=1"
- else
- g.include_library("rt")
- if g.has_function?( 'clock_gettime' ) then
- g.add_define "USE_INSTANT_CLOCK_GETTIME=1"
- end
- end
-
-end
View
178 ext/rbconfig-mingw.rb
@@ -0,0 +1,178 @@
+
+# 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/Users/jeremy/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=/Users/jeremy/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
6 gemspec.rb
@@ -45,5 +45,9 @@
if rf = Configuration.for_if_exist?('rubyforge') then
spec.rubyforge_project = rf.project
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 += ["lib/hitimes_ext.so"]
View
7 tasks/distribution.rake
@@ -34,8 +34,13 @@ if pkg_config = Configuration.for_if_exist?("packaging") then
desc "reinstall gem"
task :reinstall => [:uninstall, :repackage, :install]
+ desc "package up a windows gem"
+ task :package_win => "ext:build_win" do
+ Gem::Builder.new( Hitimes::GEM_SPEC_WIN ).build
+ end
+
desc "distribute copiously"
- task :copious => [:package] do
+ task :copious => [:package, :package_win ] do
Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
'/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
'pkg',"#{Hitimes::GEM_SPEC.full_name}.gem").upload
View
23 tasks/extension.rake
@@ -15,18 +15,34 @@ if ext_config = Configuration.for_if_exist?('extension') then
conf = parts.last
Dir.chdir(path.dirname) do |d|
ruby conf.to_s
- sh "rake default"
+ #sh "rake default"
+ sh "make"
end
end
end
+ desc "Build the extension for windows"
+ task :build_win => :clobber do
+ 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"
+ sh "make"
+ end
+ end
+ end
+
task :clean do
ext_config.configs.each do |extension|
path = Pathname.new(extension)
parts = path.split
conf = parts.last
Dir.chdir(path.dirname) do |d|
- sh "rake clean"
+ #sh "rake clean"
+ sh "make clean"
end
end
end
@@ -37,7 +53,8 @@ if ext_config = Configuration.for_if_exist?('extension') then
parts = path.split
conf = parts.last
Dir.chdir(path.dirname) do |d|
- sh "rake clobber"
+ #sh "rake clobber"
+ sh "make distclean"
end
end
end

0 comments on commit 888773e

Please sign in to comment.
Something went wrong with that request. Please try again.