Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use rake-compiler

  • Loading branch information...
commit fd518a2d4fd7fb16b482241882a3635e1b4aafc8 1 parent 6e1c4ac
@lest lest authored
Showing with 10 additions and 22 deletions.
  1. +1 −0  Gemfile
  2. +7 −16 Rakefile
  3. +2 −6 ext/cityhash/extconf.rb
View
1  Gemfile
@@ -3,4 +3,5 @@ source "http://rubygems.org"
gemspec
gem 'rake'
+gem 'rake-compiler'
gem 'minitest', '~> 2.11.0'
View
23 Rakefile
@@ -3,22 +3,6 @@ require "bundler/gem_tasks"
require 'rake/testtask'
require 'rake/clean'
-NAME = 'cityhash'
-
-file "lib/#{NAME}/#{NAME}.so" => Dir.glob("ext/#{NAME}") do
- Dir.chdir("ext/#{NAME}") do
- ruby "extconf.rb"
- sh "make"
- end
- cp "ext/#{NAME}/#{NAME}.so", "lib/#{NAME}"
-end
-
-task :test => "lib/#{NAME}/#{NAME}.so"
-
-CLEAN.include('ext/**/*{.o,.log,.so}')
-CLEAN.include('ext/**/Makefile')
-CLOBBER.include('lib/**/*.so')
-
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/*_test.rb'
@@ -27,3 +11,10 @@ end
desc "Run tests"
task :default => :test
+
+require 'rake/extensiontask'
+Rake::ExtensionTask.new('cityhash') do |ext|
+ ext.lib_dir = 'lib/cityhash'
+end
+
+Rake::Task[:test].prerequisites << :compile
View
8 ext/cityhash/extconf.rb
@@ -1,12 +1,8 @@
require 'mkmf'
-have_library('objc') if RUBY_PLATFORM =~ /darwin/
-
-%w{g O3 Wall rdynamic}.each do |flag|
+%w{g O3 Wall}.each do |flag|
flag = "-#{flag}"
$CPPFLAGS += " #{flag}" unless $CPPFLAGS.split.include? flag
end
-CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/
-
-create_makefile('cityhash')
+create_makefile('cityhash/cityhash')
Please sign in to comment.
Something went wrong with that request. Please try again.