Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
A couple refactorings in rake tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
macournoyer committed Mar 2, 2008
1 parent 4c30c78 commit 59a972c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -9,3 +9,5 @@ require 'lib/thin'
Dir['tasks/**/*.rake'].each { |rake| load rake }

task :default => :spec

ext_task :thin_parser
52 changes: 28 additions & 24 deletions tasks/ext.rake
@@ -1,19 +1,35 @@
CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)

EXT_DIR = 'ext/thin_parser'
EXT_BUNDLE = "#{EXT_DIR}/thin_parser.#{Config::CONFIG['DLEXT']}"
EXT_FILES = FileList[
"#{EXT_DIR}/*.c",
"#{EXT_DIR}/*.h",
"#{EXT_DIR}/*.rl",
"#{EXT_DIR}/extconf.rb",
"#{EXT_DIR}/Makefile",
"lib"
]
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_DIR 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}"
Expand All @@ -22,17 +38,5 @@ task :ragel do
end

desc "Compile the extensions"
task :compile => ["#{EXT_DIR}/Makefile", EXT_BUNDLE]

task :compile
task :package => :compile

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
2 changes: 2 additions & 0 deletions tasks/gem.rake
Expand Up @@ -11,6 +11,8 @@ spec = Gem::Specification.new do |s|
s.author = "Marc-Andre Cournoyer"
s.email = 'macournoyer@gmail.com'
s.homepage = 'http://code.macournoyer.com/thin/'
s.rubyforge_project = 'thin'
s.has_rdoc = true
s.executables = %w(thin)

s.required_ruby_version = '>= 1.8.6' # Makes sure the CGI eof fix is there
Expand Down

0 comments on commit 59a972c

Please sign in to comment.