priv-kweihmann / meta-rubygems

Layer for ruby gems
Other
3 stars 9 forks source link

Package request: libusb #655

Open dive-gozo opened 4 months ago

dive-gozo commented 4 months ago

What gem should be added LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary USB devices.

I'd like to add a PR for this gem, but ran into problems when bitbaking the recipe (see here) https://github.com/dive-gozo/meta-rubygems/commit/62512738b330dfcc10bed606a3add1dc7c139ab8

The error message says

ERROR: failed to build gem native extension
extconf failed, exit code 1
in 'require': cannot load such file -- ffi (LoadError)
from extconf.rb:4:in '<main>'

libusb has build dependencies on rubygems-ffi-native and rubygems-mini-portile2-native. The problem with rubygems-ffi-native is, that libusb's ext/extconf.rb requires 'ffi' in line 4, which is not in Ruby's $LOAD_PATH.

bitbake rubygems-ffi and bitbake rubygems-ffi-native are running successfully.

As a result ffi is available in poky/build/tmp/work/x86_64-linux/rubygems-libusb-native/0.7.1/recipe-sysroot-native/usr/lib/ruby/gems/3.3.0/gems/ffi-1.16.3/lib/ffi

Unfortunately, I didn't find a solution to tell Ruby where to find ffi, when compiling the extension for libusb.

Any help is very appreciated.

Link to gem on rubygems.org

https://rubygems.org/gems/libusb

priv-kweihmann commented 4 months ago

See #309. The problem is that the implementation does not provide the entire cross compiling toolchain. It can for a single gem (incl. as many as possible cross compiled extensions) compile the target code, but it cannot use the results to cross-link against those results in a gem extension that depends on that.

This would require a full cross-compiled ruby, which is still pretty annoying to patch in on every patch of the ruby runtime.

I haven't spend time on that, and likely won't any time soon, but I'm open to accept PRs (libusb being the perfect example).

For now I will but this ticket on hold

dive-gozo commented 4 months ago

Thank you Konrad, for your very fast response and the link to the older issue. Unfortunately, I'm not a Ruby expert and can't provide the needed patches to make libusb cross-compile. If you like, you can close this issue.