diff --git a/.gitignore b/.gitignore index da3523a6..a38c48b0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ ext/thin_parser/vc60.pdb ext/thin_parser/*.so *.bundle *.so +*.gem log spec/rails_app/log doc/rdoc/* diff --git a/Rakefile b/Rakefile index 26e8628b..93648879 100644 --- a/Rakefile +++ b/Rakefile @@ -1,44 +1,21 @@ -RUBY_1_9 = RUBY_VERSION =~ /^1\.9/ -WIN = (RUBY_PLATFORM =~ /mswin|cygwin/) -SUDO = (WIN ? "" : "sudo") - require 'rake' require 'rake/clean' -require 'rake/extensiontask' # from rake-compiler gem - -$: << File.join(File.dirname(__FILE__), 'lib') -require 'thin/version' +load 'thin.gemspec' # Load tasks in tasks/ Dir['tasks/**/*.rake'].each { |rake| load rake } task :default => :spec -Rake::ExtensionTask.new('thin_parser', Thin::GemSpec) do |ext| - # enable cross compilation (requires cross compile toolchain) - ext.cross_compile = true - - # forces the Windows platform instead of the default one - # configure options only for cross compile - ext.cross_platform = %w( i386-mswin32 x86-mingw32 ) -end - -CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM lib/1.{8,9}}) - -desc "Compile the Ragel state machines" -task :ragel do - Dir.chdir 'ext/thin_parser' do - target = "parser.c" - File.unlink target if File.exist? target - sh "ragel parser.rl -G2 -o #{target}" - raise "Failed to compile Ragel state machine" unless File.exist? target - end +desc "Build gem packages" +task :build do + sh "gem build thin.gemspec" end -desc "Build gem packages" -task :gems do - sh "rake clean gem && rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1" +desc "Push gem packages" +task :push => :build do + sh "gem push thin-*.gem" end -desc "Release version #{Thin::VERSION::STRING} gems to rubyforge" -task :release => [:tag, "gem:push"] \ No newline at end of file +desc "Release version #{Thin::VERSION::STRING}" +task :release => [:tag, :push] \ No newline at end of file diff --git a/tasks/ext.rake b/tasks/ext.rake new file mode 100644 index 00000000..7f51794c --- /dev/null +++ b/tasks/ext.rake @@ -0,0 +1,22 @@ +require 'rake/extensiontask' # from rake-compiler gem + +Rake::ExtensionTask.new('thin_parser', Thin::GemSpec) do |ext| + # enable cross compilation (requires cross compile toolchain) + ext.cross_compile = true + + # forces the Windows platform instead of the default one + # configure options only for cross compile + ext.cross_platform = %w( i386-mswin32 x86-mingw32 ) +end + +CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM lib/1.{8,9}}) + +desc "Compile the Ragel state machines" +task :ragel do + Dir.chdir 'ext/thin_parser' do + target = "parser.c" + File.unlink target if File.exist? target + sh "ragel parser.rl -G2 -o #{target}" + raise "Failed to compile Ragel state machine" unless File.exist? target + end +end diff --git a/tasks/gem.rake b/tasks/gem.rake deleted file mode 100644 index efaeb6de..00000000 --- a/tasks/gem.rake +++ /dev/null @@ -1,65 +0,0 @@ -require 'rake/gempackagetask' -require 'yaml' - -task :clean => :clobber_package - -Thin::GemSpec = Gem::Specification.new do |s| - s.name = Thin::NAME - s.version = Thin::VERSION::STRING - s.platform = WIN ? Gem::Platform::CURRENT : Gem::Platform::RUBY - s.summary = - s.description = "A thin and fast web server" - s.author = "Marc-Andre Cournoyer" - s.email = 'macournoyer@gmail.com' - s.homepage = 'http://code.macournoyer.com/thin/' - s.rubyforge_project = 'thin' - s.executables = %w(thin) - - s.required_ruby_version = '>= 1.8.5' - - s.add_dependency 'rack', '>= 1.0.0' - s.add_dependency 'eventmachine', '>= 0.12.6' - unless WIN - s.add_dependency 'daemons', '>= 1.0.9' - end - - s.files = %w(CHANGELOG README Rakefile) + - Dir.glob("{benchmark,bin,doc,example,lib,spec,tasks}/**/*") - Dir.glob("lib/thin_parser.*") + - Dir.glob("ext/**/*.{h,c,rb,rl}") - - if WIN - s.files += FileList["lib/*/thin_parser.*"].to_a - else - s.extensions = FileList["ext/**/extconf.rb"].to_a - end - - s.require_path = "lib" - s.bindir = "bin" -end - -Rake::GemPackageTask.new(Thin::GemSpec) do |p| - p.gem_spec = Thin::GemSpec -end - -task :tag_warn do - puts "*" * 40 - puts "Don't forget to tag the release:" - puts - puts " git tag -m 'Tagging #{Thin::SERVER}' -a v#{Thin::VERSION::STRING}" - puts - puts "or run rake tag" - puts "*" * 40 -end -task :tag do - sh "git tag -m 'Tagging #{Thin::SERVER}' -a v#{Thin::VERSION::STRING}" -end -task :gem => :tag_warn - -namespace :gem do - desc 'Upload gems to gemcutter.org' - task :push do - Dir["pkg/#{Thin::GemSpec.full_name}*.gem"].each do |file| - sh "gem push #{file}" - end - end -end diff --git a/thin.gemspec b/thin.gemspec new file mode 100644 index 00000000..7291deea --- /dev/null +++ b/thin.gemspec @@ -0,0 +1,38 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "thin/version" + +# Describe your gem and declare its dependencies: +Thin::GemSpec = Gem::Specification.new do |s| + s.name = Thin::NAME + s.version = Thin::VERSION::STRING + s.platform = Thin.win? ? Gem::Platform::CURRENT : Gem::Platform::RUBY + s.summary = + s.description = "A thin and fast web server" + s.author = "Marc-Andre Cournoyer" + s.email = 'macournoyer@gmail.com' + s.homepage = 'http://code.macournoyer.com/thin/' + s.rubyforge_project = 'thin' + s.license = 'Ruby' + s.executables = %w( thin ) + + s.required_ruby_version = '>= 1.8.5' + + s.add_dependency 'rack', '>= 1.0.0' + s.add_dependency 'eventmachine', '>= 0.12.6' + s.add_dependency 'daemons', '>= 1.0.9' unless Thin.win? + + s.files = %w(CHANGELOG README.md Rakefile) + + Dir["{bin,doc,example,lib}/**/*"] - Dir["lib/thin_parser.*"] + + Dir["ext/**/*.{h,c,rb,rl}"] + + if Thin.win? + s.files += Dir["lib/*/thin_parser.*"] + else + s.extensions = Dir["ext/**/extconf.rb"] + end + + s.require_path = "lib" + s.bindir = "bin" +end