blob: 1a9467a57778a0d92b04734a4760e14ee8988a64 [file] [log] [blame]
Gavin McDonald0b75e1a2010-10-28 02:12:01 +00001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20require 'rubygems'
21require 'rake'
22require 'spec/rake/spectask'
23
24THRIFT = '../../compiler/cpp/thrift'
25
26task :default => [:spec]
27
28task :spec => [:'gen-rb', :realspec]
29
30Spec::Rake::SpecTask.new(:realspec) do |t|
31 t.spec_files = FileList['spec/**/*_spec.rb']
32 t.spec_opts = ['--color']
33end
34
35Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
36 t.spec_files = FileList['spec/**/*_spec.rb']
37 t.spec_opts = ['--color']
38 t.rcov = true
39 t.rcov_opts = ['--exclude', '^spec,/gems/']
40end
41
42desc 'Run the compiler tests (requires full thrift checkout)'
43task :test do
44 # ensure this is a full thrift checkout and not a tarball of the ruby libs
45 cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
46 system(cmd) or fail "rake test requires a full thrift checkout"
47 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
48end
49
50desc 'Compile the .thrift files for the specs'
51task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
52
53namespace :'gen-rb' do
54 task :'spec' do
55 dir = File.dirname(__FILE__) + '/spec'
56 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift"
57 end
58
59 task :'benchmark' do
60 dir = File.dirname(__FILE__) + '/benchmark'
61 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
62 end
63
64 task :'debug_proto' do
65 sh "mkdir", "-p", "debug_proto_test"
66 sh THRIFT, '--gen', 'rb', "-o", "debug_proto_test", "../../test/DebugProtoTest.thrift"
67 end
68end
69
70desc 'Run benchmarking of NonblockingServer'
71task :benchmark do
72 ruby 'benchmark/benchmark.rb'
73end
74
75
76begin
77 require 'echoe'
78
79 Echoe.new('thrift') do |p|
80 p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee']
81 p.email = ['kevin@sb.org', 'kevin.clark@gmail.com', 'mcslee@facebook.com']
82 p.summary = "Ruby libraries for Thrift (a language-agnostic RPC system)"
83 p.url = "http://incubator.apache.org/thrift/"
84 p.include_rakefile = true
85 p.version = "0.1.0"
86 end
87
88 task :install => [:check_site_lib]
89
90 require 'rbconfig'
91 task :check_site_lib do
92 if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
93 fail "thrift is already installed in site_ruby"
94 end
95 end
96rescue LoadError
97 [:install, :package].each do |t|
98 desc "Stub for #{t}"
99 task t do
100 fail "The Echoe gem is required for this task"
101 end
102 end
103end