Skip to content

Commit

Permalink
+ changed installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jul 18, 2012
1 parent ec02c16 commit fb04c8a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
11 changes: 8 additions & 3 deletions server/lib/picky/ext/maybe_compile.rb
@@ -1,15 +1,17 @@
failed = 0

begin
require_relative 'ruby19/performant'
rescue LoadError
require File.expand_path '../ruby19/performant', __FILE__
rescue LoadError => e
failed += 1

require File.expand_path '../ruby19/extconf', __FILE__

# For some reason we need to enter ./ruby19
# via external command (see issue #81).
#
Dir.chdir File.expand_path('..', __FILE__) do
puts %x(cd ruby19; ruby extconf.rb; make)
puts %x(cd ruby19; make)
end

# Try again.
Expand All @@ -26,6 +28,9 @@
See related issue: https://github.com/floere/picky/issues/81
The problem reported by the compiler was:
#{e}
NOTE
exit 1
end
31 changes: 16 additions & 15 deletions server/lib/picky/ext/ruby19/extconf.rb
@@ -1,17 +1,18 @@
# Information.
#
print "Compiling on Ruby 1.9"
if defined?(RbConfig)
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
print " with CC set to #{RbConfig::MAKEFILE_CONFIG['CC']}"
end
puts "."
Dir.chdir File.expand_path('..', __FILE__) do
# Information.
#
print "Compiling on Ruby 1.9"
if defined?(RbConfig)
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
print " with CC set to #{RbConfig::MAKEFILE_CONFIG['CC']}"
end
puts " into #{Dir.pwd}."

# Compile.
#
require 'mkmf'
# Compile.
#
require 'mkmf'

abort 'need ruby.h' unless have_header("ruby.h")

dir_config('performant')
create_makefile('performant')
abort 'need ruby.h' unless have_header("ruby.h")
create_makefile('picky/ext/ruby19/performant')
end
4 changes: 2 additions & 2 deletions server/lib/picky/ext/ruby19/performant.c
Expand Up @@ -37,7 +37,7 @@ inline VALUE rb_ary_length(VALUE ary) {
// * orders the arrays by ascending size, small to large.
// * calls the & consecutively for all arrays.
//
inline VALUE _memory_efficient_intersect(VALUE self, VALUE unsorted_array_of_arrays) {
inline VALUE memory_efficient_intersect(VALUE self, VALUE unsorted_array_of_arrays) {
// Counters.
//
long i, j;
Expand Down Expand Up @@ -94,5 +94,5 @@ VALUE p_mPerformant, p_cArray;
void Init_performant() {
p_mPerformant = rb_define_module("Performant");
p_cArray = rb_define_class_under(p_mPerformant, "Array", rb_cObject);
rb_define_singleton_method(p_cArray, "memory_efficient_intersect", _memory_efficient_intersect, 1);
rb_define_singleton_method(p_cArray, "memory_efficient_intersect", memory_efficient_intersect, 1);
}

0 comments on commit fb04c8a

Please sign in to comment.