mirror of https://github.com/reiseburo/hermann
Restructure the Hermann gem extension build process to use rake-compiler
This is a little bit better and cleaner IMO than the hand-crafted rake tasks. Would you like to know more? <https://github.com/luislavena/rake-compiler>
This commit is contained in:
parent
9a24317c7f
commit
e241f086ee
|
@ -1,7 +1,9 @@
|
|||
hermann.iml
|
||||
.ruby-*
|
||||
ext/*.so
|
||||
ext/*.o
|
||||
*.so
|
||||
*.o
|
||||
ext/mkmf.log
|
||||
*.sw*
|
||||
ext/Makefile
|
||||
pkg/
|
||||
tmp/
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -2,6 +2,7 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem 'rake'
|
||||
gem 'rake-compiler'
|
||||
|
||||
group :test do
|
||||
gem 'rspec', '~> 3.0.0'
|
||||
|
|
|
@ -3,6 +3,8 @@ GEM
|
|||
specs:
|
||||
diff-lcs (1.2.5)
|
||||
rake (10.3.2)
|
||||
rake-compiler (0.9.3)
|
||||
rake
|
||||
rspec (3.0.0)
|
||||
rspec-core (~> 3.0.0)
|
||||
rspec-expectations (~> 3.0.0)
|
||||
|
@ -24,5 +26,6 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
rake
|
||||
rake-compiler
|
||||
rspec (~> 3.0.0)
|
||||
rspec-its
|
||||
|
|
38
Rakefile
38
Rakefile
|
@ -1,37 +1,17 @@
|
|||
|
||||
require 'rubygems'
|
||||
require 'rake/clean'
|
||||
require "bundler/gem_tasks"
|
||||
require 'rspec/core/rake_task'
|
||||
require 'rake/extensiontask'
|
||||
|
||||
EXT_CONF = "ext/extconf.rb"
|
||||
MAKEFILE = 'ext/Makefile'
|
||||
MODULE = 'ext/hermann_lib.so'
|
||||
SRC = Dir.glob('ext/*.c')
|
||||
SRC << MAKEFILE
|
||||
|
||||
CLEAN.include [ 'ext/*.o', 'ext/depend', 'ext/hermann_lib.bundle', MODULE ]
|
||||
CLOBBER.include [ 'config.save', 'ext/mkmf.log', 'ext/hermann_lib.bundle', MAKEFILE ]
|
||||
|
||||
file MAKEFILE => EXT_CONF do |t|
|
||||
Dir::chdir(File::dirname(EXT_CONF)) do
|
||||
unless sh "ruby #{File::basename(EXT_CONF)}"
|
||||
$stderr.puts "Failed to run extconf"
|
||||
break
|
||||
end
|
||||
end
|
||||
Rake::ExtensionTask.new do |t|
|
||||
t.name = 'hermann_lib'
|
||||
t.ext_dir = 'ext/hermann'
|
||||
t.gem_spec = Gem::Specification.load('hermann.gemspec')
|
||||
end
|
||||
|
||||
file MODULE => SRC do |t|
|
||||
Dir::chdir(File::dirname(EXT_CONF)) do
|
||||
unless sh "make"
|
||||
$stderr.puts "make failed"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build the native library"
|
||||
task :build => MODULE
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
task :default => [:clean, :build, :spec]
|
||||
task :build => [:compile]
|
||||
task :default => [:compile, :spec]
|
||||
|
||||
|
|
|
@ -12,15 +12,17 @@ puts "Include Dir: #{INCLUDEDIR}"
|
|||
|
||||
HEADER_DIRS = [INCLUDEDIR]
|
||||
|
||||
LIB_DIRS = [LIBDIR]
|
||||
LIB_DIRS = [LIBDIR, './librdkafka']
|
||||
|
||||
dir_config('rdkafka', HEADER_DIRS, LIB_DIRS)
|
||||
|
||||
unless find_header('librdkafka/rdkafka.h')
|
||||
ROOTDIR = File.expand_path(File.dirname(__FILE__) + '/../../')
|
||||
RDK = File.join(ROOTDIR, 'librdkafka/target')
|
||||
unless find_header('librdkafka/rdkafka.h', File.join(RDK, 'include'))
|
||||
abort "librdkafka not installed"
|
||||
end
|
||||
|
||||
unless find_library('rdkafka', 'rd_kafka_conf_new')
|
||||
unless find_library('rdkafka', 'rd_kafka_conf_new', File.join(RDK, 'lib'))
|
||||
abort "librdkafka not installed"
|
||||
end
|
||||
|
|
@ -9,15 +9,19 @@ SPEC = Gem::Specification.new do |s|
|
|||
|
||||
s.authors = ["Stan Campbell", 'R. Tyler Croy']
|
||||
s.description = 'Ruby gem wrapper for librdkafka'
|
||||
s.email = ['stan.campbell3@gmail.com', 'rtyler.croy@lookout.com']
|
||||
s.files = [ "Rakefile", "ext/hermann_lib.h", "ext/hermann_lib.c", "ext/extconf.rb"]
|
||||
s.files += `git ls-files -- lib`.split($\)
|
||||
s.extensions = [ "ext/extconf.rb"]
|
||||
s.homepage = 'https://github.com/lookout/Hermann'
|
||||
s.require_paths = ["lib", "ext"]
|
||||
s.rubygems_version = '2.2.2'
|
||||
s.summary = 'A Kafka consumer/producer gem based on the librdkafka C library.'
|
||||
s.email = ['stan.campbell3@gmail.com', 'rtyler.croy@lookout.com']
|
||||
s.homepage = 'https://github.com/lookout/Hermann'
|
||||
s.licenses = ['MIT']
|
||||
|
||||
s.files = [ "Rakefile"]
|
||||
s.files += `git ls-files -- lib`.split($\)
|
||||
s.files += `git ls-files -- ext`.split($\)
|
||||
|
||||
s.extensions = Dir['ext/**/extconf.rb']
|
||||
|
||||
s.require_paths = ["lib", "ext/hermann"]
|
||||
s.rubygems_version = '2.2.2'
|
||||
|
||||
s.specification_version = 3 if s.respond_to?(:specification_version)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue