Permalink
Browse files

Switch to using rake-compiler for all compiling

This removes the bench task and replaces it with rake-compiler's
compile task.  It moves the cross-compiling task into
Rakefile.cross.  Thanks to Luis Lavena for his help and advice
in this process.
  • Loading branch information...
1 parent 9cd87ba commit 5cd19d1ee4343caab999ad46fd778fd0c651aaef @jeremyevans committed Aug 30, 2010
Showing with 35 additions and 38 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 CHANGELOG
  3. +7 −5 README.rdoc
  4. +11 −30 Rakefile
  5. +9 −0 Rakefile.cross
  6. +1 −1 bench/cpu_bench_util.rb
  7. +2 −2 bin/home_run
View
1 .gitignore
@@ -7,5 +7,6 @@
*.core
/pkg
/lib/1.*
+/lib/date_ext.so
/tmp
/coverage
View
4 CHANGELOG
@@ -1,5 +1,9 @@
=== HEAD
+* Require rake-compiler when building from source (may need to clean out your ext/date_ext directory manually) (jeremyevans)
+
+* Include the ragel-generated file in the repository, so you don't need ragel to build from source (jeremyevans)
+
* Respect Encoding.default_internal for returned strings on 1.9 (brianmario, jeremyevans)
* Handle problems with zones in the -HH,DDD or -HH.DDD formats (jeremyevans)
View
12 README.rdoc
@@ -240,26 +240,27 @@ To get a copy:
There are a few requirements:
-* Rake
+* rake
+* rake-compiler
* MSpec (not RSpec) for running the specs. The specs are based on
the rubyspec specs, which is why they use MSpec.
* RDoc 2.5.10+ if you want to build the documentation.
* Ragel 6.5+ if you want to modify the ragel parser.
-== Building
+== Compiling
-To build the library from a git checkout, after installing the
+To compile the library from a git checkout, after installing the
requirements:
- rake build
+ rake compile
== Testing
The default rake task runs the specs, so just run:
rake
-You need to build the library and install MSpec before running the
+You need to compile the library and install MSpec before running the
specs.
== Benchmarking
@@ -293,6 +294,7 @@ home_run has been tested on the following:
* OpenBSD (amd64, i386)
* Solaris 10 (sparc)
* Windows XP (i386)
+* Windows 7 (x64)
=== Compiler Versions
View
41 Rakefile
@@ -2,7 +2,7 @@ require "rake"
require "rake/clean"
require 'rbconfig'
-CLEAN.include %w'ext/date_ext/Makefile ext/date_ext/*.o ext/date_ext/date_ext.so **/*.rbc *.core rdoc coverage'
+CLEAN.include %w'**/*.rbc *.core rdoc coverage'
RUBY=ENV['RUBY'] || File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
desc "Build the RDoc documentation"
@@ -32,40 +32,21 @@ task :distclean do
Rake::Task[:clean].invoke
end
-if RUBY_PLATFORM !~ /mswin|mingw/ and File.directory?(File.join(File.expand_path(ENV['HOME']), '.rake-compiler'))
- begin
- ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
- require 'rake/extensiontask'
- load('home_run.gemspec')
- desc "Internal--cross compile the windows binary gem"
- Rake::ExtensionTask.new('date_ext', HOME_RUN_GEMSPEC) do |ext|
- ext.cross_compile = true
- ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
- end
- rescue LoadError
- end
+begin
+ require 'rake/extensiontask'
+ Rake::ExtensionTask.new('date_ext')
+rescue LoadError
end
-desc "Build the ragel parser"
+desc "Regenerate the ragel parser"
task :parser do
sh %{cd ext/date_ext && ragel date_parser.rl}
end
-desc "Build the extension"
-task :build=>[:clean] do
- sh %{cd ext/date_ext && #{RUBY} extconf.rb && make}
-end
-
-desc "Build debug version of extension"
-task :build_debug=>[:clean] do
- ENV['DEBUG'] = '1'
- Rake::Task[:build].invoke
-end
-
desc "Start an IRB shell using the extension"
task :irb do
irb = ENV['IRB'] || File.join(RbConfig::CONFIG['bindir'], File.basename(RUBY).sub('ruby', 'irb'))
- sh %{#{irb} -I lib -I ext/date_ext -r date}
+ sh %{#{irb} -I lib -r date}
end
desc "Run comparative benchmarks"
@@ -89,11 +70,11 @@ task :mem_bench do
end
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/mem_bench.rb`.to_i
- home_run = `#{RUBY} -I lib -I ext/date_ext bench/mem_bench.rb`.to_i
+ home_run = `#{RUBY} -I lib bench/mem_bench.rb`.to_i
puts "Date memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_mem_bench.rb`.to_i
- home_run = `#{RUBY} -I lib -I ext/date_ext bench/dt_mem_bench.rb`.to_i
+ home_run = `#{RUBY} -I lib bench/dt_mem_bench.rb`.to_i
puts "DateTime memory use,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
end
@@ -105,10 +86,10 @@ task :garbage_bench do
end
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/garbage_bench.rb`.to_i
- home_run = `#{RUBY} -I lib -I ext/date_ext bench/garbage_bench.rb`.to_i
+ home_run = `#{RUBY} -I lib bench/garbage_bench.rb`.to_i
puts "Date garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
stdlib = `#{RUBY} -I #{RbConfig::CONFIG['rubylibdir']} bench/dt_garbage_bench.rb`.to_i
- home_run = `#{RUBY} -I lib -I ext/date_ext bench/dt_garbage_bench.rb`.to_i
+ home_run = `#{RUBY} -I lib bench/dt_garbage_bench.rb`.to_i
puts "DateTime garbage created,#{stdlib}KB,#{home_run}KB,#{sprintf('%0.1f', stdlib/home_run.to_f)}"
end
View
9 Rakefile.cross
@@ -0,0 +1,9 @@
+require File.join(File.dirname(File.expand_path(__FILE__)), 'Rakefile')
+
+ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
+require 'rake/extensiontask'
+load('home_run.gemspec')
+Rake::ExtensionTask.new('date_ext', HOME_RUN_GEMSPEC) do |ext|
+ ext.cross_compile = true
+ ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
+end
View
2 bench/cpu_bench_util.rb
@@ -7,7 +7,7 @@
SDT = DateTime
Object.send(:remove_const, :Date)
Object.send(:remove_const, :DateTime)
-$:.unshift(File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'ext', 'date_ext'))
+$:.unshift(File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib'))
load 'lib/date.rb'
load 'lib/date/format.rb'
HRD = Date
View
4 bin/home_run
@@ -57,8 +57,8 @@ when :install
FUV.cp("lib/date.rb", RbConfig::CONFIG['sitelibdir'])
FUV.mkdir_p(File.join(RbConfig::CONFIG['sitelibdir'], 'date'))
FUV.cp("lib/date/format.rb", File.join(RbConfig::CONFIG['sitelibdir'], 'date'))
- if File.exists?("ext/date_ext/date_ext.#{RbConfig::CONFIG['DLEXT']}")
- FUV.cp("ext/date_ext/date_ext.#{RbConfig::CONFIG['DLEXT']}", RbConfig::CONFIG['sitearchdir'])
+ if File.exists?("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}")
+ FUV.cp("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}", RbConfig::CONFIG['sitearchdir'])
else
# Windows binary gem files
if File.exists?('lib/1.8/date_ext.so')

0 comments on commit 5cd19d1

Please sign in to comment.