Skip to content

Commit

Permalink
rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Cliff Moon committed Jan 11, 2009
1 parent c0f8aae commit cf82df9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Rakefile
@@ -1,3 +1,12 @@
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
SUDO = (WIN ? "" : "sudo")

require 'rake'
require 'rake/clean'

Dir['tasks/**/*.rake'].each { |rake| load rake }

task :default => :spec

ext_task :memcache_protocol
43 changes: 43 additions & 0 deletions tasks/ext.rake
@@ -0,0 +1,43 @@
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"
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' do
target = "protocol.c"
File.unlink target if File.exist? target
sh "ragel -C protocol.rl > #{target}"
raise "Failed to compile Ragel state machine" unless File.exist? target
end
end

desc "Compile the extensions"
task :compile
task :package => :compile

7 changes: 7 additions & 0 deletions tasks/spec.rake
@@ -0,0 +1,7 @@
require 'spec/rake/spectask'

Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
end

task :spec => [:compile]

0 comments on commit cf82df9

Please sign in to comment.