New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JRuby #11
Conversation
One bit of process I'm not sure about: this -java gem can only be built with JRuby, and likewise the standard gem can't be build on JRuby, because the gemspec uses RUBY_ENGINE. This could be modified to allow building both versions on any impl, since they're just packaging files (i.e. there's no compile step required for either JRuby or MRI). |
Do you want io-console to include the Java version? |
@nobu I think it would be best for the gem to actually contain our version of the library, as we already do for psych, json, racc, and other libraries. We will have to push a We want to match CRuby's use of default/preinstalled gems as closely as possible going forward. |
Your addition of --platform will allow any implementation to build either platform gem, so I like that part. |
This commit makes the following changes: * Move JRuby-specific console logic to io/console/jruby * Add console.rb to load appropriate impl for the current engine * Adjust tags to match passing tests * Add test_io_console to MRI stdlib suite See ruby/io-console#11
This commit makes the following changes: * Move JRuby-specific console logic to io/console/jruby * Add console.rb to load appropriate impl for the current engine * Adjust tags to match passing tests * Add test_io_console to MRI stdlib suite See ruby/io-console#11
058d2fb
to
524936e
Compare
I have re-pushed the primary commit with paths fixed. This version is now also live in JRuby proper and passing CI. I also pushed a second commit that fixes a broken test on JRuby. The path to the "rubybin" executable was tweaked to substitute |
Add `--platform` option tentatively.
This fixes ruby#10. Whenever a gem is pushed for the default platform a gem must be pushed for the 'java' platform to avoid breaking JRuby users.
I'd like to have this FFI implementation work on TruffleRuby too, see ruby/reline#124 and oracle/truffleruby#1904 (comment). I think using the |
t[:c_lflag] &= ~(LibC::ECHOE|LibC::ECHOK) | ||
end | ||
|
||
def raw(*, &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options are not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean min
, time
and intr
options which are supported by IO#raw
.
Isn't it better to place these files under a different name, e.g. "ffilib/", if truffleruby will use them too? |
I meant "not only for jruby". |
I'm thinking of installing/moving ffi-version files by extconf.rb. |
@nobu I think there should be a single gem push for simplicity, so a single platform. |
I pushed 0.5.6, which just skips the extension on other than CRuby. |
@nobu Thanks, I can confirm |
Great! I guess that it's possible to install on JRuby too. And, I think the |
So the issue with reline was resolved. The remaining issue would be io-console getting installed by a JRuby user, possibly through a transitive dependency. I would still like to see this gem contain the FFI implementation, so it could be shared across non-CRuby implementations. The FFI would be the fallback for platforms or runtimes that do not build the C extension. Some day, perhaps it could replace the C extension? |
I agree it would be good to have the FFI implementation here too. I think @nobu had some concern in #11 (comment) and @aycabta in #11 (comment). @headius Could you try to address them so it's fully compatible with the C extension? |
I should be clear: this code was not originally written by me. I am hoping through this PR to release it into the public trust, so we can collaborate on making it a drop-in replacement for io/console. I would welcome suggestions and patches for concrete improvements to make. @nobu What do you mean "the options are not supported?" Are you referring to the LibC flags you linked? Or something like the @aycabta Yes I agree this should match the C extension as closely as possible, but I'm not familiar with the |
a240630
to
eddd042
Compare
I updated my branch to include the changes @nobu made as well as one fix from @aardvark179. Not much has changed since the original discussion of this PR (e.g. the |
In the short term, can we get a -java gem release that includes the FFI logic but not the C extension? At the moment we can't install reline on Windows because of the io-console requirement, which forces users to have a Our users have been ok with this version for many years, even if it does not have all features and does not pass all tests. We will take responsibility for the code and bug reports against the FFI logic (which will probably be filed with JRuby rather than io-console). |
For others following along... I have implemented the missing functionality in the FFI io/console and it now runs green on CRuby. It also runs green on JRuby with the exception of a few tests that require PTY.spawn to produce a child process with its own TTY, which is broken on JRuby (jruby/jruby#6552). The FFI implementation can be shipped now, I believe. See #22 |
This PR contains the JRuby implementation of io/console based on FFI. It should be pushed as a
java
platform gem any time the io-console gem is updated.Fixes #10.