jacius / nice-ffi

Nice-FFI: Convenience layer atop Ruby-FFI
http://jacius.github.com/nice-ffi/
23 stars 9 forks source link

Cygwin users cannot load SDL #6

Open ngolovin opened 8 years ago

ngolovin commented 8 years ago

Workaround: edit the file https://github.com/jacius/nice-ffi/blob/master/lib/nice-ffi/pathset.rb:456

paths = @paths.collect{ |regexp,ps| regexp =~ os ? ps : [] }.flatten

replace by

paths = @paths.collect{ |regexp,ps| regexp =~ "windows" ? ps : [] }.flatten
jacius commented 8 years ago

Hi, and thanks for submitting this issue. I have some suggestions about better ways to work around this.

If you tell me the output of the command ruby -r ffi -e 'p FFI::Platform::OS' and the path(s) where libraries are located in Cygwin, I can add support for Cygwin to Nice-FFI. That said, I don't know if there will ever be a new release of Nice-FFI, so maybe that doesn't help you much.

Alternatively, if you are using ruby-sdl-ffi (or rubygame), there are two built-in workarounds to add custom load paths:

1) If you are writing your own app, you can define the SDL_PATHS constant in your app to be an array of additional paths to search for SDL. You must define the constant before loading ruby-sdl-ffi, like so:

SDL_PATHS = [ "C:\\windows\\system32\\", "C:\\windows\\system\\" ]
require 'ruby-sdl-ffi'

2) If you are running someone else's app, you can set the RUBYSDLFFI_PATH environment variable (in your shell or system settings) to a path (or semicolon-separated list of paths for Windows, or colon-separated list of paths for Linux/BSD/Mac), like so:

export RUBYSDLFFI_PATH="C:\\windows\\system32\\;C:\\windows\\system\\"
ruby ./some-app.rb

I hope that helps.