]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/rb/Rakefile
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / rb / Rakefile
CommitLineData
f67539c2
TL
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
20require 'rubygems'
21require 'rake'
22require 'rake/clean'
23require 'rspec/core/rake_task'
24
25THRIFT = '../../compiler/cpp/thrift'
26
27task :default => [:gem]
28task :spec => [:'gen-rb', :build_ext, :realspec]
29
30RSpec::Core::RakeTask.new(:realspec) do |t|
31 t.rspec_opts = ['--color', '--format d']
32end
33
34RSpec::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/']
38end
39
40desc 'Compile the .thrift files for the specs'
41task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:namespaced_spec', :'gen-rb:flat_spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
42namespace :'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
70end
71
72desc "Build the native library"
73task :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
85end
86
87desc 'Run the compiler tests (requires full thrift checkout)'
88task :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"
93end
94
95desc 'Run benchmarking of NonblockingServer'
96task :benchmark do
97 ruby 'benchmark/benchmark.rb'
98end
99
100desc 'Builds the thrift gem'
101task :gem => [:spec, :build_ext] do
102 unless sh 'gem', 'build', 'thrift.gemspec'
103 $stderr.puts "Failed to build thrift gem"
104 break
105 end
106end
107
108desc 'Install the thrift gem'
109task :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
114end
115
116CLEAN.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]