blob: b5aa2ad8424e191fd0123a4a17f95d429718d28a [file] [log] [blame]
Kevin Clark5a7103a2008-06-18 00:55:11 +00001require 'rubygems'
2require 'rake'
3require 'spec/rake/spectask'
4
Kevin Clarkc06b0152008-06-24 01:05:57 +00005THRIFT = '../../compiler/cpp/thrift'
6
Kevin Clark031baf72008-11-14 17:11:39 +00007task :default => [:'gen-rb', :spec, :test]
Kevin Clark5a7103a2008-06-18 00:55:11 +00008
Kevin Clarkc06b0152008-06-24 01:05:57 +00009Spec::Rake::SpecTask.new do |t|
Kevin Clark5a7103a2008-06-18 00:55:11 +000010 t.spec_files = FileList['spec/**/*_spec.rb']
11 t.spec_opts = ['--color']
12end
Kevin Clarkc2a07b12008-06-18 00:57:06 +000013
Kevin Clarkc06b0152008-06-24 01:05:57 +000014Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
Kevin Clarkeb0dd7f2008-06-18 01:12:15 +000015 t.spec_files = FileList['spec/**/*_spec.rb']
16 t.spec_opts = ['--color']
17 t.rcov = true
18 t.rcov_opts = ['--exclude', '^spec,/gems/']
19end
20
Kevin Clarkc06b0152008-06-24 01:05:57 +000021desc 'Run the compiler tests (requires full thrift checkout)'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000022task :test do
Kevin Clarkc06b0152008-06-24 01:05:57 +000023 # 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 Clark4bd89162008-07-08 00:47:49 +000026 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
Kevin Clarka7613dd2008-06-18 01:13:48 +000027end
28
Kevin Clarkca8a1b32008-06-18 01:17:06 +000029desc 'Compile the .thrift files for the specs'
Kevin Clarkc06b0152008-06-24 01:05:57 +000030task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark']
Kevin Clarkca8a1b32008-06-18 01:17:06 +000031
Kevin Clarkc06b0152008-06-24 01:05:57 +000032namespace :'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 Clarkca8a1b32008-06-18 01:17:06 +000037
Kevin Clarkc06b0152008-06-24 01:05:57 +000038 task :'benchmark' do
39 dir = File.dirname(__FILE__) + '/benchmark'
40 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
41 end
Kevin Clarkca8a1b32008-06-18 01:17:06 +000042end
43
44desc 'Run benchmarking of NonblockingServer'
45task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000046 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000047end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000048
49
50begin
51 require 'echoe'
52
53 Echoe.new('thrift') do |p|
54 p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee']
55 p.email = ['kevin@sb.org', 'kevin.clark@gmail.com', 'mcslee@facebook.com']
56 p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)"
57 p.url = "http://incubator.apache.org/thrift/"
58 p.include_rakefile = true
59 end
Kevin Clark4bd89162008-07-08 00:47:49 +000060
61 task :install => [:check_site_lib]
62
63 require 'rbconfig'
64 task :check_site_lib do
65 if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
66 fail "thrift is already installed in site_ruby"
67 end
68 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000069rescue LoadError
Kevin Clark33871152008-06-26 18:14:25 +000070 [:install, :package].each do |t|
71 desc "Stub for #{t}"
72 task t do
73 fail "The Echoe gem is required for this task"
74 end
75 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000076end