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