Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 1 | require 'rubygems' |
| 2 | require 'rake' |
| 3 | require 'spec/rake/spectask' |
| 4 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 5 | THRIFT = '../../compiler/cpp/thrift' |
| 6 | |
Kevin Clark | 031baf7 | 2008-11-14 17:11:39 +0000 | [diff] [blame] | 7 | task :default => [:'gen-rb', :spec, :test] |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 8 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 9 | Spec::Rake::SpecTask.new do |t| |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 10 | t.spec_files = FileList['spec/**/*_spec.rb'] |
| 11 | t.spec_opts = ['--color'] |
| 12 | end |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 13 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 14 | Spec::Rake::SpecTask.new(:'spec:rcov') do |t| |
Kevin Clark | eb0dd7f | 2008-06-18 01:12:15 +0000 | [diff] [blame] | 15 | t.spec_files = FileList['spec/**/*_spec.rb'] |
| 16 | t.spec_opts = ['--color'] |
| 17 | t.rcov = true |
| 18 | t.rcov_opts = ['--exclude', '^spec,/gems/'] |
| 19 | end |
| 20 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 21 | desc 'Run the compiler tests (requires full thrift checkout)' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 22 | task :test do |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 23 | # ensure this is a full thrift checkout and not a tarball of the ruby libs |
| 24 | cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null' |
| 25 | system(cmd) or fail "rake test requires a full thrift checkout" |
Kevin Clark | 4bd8916 | 2008-07-08 00:47:49 +0000 | [diff] [blame] | 26 | sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check" |
Kevin Clark | a7613dd | 2008-06-18 01:13:48 +0000 | [diff] [blame] | 27 | end |
| 28 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 29 | desc 'Compile the .thrift files for the specs' |
Bryan Duxbury | d815c21 | 2009-03-19 18:57:43 +0000 | [diff] [blame^] | 30 | task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto'] |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 31 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 32 | namespace :'gen-rb' do |
| 33 | task :'spec' do |
| 34 | dir = File.dirname(__FILE__) + '/spec' |
| 35 | sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift" |
| 36 | end |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 37 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 38 | task :'benchmark' do |
| 39 | dir = File.dirname(__FILE__) + '/benchmark' |
| 40 | sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift" |
| 41 | end |
Bryan Duxbury | d815c21 | 2009-03-19 18:57:43 +0000 | [diff] [blame^] | 42 | |
| 43 | task :'debug_proto' do |
| 44 | sh "mkdir", "-p", "debug_proto_test" |
| 45 | sh THRIFT, '--gen', 'rb', "-o", "debug_proto_test", "../../test/DebugProtoTest.thrift" |
| 46 | end |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 47 | end |
| 48 | |
| 49 | desc 'Run benchmarking of NonblockingServer' |
| 50 | task :benchmark do |
Kevin Clark | d3cee02 | 2008-06-18 01:19:09 +0000 | [diff] [blame] | 51 | ruby 'benchmark/benchmark.rb' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 52 | end |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 53 | |
| 54 | |
| 55 | begin |
| 56 | require 'echoe' |
| 57 | |
| 58 | Echoe.new('thrift') do |p| |
| 59 | p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee'] |
| 60 | p.email = ['kevin@sb.org', 'kevin.clark@gmail.com', 'mcslee@facebook.com'] |
| 61 | p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)" |
| 62 | p.url = "http://incubator.apache.org/thrift/" |
| 63 | p.include_rakefile = true |
| 64 | end |
Kevin Clark | 4bd8916 | 2008-07-08 00:47:49 +0000 | [diff] [blame] | 65 | |
| 66 | task :install => [:check_site_lib] |
| 67 | |
| 68 | require 'rbconfig' |
| 69 | task :check_site_lib do |
| 70 | if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb')) |
| 71 | fail "thrift is already installed in site_ruby" |
| 72 | end |
| 73 | end |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 74 | rescue LoadError |
Kevin Clark | 3387115 | 2008-06-26 18:14:25 +0000 | [diff] [blame] | 75 | [:install, :package].each do |t| |
| 76 | desc "Stub for #{t}" |
| 77 | task t do |
| 78 | fail "The Echoe gem is required for this task" |
| 79 | end |
| 80 | end |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 81 | end |