You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2011/08/30 21:12:11 UTC
svn commit: r1163341 - in /thrift/trunk: configure.ac lib/rb/Gemfile
lib/rb/Makefile.am lib/rb/Manifest lib/rb/Rakefile lib/rb/setup.rb
lib/rb/spec/spec_helper.rb lib/rb/thrift.gemspec
Author: jfarrell
Date: Tue Aug 30 19:12:10 2011
New Revision: 1163341
URL: http://svn.apache.org/viewvc?rev=1163341&view=rev
Log:
Thrift-1286: Modernize the Thrift Ruby Library Dev Environment
Client: Ruby
Patch: jfarrell
Updates to ruby build process with the following changes:
- Removes dependency on echoe for spec generation
- Adds gemfile for bulider and uses thrift.gemspec for dependency management.
- Adds checks in configure for builder and only calls if available (make check-local on ci servers)
- Adds checks in configure for Ruby and rake (bundler as well but this is optional for check-local and auto dependency management)
- Still allows for rake to do its thing if all dependencies are in place
- Removed Manifest and setup.rb
- Adds a install task which will generate a gem and then install that gem to locally configured ruby path (no more prefix or destdir with this client)
Added:
thrift/trunk/lib/rb/Gemfile
thrift/trunk/lib/rb/thrift.gemspec
Modified:
thrift/trunk/configure.ac
thrift/trunk/lib/rb/Makefile.am
thrift/trunk/lib/rb/Manifest
thrift/trunk/lib/rb/Rakefile
thrift/trunk/lib/rb/setup.rb
thrift/trunk/lib/rb/spec/spec_helper.rb
Modified: thrift/trunk/configure.ac
URL: http://svn.apache.org/viewvc/thrift/trunk/configure.ac?rev=1163341&r1=1163340&r2=1163341&view=diff
==============================================================================
--- thrift/trunk/configure.ac (original)
+++ thrift/trunk/configure.ac Tue Aug 30 19:12:10 2011
@@ -220,13 +220,14 @@ AX_THRIFT_LIB(ruby, [Ruby], yes)
have_ruby=no
if test "$with_ruby" = "yes"; then
AC_PATH_PROG([RUBY], [ruby])
- AC_PATH_PROG([RSPEC], [spec])
- if test "x$RUBY" != "x" ; then
+ AC_PATH_PROG([RAKE], [rake])
+ AC_PATH_PROG([BUNDLER], [bundle])
+ if test "x$RUBY" != "x" -a "x$RAKE" != "x"; then
have_ruby="yes"
fi
fi
AM_CONDITIONAL(WITH_RUBY, [test "$have_ruby" = "yes"])
-AM_CONDITIONAL(HAVE_RSPEC, [test "x$RSPEC" != "x"])
+AM_CONDITIONAL(HAVE_BUNDLER, [test "x$BUNDLER" != "x"])
AX_THRIFT_LIB(haskell, [Haskell], yes)
have_haskell=no
Added: thrift/trunk/lib/rb/Gemfile
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/Gemfile?rev=1163341&view=auto
==============================================================================
--- thrift/trunk/lib/rb/Gemfile (added)
+++ thrift/trunk/lib/rb/Gemfile Tue Aug 30 19:12:10 2011
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+gemspec
+
Modified: thrift/trunk/lib/rb/Makefile.am
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/Makefile.am?rev=1163341&r1=1163340&r2=1163341&view=diff
==============================================================================
--- thrift/trunk/lib/rb/Makefile.am (original)
+++ thrift/trunk/lib/rb/Makefile.am Tue Aug 30 19:12:10 2011
@@ -20,8 +20,8 @@
EXTRA_DIST = \
CHANGELOG \
Rakefile \
- Manifest \
- setup.rb \
+ Gemfile \
+ thrift.gemspec \
lib \
ext \
benchmark \
@@ -31,19 +31,17 @@ EXTRA_DIST = \
DESTDIR ?= /
all-local:
- if [ -n "$(RUBY_PREFIX)" ] ; then $(RUBY) setup.rb config --prefix=$(DESTDIR)$(RUBY_PREFIX) --rbdir='$$libdir/ruby' --sodir='$$libdir/ruby' ; elif [ -n "$(DESTDIR)" ] ; then $(RUBY) setup.rb config --prefix=$(DESTDIR) ; else $(RUBY) setup.rb config ; fi
- $(RUBY) setup.rb setup
+ $(RAKE) build_ext
install-exec-hook:
- $(RUBY) setup.rb install --prefix=$(DESTDIR)
+ $(RAKE) install
-# Make sure this doesn't fail if Ruby is not configured.
clean-local:
- RUBY=$(RUBY) ; if test -z "$$RUBY" ; then RUBY=: ; fi ; \
- $$RUBY setup.rb clean
+ $(RAKE) clean
check-local: all
-if HAVE_RSPEC
- rake spec
+if HAVE_BUNDLER
+ $(BUNDLER) install
+ $(BUNDLER) exec rake
endif
Modified: thrift/trunk/lib/rb/Rakefile
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/Rakefile?rev=1163341&r1=1163340&r2=1163341&view=diff
==============================================================================
--- thrift/trunk/lib/rb/Rakefile (original)
+++ thrift/trunk/lib/rb/Rakefile Tue Aug 30 19:12:10 2011
@@ -19,35 +19,28 @@
require 'rubygems'
require 'rake'
-require 'rspec/core/rake_task'
+require 'rake/clean'
+require 'spec/rake/spectask'
THRIFT = '../../compiler/cpp/thrift'
task :default => [:spec]
-
task :spec => [:'gen-rb', :realspec]
-RSpec::Core::RakeTask.new(:realspec) do |t|
- t.rspec_opts = ['--color']
+Spec::Rake::SpecTask.new(:realspec) do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = ['--color']
end
-RSpec::Core::RakeTask.new(:'spec:rcov') do |t|
- t.rspec_opts = ['--color']
+Spec::Rake::SpecTask.new(:'spec:rcov') do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = ['--color']
t.rcov = true
t.rcov_opts = ['--exclude', '^spec,/gems/']
end
-desc 'Run the compiler tests (requires full thrift checkout)'
-task :test do
- # ensure this is a full thrift checkout and not a tarball of the ruby libs
- cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
- system(cmd) or fail "rake test requires a full thrift checkout"
- sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
-end
-
desc 'Compile the .thrift files for the specs'
task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:benchmark', :'gen-rb:debug_proto']
-
namespace :'gen-rb' do
task :'spec' do
dir = File.dirname(__FILE__) + '/spec'
@@ -60,44 +53,52 @@ namespace :'gen-rb' do
end
task :'debug_proto' do
- sh "mkdir", "-p", "debug_proto_test"
- sh THRIFT, '--gen', 'rb', "-o", "debug_proto_test", "../../test/DebugProtoTest.thrift"
+ sh "mkdir", "-p", "test/debug_proto"
+ sh THRIFT, '--gen', 'rb', "-o", "test/debug_proto", "../../test/DebugProtoTest.thrift"
end
end
+desc "Build the native library"
+task :build_ext => :spec do
+ Dir::chdir(File::dirname('ext/extconf.rb')) do
+ unless sh "ruby #{File::basename('ext/extconf.rb')}"
+ $stderr.puts "Failed to run extconf"
+ break
+ end
+ unless sh "make"
+ $stderr.puts "make failed"
+ break
+ end
+ end
+end
+
+desc 'Run the compiler tests (requires full thrift checkout)'
+task :test do
+ # ensure this is a full thrift checkout and not a tarball of the ruby libs
+ cmd = 'head -1 ../../README 2>/dev/null | grep Thrift >/dev/null 2>/dev/null'
+ system(cmd) or fail "rake test requires a full thrift checkout"
+ sh 'make', '-C', File.dirname(__FILE__) + "/../../test/rb", "check"
+end
+
desc 'Run benchmarking of NonblockingServer'
task :benchmark do
ruby 'benchmark/benchmark.rb'
end
-
-begin
- require 'echoe'
-
- Echoe.new('thrift') do |p|
- p.author = ['Thrift Developers']
- p.email = ['dev@thrift.apache.org']
- p.summary = "Ruby bindings for the Apache Thrift RPC system"
- p.url = "http://thrift.apache.org"
- p.include_rakefile = true
- p.version = "0.8.0-dev"
- p.rubygems_version = ">= 1.2.0"
- end
-
- task :install => [:check_site_lib]
-
- require 'rbconfig'
- task :check_site_lib do
- if File.exist?(File.join(Config::CONFIG['sitelibdir'], 'thrift.rb'))
- fail "thrift is already installed in site_ruby"
- end
- end
-rescue LoadError
- [:install, :package].each do |t|
- desc "Stub for #{t}"
- task t do
- fail "The Echoe gem is required for this task"
- end
+desc 'Generate and install the thrift gem'
+task :install => [:spec, :build_ext] do
+ unless sh 'gem', 'build', 'thrift.gemspec'
+ $stderr.puts "Failed to build thrift gem"
+ break
+ end
+ unless sh 'gem', 'install', 'thrift-*.gem'
+ $stderr.puts "Failed to install thrift gem"
+ break
end
end
+CLEAN.include [ 'ext/*.{o,bundle,so,dll}', 'mkmf.log', 'ext/mkmf.log', 'ext/Makefile',
+ 'Gemfile.lock', '.bundle',
+ 'spec/gen-rb', 'test', 'benchmark/gen-rb',
+ 'pkg', 'thrift-*.gem'
+]
Modified: thrift/trunk/lib/rb/spec/spec_helper.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/spec_helper.rb?rev=1163341&r1=1163340&r2=1163341&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/spec_helper.rb (original)
+++ thrift/trunk/lib/rb/spec/spec_helper.rb Tue Aug 30 19:12:10 2011
@@ -42,7 +42,7 @@ Spec::Runner.configure do |configuration
end
end
-$:.unshift File.join(File.dirname(__FILE__), *%w[.. debug_proto_test gen-rb])
+$:.unshift File.join(File.dirname(__FILE__), *%w[.. test debug_proto gen-rb])
require "srv"
require "debug_proto_test_constants"
Added: thrift/trunk/lib/rb/thrift.gemspec
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/thrift.gemspec?rev=1163341&view=auto
==============================================================================
--- thrift/trunk/lib/rb/thrift.gemspec (added)
+++ thrift/trunk/lib/rb/thrift.gemspec Tue Aug 30 19:12:10 2011
@@ -0,0 +1,34 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = 'thrift'
+ s.version = '0.8.0dev'
+ s.authors = ['Thrift Developers']
+ s.email = ['dev@thrift.apache.org']
+ s.homepage = 'http://thrift.apache.org'
+ s.summary = %q{Ruby bindings for Apache Thrift}
+ s.description = %q{Ruby bindings for the Apache Thrift RPC system}
+ s.license = 'Apache 2.0'
+ s.extensions = ['ext/extconf.rb']
+
+ s.has_rdoc = true
+ s.rdoc_options = %w[--line-numbers --inline-source --title Thrift --main README]
+
+ s.rubyforge_project = 'thrift'
+
+ dir = File.expand_path(File.dirname(__FILE__))
+
+ s.files = Dir.glob("{lib,spec}/**/*")
+ s.test_files = Dir.glob("{test,spec,benchmark}/**/*")
+ s.executables = Dir.glob("{bin}/**/*")
+
+ s.extra_rdoc_files = %w[CHANGELOG README] + Dir.glob("{ext,lib}/**/*.{c,h,rb}")
+
+ s.require_paths = %w[lib ext]
+
+ s.add_development_dependency "rake"
+ s.add_development_dependency "rspec", "1.3.2"
+ s.add_development_dependency "mongrel"
+end
+