Skip to content

Commit

Permalink
Make cross compiling to win32 work under OS X, w00t!
Browse files Browse the repository at this point in the history
Automate release process some more.
  • Loading branch information
macournoyer committed Sep 6, 2009
1 parent 9d4f025 commit 4ad001c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ Dir['tasks/**/*.rake'].each { |rake| load rake }

task :default => :spec

Rake::ExtensionTask.new('thin_parser', Thin::GemSpec)
Rake::ExtensionTask.new('thin_parser', Thin::GemSpec) do |ext|
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
ext.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
# configure options only for cross compile
end

CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)

desc "Compile the Ragel state machines"
task :ragel do
Expand All @@ -25,3 +31,6 @@ task :ragel do
raise "Failed to compile Ragel state machine" unless File.exist? target
end
end

desc "Release version #{Thin::VERSION::STRING} gems to rubyforge"
task :release => [:clean, :cross, :native, :gem, :tag, "gem:upload"]
22 changes: 7 additions & 15 deletions tasks/gem.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rake/gempackagetask'
require 'yaml'

WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'i386-mswin32'
WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'x86-mswin32'

task :clean => :clobber_package

Expand Down Expand Up @@ -64,19 +64,11 @@ namespace :gem do
File.open("thin.gemspec", 'w') { |f| f << YAML.dump(Thin::GemSpec) }
end

namespace :upload do
desc 'Upload the precompiled win32 gem to code.macournoyer.com'
task :win do
upload "pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
end

desc 'Upload gems (ruby & win32) to rubyforge.org'
task :rubyforge => :gem do
sh 'rubyforge login'
sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem"
end
desc 'Upload gems (ruby & win32) to rubyforge.org'
task :upload => :gem do
sh 'rubyforge login'
sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem"
end
end

1 comment on commit 4ad001c

@luislavena
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

It is true what I see here?

Thin on Windows!

I've a couple of comments:

  • You don't need to cleanup temporary files, those are stored in tmp/ (gitignore it)
  • Add x86-mingw32 to the cross platform array, so old and new RubyInstallers can benefit from binaries.
  • If thin works with Ruby 1.9, perhaps you want to build fat-binaries! use RUBY_CC_VERSION with multiple versions and you're done!

Thank you for putting this in your project and feel free to add this to rake-compiler wiki!

Cheers!
Luis

Please sign in to comment.