Skip to content

Commit 17a3dc3

Browse files
committed
Find dlltool from RbConfig and update rake-compiler for cross-compilation
1 parent 875a627 commit 17a3dc3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

ext/mysql2/extconf.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,24 @@ def asplode lib
104104
libfile = File.expand_path(File.join(rpath_dir, 'libmysql.lib'))
105105
file 'libmysql.a' => [deffile, libfile] do |t|
106106
when_writing 'building libmysql.a' do
107-
sh 'dlltool', '--kill-at',
107+
# Ruby kindly shows us where dllwrap is, but that tool does more than we want.
108+
# Maybe in the future Ruby could provide RbConfig::CONFIG['DLLTOOL'] directly.
109+
dlltool = RbConfig::CONFIG['DLLWRAP'].gsub('dllwrap', 'dlltool')
110+
sh dlltool, '--kill-at',
108111
'--dllname', 'libmysql.dll',
109112
'--output-lib', 'libmysql.a',
110113
'--input-def', deffile, libfile
111114
end
112115
end
113116

114117
Rake::Task['libmysql.a'].invoke
115-
116-
# Make sure the generated interface library works
117118
$LOCAL_LIBS << ' ' << 'libmysql.a'
118-
abort "-----\nCannot find libmysql.a\n----" unless have_library('libmysql')
119-
abort "-----\nCannot link to libmysql.a (my_init)\n----" unless have_func('my_init')
119+
120+
# Make sure the generated interface library works (if cross-compiling, trust without verifying)
121+
unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
122+
abort "-----\nCannot find libmysql.a\n----" unless have_library('libmysql')
123+
abort "-----\nCannot link to libmysql.a (my_init)\n----" unless have_func('my_init')
124+
end
120125

121126
# Vendor libmysql.dll
122127
vendordll = File.expand_path('../../../vendor/libmysql.dll', __FILE__)

mysql2.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
1515
s.test_files = `git ls-files spec examples`.split
1616

1717
# tests
18-
s.add_development_dependency 'rake-compiler', '~> 0.8.1'
18+
s.add_development_dependency 'rake-compiler', '~> 0.9.5'
1919
s.add_development_dependency 'rake', '~> 0.9.3'
2020
s.add_development_dependency 'rspec', '~> 2.8.0'
2121
end

0 commit comments

Comments
 (0)