Skip to content

Commit

Permalink
Do not compile the C extension on TruffleRuby
Browse files Browse the repository at this point in the history
* 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:
  ruby/openssl#699
  • Loading branch information
eregon authored and nobu committed Nov 27, 2023
1 parent a5616dd commit d791b63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 12 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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"]
Expand Down
6 changes: 5 additions & 1 deletion ext/stringio/extconf.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d791b63

Please sign in to comment.