Skip to content

Commit

Permalink
Three fixes to Windows build errors since brianmario#473
Browse files Browse the repository at this point in the history
Fix syntax for cross_config_options.
Only invoke vendor:mysql when compiling for Windows.
Only invoke vendor:mysql twice when cross-compiling for Windows.
  • Loading branch information
sodabrew committed Feb 9, 2015
1 parent 0fa2721 commit 1fcc1e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tasks/compile.rake
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ Rake::ExtensionTask.new("mysql2", gemspec) do |ext|
CLEAN.include "#{ext.lib_dir}/*.#{RbConfig::CONFIG['DLEXT']}"

if RUBY_PLATFORM =~ /mswin|mingw/ then
Rake::Task['vendor:mysql'].invoke
# Expand the path because the build dir is 3-4 levels deep in tmp/platform/version/
connector_dir = File.expand_path("../../vendor/#{vendor_mysql_dir}", __FILE__)
ext.config_options = [ "--with-mysql-dir=#{connector_dir}" ]
else
Rake::Task['vendor:mysql'].invoke('x86')
Rake::Task['vendor:mysql'].invoke('x64')
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60', 'x64-mingw32']
ext.cross_config_options = {
'x86-mingw32' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__) ],
'x86-mswin32-60' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__) ],
'x64-mingw32' => [ "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x64')}", __FILE__) ],
ext.cross_config_options << {
'x86-mingw32' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__),
'x86-mswin32-60' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x86')}", __FILE__),
'x64-mingw32' => "--with-mysql-dir=" + File.expand_path("../../vendor/#{vendor_mysql_dir('x64')}", __FILE__),
}

ext.cross_compiling do |spec|
Expand Down Expand Up @@ -76,4 +73,8 @@ end
if RUBY_PLATFORM =~ /mingw|mswin/ then
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
Rake::Task['compile'].prerequisites.unshift 'devkit'
else
if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
Rake::Task['cross'].prerequisites.unshift 'vendor:mysql:cross'
end
end
6 changes: 6 additions & 0 deletions tasks/vendor_mysql.rake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def vendor_mysql_url(*args)
end

# vendor:mysql
task "vendor:mysql:cross" do |t|
# When cross-compiling, grab both 32 and 64 bit connectors
Rake::Task['vendor:mysql'].invoke('x86')
Rake::Task['vendor:mysql'].invoke('x64')
end

task "vendor:mysql", [:platform] do |t, args|
puts "vendor:mysql for #{vendor_mysql_dir(args[:platform])}"

Expand Down

0 comments on commit 1fcc1e9

Please sign in to comment.