blob: 96d14482c48a41bcd6cddec7d26dc9e566a454a8 [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'
Bryan Duxburyd815c212009-03-19 18:57:43 +000030task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
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
Bryan Duxburyd815c212009-03-19 18:57:43 +000042
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 Clarkca8a1b32008-06-18 01:17:06 +000047end
48
49desc 'Run benchmarking of NonblockingServer'
50task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000051 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000052end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000053
54
55begin
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 Clark4bd89162008-07-08 00:47:49 +000065
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 Clark3a9ffbd2008-06-24 01:06:00 +000074rescue LoadError
Kevin Clark33871152008-06-26 18:14:25 +000075 [: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 Clark3a9ffbd2008-06-24 01:06:00 +000081end