Skip to content

Commit ba9bf00

Browse files
kateinoigakukunhsbt
authored andcommitted
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.
1 parent 7fe3f97 commit ba9bf00

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ext/io/console/extconf.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
# frozen_string_literal: false
22
require 'mkmf'
33

4+
# `--target-rbconfig` compatibility for Ruby 3.3 or earlier
5+
# See https://bugs.ruby-lang.org/issues/20345
6+
MakeMakefile::RbConfig ||= ::RbConfig
7+
48
have_func("rb_io_path")
59
have_func("rb_io_descriptor")
610
have_func("rb_io_get_write_io")
711
have_func("rb_io_closed_p")
812
have_func("rb_io_open_descriptor")
913

10-
ok = true if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
14+
is_wasi = /wasi/ =~ MakeMakefile::RbConfig::CONFIG["platform"]
15+
# `ok` can be `true`, `false`, or `nil`:
16+
# * `true` : Required headers and functions available, proceed regular build.
17+
# * `false`: Required headers or functions not available, abort build.
18+
# * `nil` : Unsupported compilation target, generate dummy Makefile.
19+
#
20+
# Skip building io/console on WASI, as it does not support termios.h.
21+
ok = true if (RUBY_ENGINE == "ruby" && !is_wasi) || RUBY_ENGINE == "truffleruby"
1122
hdr = nil
1223
case
1324
when macro_defined?("_WIN32", "")

0 commit comments

Comments
 (0)