David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | # |
| 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 Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 20 | require 'rubygems' |
| 21 | require 'rake' |
Jake Farrell | 74362e0 | 2011-08-16 17:13:41 +0000 | [diff] [blame] | 22 | require 'rspec/core/rake_task' |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 23 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 24 | THRIFT = '../../compiler/cpp/thrift' |
| 25 | |
Bryan Duxbury | f0377e2 | 2009-03-30 17:14:06 +0000 | [diff] [blame] | 26 | task :default => [:spec] |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 27 | |
Bryan Duxbury | f0377e2 | 2009-03-30 17:14:06 +0000 | [diff] [blame] | 28 | task :spec => [:'gen-rb', :realspec] |
| 29 | |
Jake Farrell | 74362e0 | 2011-08-16 17:13:41 +0000 | [diff] [blame] | 30 | RSpec::Core::RakeTask.new(:realspec) do |t| |
| 31 | t.rspec_opts = ['--color'] |
Kevin Clark | 5a7103a | 2008-06-18 00:55:11 +0000 | [diff] [blame] | 32 | end |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 33 | |
Jake Farrell | 74362e0 | 2011-08-16 17:13:41 +0000 | [diff] [blame] | 34 | RSpec::Core::RakeTask.new(:'spec:rcov') do |t| |
| 35 | t.rspec_opts = ['--color'] |
Kevin Clark | eb0dd7f | 2008-06-18 01:12:15 +0000 | [diff] [blame] | 36 | t.rcov = true |
| 37 | t.rcov_opts = ['--exclude', '^spec,/gems/'] |
| 38 | end |
| 39 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 40 | desc 'Run the compiler tests (requires full thrift checkout)' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 41 | task :test do |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 42 | # 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 Clark | 4bd8916 | 2008-07-08 00:47:49 +0000 | [diff] [blame] | 45 | sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check" |
Kevin Clark | a7613dd | 2008-06-18 01:13:48 +0000 | [diff] [blame] | 46 | end |
| 47 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 48 | desc 'Compile the .thrift files for the specs' |
Bryan Duxbury | d815c21 | 2009-03-19 18:57:43 +0000 | [diff] [blame] | 49 | task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto'] |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 50 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 51 | namespace :'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 Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 56 | |
Kevin Clark | c06b015 | 2008-06-24 01:05:57 +0000 | [diff] [blame] | 57 | task :'benchmark' do |
| 58 | dir = File.dirname(__FILE__) + '/benchmark' |
| 59 | sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift" |
| 60 | end |
Bryan Duxbury | d815c21 | 2009-03-19 18:57:43 +0000 | [diff] [blame] | 61 | |
| 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 Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 66 | end |
| 67 | |
| 68 | desc 'Run benchmarking of NonblockingServer' |
| 69 | task :benchmark do |
Kevin Clark | d3cee02 | 2008-06-18 01:19:09 +0000 | [diff] [blame] | 70 | ruby 'benchmark/benchmark.rb' |
Kevin Clark | c2a07b1 | 2008-06-18 00:57:06 +0000 | [diff] [blame] | 71 | end |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 72 | |
| 73 | |
| 74 | begin |
| 75 | require 'echoe' |
| 76 | |
| 77 | Echoe.new('thrift') do |p| |
Roger Meier | 2287278 | 2010-10-22 11:20:25 +0000 | [diff] [blame] | 78 | p.author = ['Thrift Developers'] |
Roger Meier | a8b52c7 | 2010-11-02 07:33:30 +0000 | [diff] [blame] | 79 | p.email = ['dev@thrift.apache.org'] |
Roger Meier | 2287278 | 2010-10-22 11:20:25 +0000 | [diff] [blame] | 80 | p.summary = "Ruby bindings for the Apache Thrift RPC system" |
Roger Meier | a8b52c7 | 2010-11-02 07:33:30 +0000 | [diff] [blame] | 81 | p.url = "http://thrift.apache.org" |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 82 | p.include_rakefile = true |
Jake Farrell | 9c76258 | 2011-08-13 21:29:36 +0000 | [diff] [blame] | 83 | p.version = "0.8.0-dev" |
Bryan Duxbury | 0552813 | 2009-07-30 15:52:25 +0000 | [diff] [blame] | 84 | p.rubygems_version = ">= 1.2.0" |
Kevin Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 85 | end |
Kevin Clark | 4bd8916 | 2008-07-08 00:47:49 +0000 | [diff] [blame] | 86 | |
| 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 Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 95 | rescue LoadError |
Kevin Clark | 3387115 | 2008-06-26 18:14:25 +0000 | [diff] [blame] | 96 | [: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 Clark | 3a9ffbd | 2008-06-24 01:06:00 +0000 | [diff] [blame] | 102 | end |
Jake Farrell | 74362e0 | 2011-08-16 17:13:41 +0000 | [diff] [blame] | 103 | |