Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replace custom extension tasks w/ rake-compiler

  • Loading branch information...
commit 9d4f025692e1668d6566725ecc91ec9d0036f9e9 1 parent 04114f6
Marc-André Cournoyer macournoyer authored
14 Rakefile
@@ -4,12 +4,24 @@ SUDO = (WIN ? "" : "sudo")
4 4
5 5 require 'rake'
6 6 require 'rake/clean'
  7 +require 'rake/extensiontask' # from rake-compiler gem
7 8
8 9 $: << File.join(File.dirname(__FILE__), 'lib')
9 10 require 'thin'
10 11
  12 +# Load tasks in tasks/
11 13 Dir['tasks/**/*.rake'].each { |rake| load rake }
12 14
13 15 task :default => :spec
14 16
15   -ext_task :thin_parser
  17 +Rake::ExtensionTask.new('thin_parser', Thin::GemSpec)
  18 +
  19 +desc "Compile the Ragel state machines"
  20 +task :ragel do
  21 + Dir.chdir 'ext/thin_parser' do
  22 + target = "parser.c"
  23 + File.unlink target if File.exist? target
  24 + sh "ragel parser.rl | rlgen-cd -G2 -o #{target}"
  25 + raise "Failed to compile Ragel state machine" unless File.exist? target
  26 + end
  27 +end
7 tasks/deploy.rake
... ... @@ -1,14 +1,11 @@
1 1 namespace :deploy do
2 2 task :site => %w(site:upload rdoc:upload)
3 3
4   - desc 'Deploy on code.macournoyer.com'
5   - task :alpha => %w(gem:upload deploy:site)
6   -
7 4 desc 'Deploy on rubyforge'
8   - task :public => %w(gem:upload_rubyforge deploy:site)
  5 + task :gem => %w(gem:upload_rubyforge deploy:site)
9 6 end
10 7 desc 'Deploy on all servers'
11   -task :deploy => %w(deploy:alpha deploy:public)
  8 +task :deploy => "deploy:gem"
12 9
13 10 def upload(file, to, options={})
14 11 sh %{ssh macournoyer@code.macournoyer.com "rm -rf code.macournoyer.com/#{to}"} if options[:replace]
42 tasks/ext.rake
... ... @@ -1,42 +0,0 @@
1   -CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)
2   -
3   -def ext_task(name)
4   - ext_dir = "ext/#{name}"
5   - ext_bundle = "#{ext_dir}/#{name}.#{Config::CONFIG['DLEXT']}"
6   - ext_files = FileList[
7   - "#{ext_dir}/*.c",
8   - "#{ext_dir}/*.h",
9   - "#{ext_dir}/*.rl",
10   - "#{ext_dir}/extconf.rb",
11   - "#{ext_dir}/Makefile",
12   - "lib"
13   - ]
14   -
15   - task "compile:#{name}" => ["#{ext_dir}/Makefile", ext_bundle]
16   - task :compile => "compile:#{name}"
17   -
18   - file "#{ext_dir}/Makefile" => ["#{ext_dir}/extconf.rb"] do
19   - cd(ext_dir) { ruby "extconf.rb" }
20   - end
21   -
22   - file ext_bundle => ext_files do
23   - cd ext_dir do
24   - sh(WIN ? 'nmake' : 'make')
25   - end
26   - cp ext_bundle, 'lib/'
27   - end
28   -end
29   -
30   -desc "Compile the Ragel state machines"
31   -task :ragel do
32   - Dir.chdir 'ext/thin_parser' do
33   - target = "parser.c"
34   - File.unlink target if File.exist? target
35   - sh "ragel parser.rl | rlgen-cd -G2 -o #{target}"
36   - raise "Failed to compile Ragel state machine" unless File.exist? target
37   - end
38   -end
39   -
40   -desc "Compile the extensions"
41   -task :compile
42   -task :package => :compile
42 tasks/gem.rake
@@ -5,7 +5,7 @@ WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'i386-mswin32'
5 5
6 6 task :clean => :clobber_package
7 7
8   -spec = Gem::Specification.new do |s|
  8 +Thin::GemSpec = Gem::Specification.new do |s|
9 9 s.name = Thin::NAME
10 10 s.version = Thin::VERSION::STRING
11 11 s.platform = WIN ? Gem::Platform::CURRENT : Gem::Platform::RUBY
@@ -40,8 +40,8 @@ spec = Gem::Specification.new do |s|
40 40 s.bindir = "bin"
41 41 end
42 42
43   -Rake::GemPackageTask.new(spec) do |p|
44   - p.gem_spec = spec
  43 +Rake::GemPackageTask.new(Thin::GemSpec) do |p|
  44 + p.gem_spec = Thin::GemSpec
45 45 end
46 46
47 47 task :tag_warn do
@@ -61,48 +61,22 @@ task :gem => :tag_warn
61 61 namespace :gem do
62 62 desc "Update the gemspec for GitHub's gem server"
63 63 task :github do
64   - File.open("thin.gemspec", 'w') { |f| f << YAML.dump(spec) }
65   - end
66   -
67   - desc 'Upload gem to code.macournoyer.com'
68   - task :upload => :gem do
69   - upload "pkg/#{spec.full_name}.gem", 'gems'
70   - system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
  64 + File.open("thin.gemspec", 'w') { |f| f << YAML.dump(Thin::GemSpec) }
71 65 end
72 66
73 67 namespace :upload do
74 68 desc 'Upload the precompiled win32 gem to code.macournoyer.com'
75 69 task :win do
76   - upload "pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
  70 + upload "pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
77 71 system 'ssh macournoyer@code.macournoyer.com "cd code.macournoyer.com && gem generate_index"'
78 72 end
79 73
80 74 desc 'Upload gems (ruby & win32) to rubyforge.org'
81 75 task :rubyforge => :gem do
82 76 sh 'rubyforge login'
83   - sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
84   - sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
85   - sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem"
86   - end
87   - end
88   -
89   - desc 'Download the Windows gem from Kevin repo'
90   - task 'download:win' => 'pkg' do
91   - cd 'pkg' do
92   - `wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}-#{WIN_SUFFIX}.gem`
  77 + sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
  78 + sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}.gem"
  79 + sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{Thin::GemSpec.full_name}-#{WIN_SUFFIX}.gem"
93 80 end
94 81 end
95 82 end
96   -
97   -task :install => [:clobber, :compile, :package] do
98   - sh "#{SUDO} #{gem} install pkg/#{spec.full_name}.gem"
99   -end
100   -
101   -task :uninstall => :clean do
102   - sh "#{SUDO} #{gem} uninstall -v #{Thin::VERSION::STRING} -x #{Thin::NAME}"
103   -end
104   -
105   -
106   -def gem
107   - RUBY_1_9 ? 'gem19' : 'gem'
108   -end

0 comments on commit 9d4f025

Please sign in to comment.
Something went wrong with that request. Please try again.