Closed humdogm closed 2 years ago
Fixes #48
Doesn't this require adding win32-api
as a dependency in .gemspec
, like this:
...?
Doesn't this require adding
win32-api
as a dependency in.gemspec
Yes sorry, here is the commit for that as well.
While fixing things for Ruby 3.0 looks like a good idea, we can't afford to break things for other OSes. Can we somehow scope
win32-api
to Windows only?
From doing some reading on gemspecs, it looks like You'll want to create platform-specific gems for your gem that has different dependencies
according to this rubygems github issue and uses this part of the gem specification. I'm not very familiar with ruby, would that entail creating a new repository or could that be done just at build time?
I'd be all for releasing a new version of kaitai-struct-visualizer
, but I really wanted to resolve the Ruby 3 incompatibility on Windows. I have been eyeing this PR, but it uses https://github.com/cosmo0920/win32-api whose author strongly encourages to migrate away from and "use FFI" instead. There is also win32api
from Ruby lang developers, which is deprecated as well, but at least it gives a hint what to do
(https://github.com/ruby/win32api/blob/f020cca/lib/Win32API.rb#L5):
warn "Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead", uplevel: 2
So https://github.com/ruby/fiddle is apparently the way to go. This Gist compares how to call a Win32 function using both Fiddle
and Win32API
(which we're using right now), so we can see how to migrate: https://gist.github.com/Iristyle/db78afd90bf59c28d3cc1741241bde56
I don't even think we'll still need to roll out platform-specific gems with Fiddle, because it's even supposedly in the standard library since 1.9 (source). Also: https://ruby-doc.org/stdlib-3.1.2/libdoc/fiddle/rdoc/Fiddle.html
Is that the kind of thing you are looking for? If I had know about Fiddle at the time I made my PR I would have used that instead.
@humdogm Thanks again! 🥇 🚀 🎉
Win32API, which was originally part of the Ruby standard library, was slated for removal in version 2.0, according to the developer of win32-api. win32-api is a
drop-in replacement for the Win32API library
. The only major differences are putting the dll name as the last argument, and it requires capital letters for prototype and return types.The developer states that:
So, there is not a problem supporting multiple versions of Ruby with this change.
I have tested this on Ruby 3.0.2 on Windows 10.0.19043 in Command Prompt and Powershell v5.1.19041.1237