diff --git a/Rakefile b/Rakefile index 872d9119..b5688292 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,8 @@ require 'fileutils' include FileUtils setup_tests -setup_clean ["ext/http11/Makefile", "pkg", "lib/*.bundle", "ext/http11/*.bundle", "doc/site/output"] +setup_clean ["ext/http11/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/http11/Makefile", "pkg", "lib/*.bundle", "*.gem", "doc/site/output", ".config"] + setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/*.rb', 'doc/**/*.rdoc', 'ext/http11/http11.c'] desc "Does a full compile, test run" @@ -34,3 +35,17 @@ test_file = "test/test_ws.rb" setup_gem("mongrel", "0.3.3", "Zed A. Shaw", summary, ['mongrel_rails'], test_file) do |spec| spec.add_dependency('daemons', '>= 0.4.2') end + +desc "Build a binary gem for Win32" +task :win32_gem => [:clean, :compile, :test, :package_win32] + +task :package_win32 do + setup_win32_gem("mongrel", "0.3.3", "Zed A. Shaw", summary, + ['mongrel_rails'], test_file) do |spec| + spec.add_dependency('daemons', '>= 0.4.2') + spec.files << 'ext/http11/http11.so' + spec.extensions = [] + spec.platform = Gem::Platform::WIN32 + end +end + diff --git a/tools/rakehelp.rb b/tools/rakehelp.rb index 577acb79..58430ffd 100644 --- a/tools/rakehelp.rb +++ b/tools/rakehelp.rb @@ -1,7 +1,7 @@ def make(makedir) Dir.chdir(makedir) do - sh 'make' + sh(PLATFORM =~ /win32/ ? 'nmake' : 'make') end end @@ -64,14 +64,14 @@ def setup_extension(dir, extension) end -def setup_gem(pkg_name, pkg_version, author, summary, executables, test_file) +def base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file) pkg_version = pkg_version pkg_name = pkg_name pkg_file_name = "#{pkg_name}-#{pkg_version}" - - spec = Gem::Specification.new do |s| + Gem::Specification.new do |s| s.name = pkg_name s.version = pkg_version + s.required_ruby_version = '>= 1.8.3' s.platform = Gem::Platform::RUBY s.author = author s.summary = summary @@ -90,14 +90,22 @@ def setup_gem(pkg_name, pkg_version, author, summary, executables, test_file) s.executables = executables s.bindir = "bin" - - if block_given? - yield s - end end - +end + +def setup_gem(pkg_name, pkg_version, author, summary, executables, test_file) + spec = base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file) + yield spec if block_given? + Rake::GemPackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true end end + +def setup_win32_gem(pkg_name, pkg_version, author, summary, executables, test_file) + spec = base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file) + yield spec if block_given? + + Gem::Builder.new(spec).build +end