Skip to content

Commit

Permalink
Replace Win32API with Fiddle, update appveyor.yml (brianmario#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg authored and sodabrew committed Oct 2, 2019
1 parent 9804551 commit fd32e28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on_failure:
- find tmp -name "*.log" | xargs cat
environment:
matrix:
- ruby_version: "26-x64"
MINGW_PACKAGE_PREFIX: "mingw-w64-x86_64"
- ruby_version: "25-x64"
MINGW_PACKAGE_PREFIX: "mingw-w64-x86_64"
- ruby_version: "24-x64"
MINGW_PACKAGE_PREFIX: "mingw-w64-x86_64"
- ruby_version: "24"
Expand Down
9 changes: 6 additions & 3 deletions lib/mysql2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
end

if dll_path
require 'Win32API'
LoadLibrary = Win32API.new('Kernel32', 'LoadLibrary', ['P'], 'I')
if LoadLibrary.call(dll_path).zero?
require 'fiddle'
kernel32 = Fiddle.dlopen 'kernel32'
load_library = Fiddle::Function.new(
kernel32['LoadLibraryW'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT,
)
if load_library.call(dll_path.encode('utf-16le')).zero?
abort "Failed to load libmysql.dll from #{dll_path}"
end
end
Expand Down

0 comments on commit fd32e28

Please sign in to comment.