Skip to content

Commit

Permalink
Corrected fat-binary support. Closes GH-6
Browse files Browse the repository at this point in the history
- Namespace mysql_api component into mysql library path
- Try search for {1.8, 1.9}/mysql_api inside mysql lib before directly
- Removed RUBY_PLATFORM conditional.
  • Loading branch information
luislavena committed May 25, 2010
1 parent 209a9ef commit a06fc96
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ext/mysql_api/extconf.rb
Expand Up @@ -90,4 +90,4 @@ def default_mysql_config_path
end
end

create_makefile("mysql_api")
create_makefile("mysql/mysql_api")
8 changes: 3 additions & 5 deletions lib/mysql.rb
@@ -1,11 +1,9 @@
# support multiple ruby version (fat binaries under windows)
begin
require 'mysql_api'
RUBY_VERSION =~ /(\d+.\d+)/
require "mysql/#{$1}/mysql_api"
rescue LoadError
if RUBY_PLATFORM =~ /mingw|mswin/ then
RUBY_VERSION =~ /(\d+.\d+)/
require "#{$1}/mysql_api"
end
require 'mysql/mysql_api'
end

require 'mysql/version'
5 changes: 4 additions & 1 deletion tasks/native.rake
Expand Up @@ -8,10 +8,13 @@ Rake::ExtensionTask.new('mysql_api', HOE.spec) do |ext|
# reference where the vendored MySQL got extracted
mysql_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', "mysql-#{MYSQL_VERSION}-win32"))

# where native extension will be copied (matches makefile)
ext.lib_dir = "lib/mysql"

# define target for extension (supporting fat binaries)
if RUBY_PLATFORM =~ /mswin|mingw/ then
ruby_ver = RUBY_VERSION.match(/(\d+\.\d+)/)[1]
ext.lib_dir = "lib/#{ruby_ver}"
ext.lib_dir = "lib/mysql/#{ruby_ver}"
end

# automatically add build options to avoid need of manual input
Expand Down

0 comments on commit a06fc96

Please sign in to comment.