blob: a9d1710cfc02119504122cbd99b0295853ae27e3 [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
Bryan Duxburyf0377e22009-03-30 17:14:06 +00007task :default => [:spec]
Kevin Clark5a7103a2008-06-18 00:55:11 +00008
Bryan Duxburyf0377e22009-03-30 17:14:06 +00009task :spec => [:'gen-rb', :realspec]
10
11Spec::Rake::SpecTask.new(:realspec) do |t|
Kevin Clark5a7103a2008-06-18 00:55:11 +000012 t.spec_files = FileList['spec/**/*_spec.rb']
13 t.spec_opts = ['--color']
14end
Kevin Clarkc2a07b12008-06-18 00:57:06 +000015
Kevin Clarkc06b0152008-06-24 01:05:57 +000016Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
Kevin Clarkeb0dd7f2008-06-18 01:12:15 +000017 t.spec_files = FileList['spec/**/*_spec.rb']
18 t.spec_opts = ['--color']
19 t.rcov = true
20 t.rcov_opts = ['--exclude', '^spec,/gems/']
21end
22
Kevin Clarkc06b0152008-06-24 01:05:57 +000023desc 'Run the compiler tests (requires full thrift checkout)'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000024task :test do
Kevin Clarkc06b0152008-06-24 01:05:57 +000025 # 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 Clark4bd89162008-07-08 00:47:49 +000028 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
Kevin Clarka7613dd2008-06-18 01:13:48 +000029end
30
Kevin Clarkca8a1b32008-06-18 01:17:06 +000031desc 'Compile the .thrift files for the specs'
Bryan Duxburyd815c212009-03-19 18:57:43 +000032task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
Kevin Clarkca8a1b32008-06-18 01:17:06 +000033
Kevin Clarkc06b0152008-06-24 01:05:57 +000034namespace :'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 Clarkca8a1b32008-06-18 01:17:06 +000039
Kevin Clarkc06b0152008-06-24 01:05:57 +000040 task :'benchmark' do
41 dir = File.dirname(__FILE__) + '/benchmark'
42 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
43 end
Bryan Duxburyd815c212009-03-19 18:57:43 +000044
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 Clarkca8a1b32008-06-18 01:17:06 +000049end
50
51desc 'Run benchmarking of NonblockingServer'
52task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000053 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000054end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000055
56
57begin
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 Clark4bd89162008-07-08 00:47:49 +000067
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 Clark3a9ffbd2008-06-24 01:06:00 +000076rescue LoadError
Kevin Clark33871152008-06-26 18:14:25 +000077 [: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 Clark3a9ffbd2008-06-24 01:06:00 +000083end