From c2b09a69400854a1e002c99035242de1f514faf5 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 24 Nov 2023 13:14:56 +0100 Subject: [PATCH] Do not compile the C extension on TruffleRuby * Before this it was compiled but not used, because TruffleRuby has a stringio.rb in stdlib and .rb has precedence over .so. In fact that extension never worked on TruffleRuby, because rb_io_extract_modeenc() has never been defined on TruffleRuby. * So this just skip compiling the extension since compilation of it now fails: https://github.com/ruby/openssl/issues/699 --- Rakefile | 16 ++++++++++++---- ext/stringio/extconf.rb | 6 +++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 1a16b54..5fec2bc 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,8 @@ require "rake/testtask" name = "stringio" -if RUBY_PLATFORM =~ /java/ +case RUBY_ENGINE +when "jruby" require 'rake/javaextensiontask' extask = Rake::JavaExtensionTask.new("stringio") do |ext| ext.lib_dir << "/#{ext.platform}" @@ -13,15 +14,22 @@ if RUBY_PLATFORM =~ /java/ end task :build => "#{extask.lib_dir}/#{extask.name}.jar" -else +when "ruby" require 'rake/extensiontask' extask = Rake::ExtensionTask.new(name) do |x| x.lib_dir << "/#{RUBY_VERSION}/#{x.platform}" end +else + task :compile end + Rake::TestTask.new(:test) do |t| - ENV["RUBYOPT"] = "-I" + [extask.lib_dir, "test/lib"].join(File::PATH_SEPARATOR) - t.libs << extask.lib_dir + if extask + ENV["RUBYOPT"] = "-I" + [extask.lib_dir, "test/lib"].join(File::PATH_SEPARATOR) + t.libs << extask.lib_dir + else + ENV["RUBYOPT"] = "-Itest/lib" + end t.libs << "test/lib" t.ruby_opts << "-rhelper" t.test_files = FileList["test/**/test_*.rb"] diff --git a/ext/stringio/extconf.rb b/ext/stringio/extconf.rb index ad8650d..553732f 100644 --- a/ext/stringio/extconf.rb +++ b/ext/stringio/extconf.rb @@ -1,3 +1,7 @@ # frozen_string_literal: false require 'mkmf' -create_makefile('stringio') +if RUBY_ENGINE == 'ruby' + create_makefile('stringio') +else + File.write('Makefile', dummy_makefile("").join) +end