akihikodaki / cld3-ruby

cld3-ruby is an interface of Compact Language Detector v3 (CLD3) for Ruby.
Apache License 2.0
77 stars 22 forks source link

Compatible to macOS #1

Closed ykzts closed 7 years ago

ykzts commented 7 years ago

Fix https://github.com/tootsuite/mastodon/pull/2949#issuecomment-300260804

ykzts commented 7 years ago

It does not matter on platforms other than macOS. It is not necessary to use values other than FFI.

akihikodaki commented 7 years ago

@ykzts The problem is FFI uses values irrelevant from native extensions; FFI.map_library_name is inteded to be compatible with libraries installed to the system. Though it matters only for macOS for now, another platform may have different values for the two variables in future since the intensions of FFI.map_library_name and RbConfig::CONFIG["DLEXT"] are different. RbConfig::CONFIG["DLEXT"] sounds more correct or something sort of, considering that.

ykzts commented 7 years ago

FFI is not intended to load an extension library of Ruby which builds by running gem build. This is the distortion that is occurring for that. Originally it should be implemented using ruby.h without using FFI.

My patch is the method used in cld 2 gem. Temporarily use such a solution, eventually remove FFI.

akihikodaki commented 7 years ago

@ykzts The decision to use FFI is a different issue. Consider how we could deal with the distortion in this issue. For your information, I decided to use FFI because I was convinced with https://github.com/ffi/ffi/wiki/why-use-ffi. Open another issue if you are against with that.

ykzts commented 7 years ago

What is written on the wiki does not take into consideration what is built from extconf.rb.

akihikodaki commented 7 years ago

An FFI extension is multi-platform and multi-implementation An FFI extension works without changes on Ruby, JRuby, and any other Ruby VM that supports FFI.

This applies also for embedded extensions.

ykzts commented 7 years ago

I do not know how to write better than cdaee7f.

"ibcld3." Is hard-coded. I do not know the merit of using constants only for suffix.

akihikodaki commented 7 years ago

@ykzts The name of libcld3 is not dependent on mkmf, but written in extconf.rb. It is safe to assume.

create_makefile("libcld3")

https://github.com/akihikodaki/cld3-ruby/commit/a82866fee388c4e076f827b6aeb7e3716eaee011#diff-008b2ea0e48987eb07538f63cb0739d2R49

ykzts commented 7 years ago

This is your library. If you do it your way, you are OK.

akihikodaki commented 7 years ago

Thank you for your pull request and discussion anyway. That helps to understand the issue of FFI better.