blob: 06189ebe0350bb65b5b1607e9f3e7b83cf7d2567 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +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
Kevin Clark5a7103a2008-06-18 00:55:11 +000020require 'rubygems'
21require 'rake'
Jake Farrell74362e02011-08-16 17:13:41 +000022require 'rspec/core/rake_task'
Kevin Clark5a7103a2008-06-18 00:55:11 +000023
Kevin Clarkc06b0152008-06-24 01:05:57 +000024THRIFT = '../../compiler/cpp/thrift'
25
Bryan Duxburyf0377e22009-03-30 17:14:06 +000026task :default => [:spec]
Kevin Clark5a7103a2008-06-18 00:55:11 +000027
Bryan Duxburyf0377e22009-03-30 17:14:06 +000028task :spec => [:'gen-rb', :realspec]
29
Jake Farrell74362e02011-08-16 17:13:41 +000030RSpec::Core::RakeTask.new(:realspec) do |t|
31 t.rspec_opts = ['--color']
Kevin Clark5a7103a2008-06-18 00:55:11 +000032end
Kevin Clarkc2a07b12008-06-18 00:57:06 +000033
Jake Farrell74362e02011-08-16 17:13:41 +000034RSpec::Core::RakeTask.new(:'spec:rcov') do |t|
35 t.rspec_opts = ['--color']
Kevin Clarkeb0dd7f2008-06-18 01:12:15 +000036 t.rcov = true
37 t.rcov_opts = ['--exclude', '^spec,/gems/']
38end
39
Kevin Clarkc06b0152008-06-24 01:05:57 +000040desc 'Run the compiler tests (requires full thrift checkout)'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000041task :test do
Kevin Clarkc06b0152008-06-24 01:05:57 +000042 # ensure this is a full thrift checkout and not a tarball of the ruby libs
43 cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
44 system(cmd) or fail "rake test requires a full thrift checkout"
Kevin Clark4bd89162008-07-08 00:47:49 +000045 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
Kevin Clarka7613dd2008-06-18 01:13:48 +000046end
47
Kevin Clarkca8a1b32008-06-18 01:17:06 +000048desc 'Compile the .thrift files for the specs'
Bryan Duxburyd815c212009-03-19 18:57:43 +000049task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
Kevin Clarkca8a1b32008-06-18 01:17:06 +000050
Kevin Clarkc06b0152008-06-24 01:05:57 +000051namespace :'gen-rb' do
52 task :'spec' do
53 dir = File.dirname(__FILE__) + '/spec'
54 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift"
55 end
Kevin Clarkca8a1b32008-06-18 01:17:06 +000056
Kevin Clarkc06b0152008-06-24 01:05:57 +000057 task :'benchmark' do
58 dir = File.dirname(__FILE__) + '/benchmark'
59 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
60 end
Bryan Duxburyd815c212009-03-19 18:57:43 +000061
62 task :'debug_proto' do
63 sh "mkdir", "-p", "debug_proto_test"
64 sh THRIFT, '--gen', 'rb', "-o", "debug_proto_test", "../../test/DebugProtoTest.thrift"
65 end
Kevin Clarkca8a1b32008-06-18 01:17:06 +000066end
67
68desc 'Run benchmarking of NonblockingServer'
69task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000070 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000071end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000072
73
74begin
75 require 'echoe'
76
77 Echoe.new('thrift') do |p|
Roger Meier22872782010-10-22 11:20:25 +000078 p.author = ['Thrift Developers']
Roger Meiera8b52c72010-11-02 07:33:30 +000079 p.email = ['dev@thrift.apache.org']
Roger Meier22872782010-10-22 11:20:25 +000080 p.summary = "Ruby bindings for the Apache Thrift RPC system"
Roger Meiera8b52c72010-11-02 07:33:30 +000081 p.url = "http://thrift.apache.org"
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000082 p.include_rakefile = true
Jake Farrell9c762582011-08-13 21:29:36 +000083 p.version = "0.8.0-dev"
Bryan Duxbury05528132009-07-30 15:52:25 +000084 p.rubygems_version = ">= 1.2.0"
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000085 end
Kevin Clark4bd89162008-07-08 00:47:49 +000086
87 task :install => [:check_site_lib]
88
89 require 'rbconfig'
90 task :check_site_lib do
91 if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
92 fail "thrift is already installed in site_ruby"
93 end
94 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000095rescue LoadError
Kevin Clark33871152008-06-26 18:14:25 +000096 [:install, :package].each do |t|
97 desc "Stub for #{t}"
98 task t do
99 fail "The Echoe gem is required for this task"
100 end
101 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +0000102end
Jake Farrell74362e02011-08-16 17:13:41 +0000103