From 0f7f156bd16adad8ab2f313f26933a3c9fafbdd4 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 30 May 2023 14:20:11 +0200 Subject: [PATCH 1/3] Use the correct pattern for the fallback of rb_io_descriptor() * See https://github.com/ruby/io-console/pull/43/commits/d1d9aef45ceb14365fdf0ebee3e5ea06f27da682 --- ext/io/nonblock/nonblock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/io/nonblock/nonblock.c b/ext/io/nonblock/nonblock.c index 048c3aa..4c729a7 100644 --- a/ext/io/nonblock/nonblock.c +++ b/ext/io/nonblock/nonblock.c @@ -19,12 +19,13 @@ #ifndef HAVE_RB_IO_DESCRIPTOR static int -rb_io_descriptor(VALUE io) +io_descriptor_fallback(VALUE io) { rb_io_t *fptr; GetOpenFile(io, fptr); return fptr->fd; } +#define rb_io_descriptor io_descriptor_fallback #endif #ifdef F_GETFL From 0bcaec8807ff2c91ea7fdee6c338d5c280830164 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 30 May 2023 14:21:54 +0200 Subject: [PATCH 2/3] Add TruffleRuby support and add it in CI * Do not use a C extension on TruffleRuby for these 3 methods. --- .github/workflows/test.yml | 2 +- Rakefile | 13 +++++++++---- ext/io/nonblock/extconf.rb | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67353f3..389089f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: - ruby: [ 3.0, 2.7, head ] + ruby: [ 3.0, 2.7, head, truffleruby, truffleruby-head ] os: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/Rakefile b/Rakefile index 44b7d42..b622e9e 100644 --- a/Rakefile +++ b/Rakefile @@ -3,12 +3,17 @@ require "rake/testtask" name = "io/nonblock" -require 'rake/extensiontask' -extask = Rake::ExtensionTask.new(name) do |x| - x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}") +if RUBY_ENGINE == 'ruby' + require 'rake/extensiontask' + extask = Rake::ExtensionTask.new(name) do |x| + x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}") + end +else + task :compile end + Rake::TestTask.new(:test) do |t| - t.libs = ["lib/#{RUBY_VERSION}/#{extask.platform}"] + t.libs = ["lib/#{RUBY_VERSION}/#{extask.platform}"] if extask t.libs << "test/lib" t.ruby_opts << "-rhelper" t.test_files = FileList["test/**/test_*.rb"] diff --git a/ext/io/nonblock/extconf.rb b/ext/io/nonblock/extconf.rb index 5321593..a1e6075 100644 --- a/ext/io/nonblock/extconf.rb +++ b/ext/io/nonblock/extconf.rb @@ -2,6 +2,11 @@ require 'mkmf' target = "io/nonblock" +unless RUBY_ENGINE == 'ruby' + File.write("Makefile", dummy_makefile($srcdir).join("")) + return +end + have_func("rb_io_descriptor") hdr = %w"fcntl.h" From aec27bdb1ec9c19efb58eb4102c2595fe973e7ec Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 30 May 2023 14:32:55 +0200 Subject: [PATCH 3/3] Add JRuby in CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 389089f..51a46b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: - ruby: [ 3.0, 2.7, head, truffleruby, truffleruby-head ] + ruby: [ 3.0, 2.7, head, truffleruby, truffleruby-head, jruby, jruby-head ] os: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} steps: