blob: 9500db10044405c5c2690d8a50f748e2066d4104 [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'
22require 'spec/rake/spectask'
23
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
30Spec::Rake::SpecTask.new(:realspec) do |t|
Kevin Clark5a7103a2008-06-18 00:55:11 +000031 t.spec_files = FileList['spec/**/*_spec.rb']
32 t.spec_opts = ['--color']
33end
Kevin Clarkc2a07b12008-06-18 00:57:06 +000034
Kevin Clarkc06b0152008-06-24 01:05:57 +000035Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
Kevin Clarkeb0dd7f2008-06-18 01:12:15 +000036 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
Kevin Clarkc06b0152008-06-24 01:05:57 +000042desc 'Run the compiler tests (requires full thrift checkout)'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000043task :test do
Kevin Clarkc06b0152008-06-24 01:05:57 +000044 # 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"
Kevin Clark4bd89162008-07-08 00:47:49 +000047 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
Kevin Clarka7613dd2008-06-18 01:13:48 +000048end
49
Kevin Clarkca8a1b32008-06-18 01:17:06 +000050desc 'Compile the .thrift files for the specs'
Bryan Duxburyd815c212009-03-19 18:57:43 +000051task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
Kevin Clarkca8a1b32008-06-18 01:17:06 +000052
Kevin Clarkc06b0152008-06-24 01:05:57 +000053namespace :'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
Kevin Clarkca8a1b32008-06-18 01:17:06 +000058
Kevin Clarkc06b0152008-06-24 01:05:57 +000059 task :'benchmark' do
60 dir = File.dirname(__FILE__) + '/benchmark'
61 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
62 end
Bryan Duxburyd815c212009-03-19 18:57:43 +000063
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
Kevin Clarkca8a1b32008-06-18 01:17:06 +000068end
69
70desc 'Run benchmarking of NonblockingServer'
71task :benchmark do
Kevin Clarkd3cee022008-06-18 01:19:09 +000072 ruby 'benchmark/benchmark.rb'
Kevin Clarkc2a07b12008-06-18 00:57:06 +000073end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000074
75
76begin
77 require 'echoe'
78
79 Echoe.new('thrift') do |p|
Roger Meier22872782010-10-22 11:20:25 +000080 p.author = ['Thrift Developers']
Roger Meiera8b52c72010-11-02 07:33:30 +000081 p.email = ['dev@thrift.apache.org']
Roger Meier22872782010-10-22 11:20:25 +000082 p.summary = "Ruby bindings for the Apache Thrift RPC system"
Roger Meiera8b52c72010-11-02 07:33:30 +000083 p.url = "http://thrift.apache.org"
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000084 p.include_rakefile = true
Jake Farrell9c762582011-08-13 21:29:36 +000085 p.version = "0.8.0-dev"
Bryan Duxbury05528132009-07-30 15:52:25 +000086 p.rubygems_version = ">= 1.2.0"
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000087 end
Kevin Clark4bd89162008-07-08 00:47:49 +000088
89 task :install => [:check_site_lib]
90
91 require 'rbconfig'
92 task :check_site_lib do
93 if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
94 fail "thrift is already installed in site_ruby"
95 end
96 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +000097rescue LoadError
Kevin Clark33871152008-06-26 18:14:25 +000098 [:install, :package].each do |t|
99 desc "Stub for #{t}"
100 task t do
101 fail "The Echoe gem is required for this task"
102 end
103 end
Kevin Clark3a9ffbd2008-06-24 01:06:00 +0000104end