]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/rb/Rakefile
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / rb / Rakefile
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
20 require 'rubygems'
21 require 'rake'
22 require 'rake/clean'
23 require 'rspec/core/rake_task'
24
25 THRIFT = '../../compiler/cpp/thrift'
26
27 task :default => [:gem]
28 task :spec => [:'gen-rb', :build_ext, :realspec]
29
30 RSpec::Core::RakeTask.new(:realspec) do |t|
31 t.rspec_opts = ['--color', '--format d']
32 end
33
34 RSpec::Core::RakeTask.new(:'spec:rcov') do |t|
35 t.rspec_opts = ['--color', '--format d']
36 t.rcov = true
37 t.rcov_opts = ['--exclude', '^spec,/gems/']
38 end
39
40 desc 'Compile the .thrift files for the specs'
41 task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:namespaced_spec', :'gen-rb:flat_spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
42 namespace :'gen-rb' do
43 task :'spec' do
44 dir = File.dirname(__FILE__) + '/spec'
45 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/ThriftSpec.thrift"
46 end
47
48 task :'namespaced_spec' do
49 dir = File.dirname(__FILE__) + '/spec'
50 sh THRIFT, '--gen', 'rb:namespaced', '--recurse', '-o', dir, "#{dir}/ThriftNamespacedSpec.thrift"
51 sh THRIFT, '--gen', 'rb:namespaced', '--recurse', '-o', dir, "#{dir}/BaseService.thrift"
52 sh THRIFT, '--gen', 'rb:namespaced', '--recurse', '-o', dir, "#{dir}/ExtendedService.thrift"
53 end
54
55 task :'flat_spec' do
56 dir = File.dirname(__FILE__) + '/spec'
57 mkdir_p("#{dir}/gen-rb/flat")
58 sh THRIFT, '--gen', 'rb', '--recurse', '-out', "#{dir}/gen-rb/flat", "#{dir}/ThriftNamespacedSpec.thrift"
59 end
60
61 task :'benchmark' do
62 dir = File.dirname(__FILE__) + '/benchmark'
63 sh THRIFT, '--gen', 'rb', '-o', dir, "#{dir}/Benchmark.thrift"
64 end
65
66 task :'debug_proto' do
67 sh "mkdir", "-p", "test/debug_proto"
68 sh THRIFT, '--gen', 'rb', "-o", "test/debug_proto", "../../test/DebugProtoTest.thrift"
69 end
70 end
71
72 desc "Build the native library"
73 task :build_ext => :'gen-rb' do
74 next if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
75 Dir::chdir(File::dirname('ext/extconf.rb')) do
76 unless sh "ruby #{File::basename('ext/extconf.rb')}"
77 $stderr.puts "Failed to run extconf"
78 break
79 end
80 unless sh "make"
81 $stderr.puts "make failed"
82 break
83 end
84 end
85 end
86
87 desc 'Run the compiler tests (requires full thrift checkout)'
88 task :test do
89 # ensure this is a full thrift checkout and not a tarball of the ruby libs
90 cmd = 'head -1 ../../README.md 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
91 system(cmd) or fail "rake test requires a full thrift checkout"
92 sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
93 end
94
95 desc 'Run benchmarking of NonblockingServer'
96 task :benchmark do
97 ruby 'benchmark/benchmark.rb'
98 end
99
100 desc 'Builds the thrift gem'
101 task :gem => [:spec, :build_ext] do
102 unless sh 'gem', 'build', 'thrift.gemspec'
103 $stderr.puts "Failed to build thrift gem"
104 break
105 end
106 end
107
108 desc 'Install the thrift gem'
109 task :install => [:gem] do
110 unless sh 'gem', 'install', Dir.glob('thrift-*.gem').last
111 $stderr.puts "Failed to install thrift gem"
112 break
113 end
114 end
115
116 CLEAN.include [
117 '.bundle', 'benchmark/gen-rb', 'coverage', 'ext/*.{o,bundle,so,dll}', 'ext/mkmf.log',
118 'ext/Makefile', 'ext/conftest.dSYM', 'Gemfile.lock', 'mkmf.log', 'pkg', 'spec/gen-rb',
119 'test', 'thrift-*.gem'
120 ]