-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compat with RubyInstaller-2.4 on Windows #875
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,20 @@ | |
ENV['RUBY_MYSQL2_LIBMYSQL_DLL'] | ||
elsif File.exist?(File.expand_path('../vendor/libmysql.dll', File.dirname(__FILE__))) | ||
# Use vendor/libmysql.dll if it exists, convert slashes for Win32 LoadLibrary | ||
File.expand_path('../vendor/libmysql.dll', File.dirname(__FILE__)).tr('/', '\\') | ||
File.expand_path('../vendor/libmysql.dll', File.dirname(__FILE__)) | ||
elsif defined?(RubyInstaller) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# RubyInstaller-2.4+ native build doesn't need DLL preloading | ||
else | ||
# This will use default / system library paths | ||
'libmysql.dll' | ||
end | ||
|
||
require 'Win32API' | ||
LoadLibrary = Win32API.new('Kernel32', 'LoadLibrary', ['P'], 'I') | ||
if 0 == LoadLibrary.call(dll_path) | ||
abort "Failed to load libmysql.dll from #{dll_path}" | ||
if dll_path | ||
require 'Win32API' | ||
LoadLibrary = Win32API.new('Kernel32', 'LoadLibrary', ['P'], 'I') | ||
if 0 == LoadLibrary.call(dll_path) | ||
abort "Failed to load libmysql.dll from #{dll_path}" | ||
end | ||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -712,7 +712,6 @@ def stmt_count | |
|
||
it 'should return number of rows affected by an insert' do | ||
stmt = @client.prepare 'INSERT INTO lastIdTest (blah) VALUES (?)' | ||
expect(stmt.affected_rows).to eq 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As commented: The change in the spec is required for mariadbclient. It throws an error if no query was executed. |
||
stmt.execute 1 | ||
expect(stmt.affected_rows).to eq 1 | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ Rake::ExtensionTask.new("mysql2", Mysql2::GEMSPEC) do |ext| | |
# clean compiled extension | ||
CLEAN.include "#{ext.lib_dir}/*.#{RbConfig::CONFIG['DLEXT']}" | ||
|
||
if RUBY_PLATFORM =~ /mswin|mingw/ | ||
if RUBY_PLATFORM =~ /mswin|mingw/ && !defined?(RubyInstaller) | ||
# 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}"] | ||
|
@@ -26,6 +26,10 @@ Rake::ExtensionTask.new("mysql2", Mysql2::GEMSPEC) do |ext| | |
Rake::Task['lib/mysql2/mysql2.rb'].invoke | ||
# vendor/libmysql.dll is invoked from extconf.rb | ||
Rake::Task['vendor/README'].invoke | ||
|
||
# only the source gem has a package dependency - the binary gem ships it's own DLL version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, but thanks for the hint! |
||
spec.metadata.delete('msys2_mingw_dependencies') | ||
|
||
spec.files << 'lib/mysql2/mysql2.rb' | ||
spec.files << 'vendor/libmysql.dll' | ||
spec.files << 'vendor/README' | ||
|
@@ -77,7 +81,7 @@ task :devkit do | |
end | ||
|
||
if RUBY_PLATFORM =~ /mingw|mswin/ | ||
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql' | ||
Rake::Task['compile'].prerequisites.unshift 'vendor:mysql' unless defined?(RubyInstaller) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not following why the unless RubyInstaller case is needed. This file shouldn't execute in the source code case, only when I'm building the binaries at my desktop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reason is: the simplest way to build the mysql2 gem is by using the On the other hand the vendored library works as well, provided that the |
||
Rake::Task['compile'].prerequisites.unshift 'devkit' | ||
else | ||
if Rake::Task.tasks.map(&:name).include? 'cross' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember the backslashes being required, since the LoadLibrary call is native Windows and not Ruby.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoadLibrary accepts both, forward and backward slashes as all filesystem related WINAPI functions do. There's no need to translate path separators. cmd and powershell don't recognize forward slashs, but can handle them as well.