Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace custom extension tasks w/ rake-compiler

  • Loading branch information...
commit 9d4f025692e1668d6566725ecc91ec9d0036f9e9 1 parent 04114f6
@macournoyer macournoyer authored
Showing with 23 additions and 82 deletions.
  1. +13 −1 Rakefile
  2. +2 −5 tasks/deploy.rake
  3. +0 −42 tasks/ext.rake
  4. +8 −34 tasks/gem.rake
View
14 Rakefile
@@ -4,12 +4,24 @@ SUDO = (WIN ? "" : "sudo")
require 'rake'
require 'rake/clean'
+require 'rake/extensiontask' # from rake-compiler gem
$: << File.join(File.dirname(__FILE__), 'lib')
require 'thin'
+# Load tasks in tasks/
Dir['tasks/**/*.rake'].each { |rake| load rake }
task :default => :spec
-ext_task :thin_parser
+Rake::ExtensionTask.new('thin_parser', Thin::GemSpec)
+
+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 | rlgen-cd -G2 -o #{target}"
+ raise "Failed to compile Ragel state machine" unless File.exist? target
+ end
+end
View
7 tasks/deploy.rake
@@ -1,14 +1,11 @@
namespace :deploy do
task :site => %w(site:upload rdoc:upload)
- desc 'Deploy on code.macournoyer.com'
- task :alpha => %w(gem:upload deploy:site)
-
desc 'Deploy on rubyforge'
- task :public => %w(gem:upload_rubyforge deploy:site)
+ task :gem => %w(gem:upload_rubyforge deploy:site)
end
desc 'Deploy on all servers'
-task :deploy => %w(deploy:alpha deploy:public)
+task :deploy => "deploy:gem"
def upload(file, to, options={})
sh %{ssh macournoyer@code.macournoyer.com "rm -rf code.macournoyer.com/#{to}"} if options[:replace]
View
42 tasks/ext.rake
@@ -1,42 +0,0 @@
-CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)
-
-def ext_task(name)
- ext_dir = "ext/#{name}"
- ext_bundle = "#{ext_dir}/#{name}.#{Config::CONFIG['DLEXT']}"
- ext_files = FileList[
- "#{ext_dir}/*.c",
- "#{ext_dir}/*.h",
- "#{ext_dir}/*.rl",
- "#{ext_dir}/extconf.rb",
- "#{ext_dir}/Makefile",
- "lib"
- ]
-
- task "compile:#{name}" => ["#{ext_dir}/Makefile", ext_bundle]
- task :compile => "compile:#{name}"
-
- file "#{ext_dir}/Makefile" => ["#{ext_dir}/extconf.rb"] do
- cd(ext_dir) { ruby "extconf.rb" }
- end
-
- file ext_bundle => ext_files do
- cd ext_dir do
- sh(WIN ? 'nmake' : 'make')
- end
- cp ext_bundle, 'lib/'
- end
-end
-
-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 | rlgen-cd -G2 -o #{target}"
- raise "Failed to compile Ragel state machine" unless File.exist? target
- end
-end
-
-desc "Compile the extensions"
-task :compile
-task :package => :compile
View
42 tasks/gem.rake
@@ -5,7 +5,7 @@ WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'i386-mswin32'
task :clean => :clobber_package
-spec = Gem::Specification.new do |s|
+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
@@ -40,8 +40,8 @@ spec = Gem::Specification.new do |s|
s.bindir = "bin"
end
-Rake::GemPackageTask.new(spec) do |p|
- p.gem_spec = spec
+Rake::GemPackageTask.new(Thin::GemSpec) do |p|
+ p.gem_spec = Thin::GemSpec
end
task :tag_warn do
@@ -61,48 +61,22 @@ task :gem => :tag_warn
namespace :gem do
desc "Update the gemspec for GitHub's gem server"
task :github do
- File.open("thin.gemspec", 'w') { |f| f << YAML.dump(spec) }
- end
-
- desc 'Upload gem to code.macournoyer.com'
- task :upload => :gem do
- upload "pkg/#{spec.full_name}.gem", 'gems'
- system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
+ 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/#{spec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
+ 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/#{spec.full_name}.gem"
- sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
- sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem"
- end
- end
-
- desc 'Download the Windows gem from Kevin repo'
- task 'download:win' => 'pkg' do
- cd 'pkg' do
- `wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}-#{WIN_SUFFIX}.gem`
+ 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
end
-
-task :install => [:clobber, :compile, :package] do
- sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
-end
-
-task :uninstall => :clean do
- sh "#{SUDO} #{gem} uninstall -v #{Thin::VERSION::STRING} -x #{Thin::NAME}"
-end
-
-
-def gem
- RUBY_1_9 ? 'gem19' : 'gem'
-end
Please sign in to comment.
Something went wrong with that request. Please try again.