From b73dd8f6d0d04fec834c4aae0139cf6c0270f780 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 17 Jun 2024 07:20:53 +0000 Subject: [PATCH] [ruby/io-console] Skip building extension on WASI WASI does not support concept to provide termios, so it is not possible to build io/console extension on WASI at the moment. However, `io/console` is used by many gems, and removing the dependency from them *conditionally* is impossible. So, this commit adds a check to skip building `io/console` extension on WASI just to pass `gem install` for the platform. https://github.com/ruby/io-console/commit/ba9bf00184 --- ext/io/console/extconf.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb index a72403c7f90fa4..0cd8eaea0f40fb 100644 --- a/ext/io/console/extconf.rb +++ b/ext/io/console/extconf.rb @@ -1,13 +1,24 @@ # frozen_string_literal: false require 'mkmf' +# `--target-rbconfig` compatibility for Ruby 3.3 or earlier +# See https://bugs.ruby-lang.org/issues/20345 +MakeMakefile::RbConfig ||= ::RbConfig + have_func("rb_io_path") have_func("rb_io_descriptor") have_func("rb_io_get_write_io") have_func("rb_io_closed_p") have_func("rb_io_open_descriptor") -ok = true if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby" +is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"] +# `ok` can be `true`, `false`, or `nil`: +# * `true` : Required headers and functions available, proceed regular build. +# * `false`: Required headers or functions not available, abort build. +# * `nil` : Unsupported compilation target, generate dummy Makefile. +# +# Skip building io/console on WASI, as it does not support termios.h. +ok = true if (RUBY_ENGINE == "ruby" && !is_wasi) || RUBY_ENGINE == "truffleruby" hdr = nil case when macro_defined?("_WIN32", "")