Skip to content

Commit 1fcc1e9

Browse files
committed
Three fixes to Windows build errors since #473
Fix syntax for cross_config_options. Only invoke vendor:mysql when compiling for Windows. Only invoke vendor:mysql twice when cross-compiling for Windows.
1 parent 0fa2721 commit 1fcc1e9

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tasks/compile.rake

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
1212
CLEAN.include "#{ext.lib_dir}/*.#{RbConfig::CONFIG['DLEXT']}"
1313

1414
if RUBY_PLATFORM =~ /mswin|mingw/ then
15-
Rake::Task['vendor:mysql'].invoke
1615
# Expand the path because the build dir is 3-4 levels deep in tmp/platform/version/
1716
connector_dir = File.expand_path("../../vendor/#{vendor_mysql_dir}", __FILE__)
1817
ext.config_options = [ "--with-mysql-dir=#{connector_dir}" ]
1918
else
20-
Rake::Task['vendor:mysql'].invoke('x86')
21-
Rake::Task['vendor:mysql'].invoke('x64')
2219
ext.cross_compile = true
2320
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60', 'x64-mingw32']
24-
ext.cross_config_options = {
25-
'x86-mingw32' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__) ],
26-
'x86-mswin32-60' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__) ],
27-
'x64-mingw32' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x64')}", __FILE__) ],
21+
ext.cross_config_options << {
22+
'x86-mingw32' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__),
23+
'x86-mswin32-60' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__),
24+
'x64-mingw32' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x64')}", __FILE__),
2825
}
2926

3027
ext.cross_compiling do |spec|
@@ -76,4 +73,8 @@ end
7673
if RUBY_PLATFORM =~ /mingw|mswin/ then
7774
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
7875
Rake::Task['compile'].prerequisites.unshift 'devkit'
76+
else
77+
if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
78+
Rake::Task['cross'].prerequisites.unshift 'vendor:mysql:cross'
79+
end
7980
end

tasks/vendor_mysql.rake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def vendor_mysql_url(*args)
2121
end
2222

2323
# vendor:mysql
24+
task "vendor:mysql:cross" do |t|
25+
# When cross-compiling, grab both 32 and 64 bit connectors
26+
Rake::Task['vendor:mysql'].invoke('x86')
27+
Rake::Task['vendor:mysql'].invoke('x64')
28+
end
29+
2430
task "vendor:mysql", [:platform] do |t, args|
2531
puts "vendor:mysql for #{vendor_mysql_dir(args[:platform])}"
2632

0 commit comments

Comments
 (0)