Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace custom extension tasks w/ rake-compiler
  • Loading branch information
macournoyer committed Sep 6, 2009
1 parent 04114f6 commit 9d4f025
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 82 deletions.
14 changes: 13 additions & 1 deletion Rakefile
Expand Up @@ -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
7 changes: 2 additions & 5 deletions 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]
Expand Down
42 changes: 0 additions & 42 deletions tasks/ext.rake

This file was deleted.

42 changes: 8 additions & 34 deletions tasks/gem.rake
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 9d4f025

Please sign in to comment.