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