diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67353f3..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 ] + ruby: [ 3.0, 2.7, head, truffleruby, truffleruby-head, jruby, jruby-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" 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