mruby-io,mruby-dir: improve mingw detection for native builds

add mingw pattern to RUBY_PLATFORM check. native mingw builds were
falling through to windows hal because previous detection only worked
for cross-compilation. now checks RUBY_PLATFORM for mingw along with
linux/darwin/bsd.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-16 17:38:37 +09:00
parent 0c849e9020
commit 1efaaa5570
2 changed files with 6 additions and 12 deletions
+3 -6
View File
@@ -7,14 +7,11 @@ MRuby::Gem::Specification.new('mruby-dir') do |spec|
spec.build.gems.one? { |g| g.name =~ /^hal-.*-dir$/ } or begin
# No HAL found - determine appropriate error message or auto-load
# MinGW provides POSIX compatibility, so use hal-posix-dir
# Detect MinGW by checking host_target or compiler command
is_mingw = (spec.build.kind_of?(MRuby::CrossBuild) &&
spec.build.host_target =~ /mingw/) ||
spec.cc.command.to_s =~ /mingw/
suggested_hal = if ENV['MRUBY_DIR_HAL']
ENV['MRUBY_DIR_HAL']
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/ || is_mingw
elsif RUBY_PLATFORM =~ /linux|darwin|bsd|mingw/ ||
(spec.build.kind_of?(MRuby::CrossBuild) && spec.build.host_target =~ /mingw/) ||
spec.cc.command.to_s =~ /mingw/
'hal-posix-dir'
elsif spec.for_windows?
'hal-win-dir'
+3 -6
View File
@@ -11,12 +11,9 @@ MRuby::Gem::Specification.new('mruby-io') do |spec|
spec.build.gems.one? { |g| g.name =~ /^hal-.*-io$/ } or begin
# No HAL found - determine appropriate error message or auto-load
# MinGW provides POSIX compatibility, so use hal-posix-io
# Detect MinGW by checking host_target or compiler command
is_mingw = (spec.build.kind_of?(MRuby::CrossBuild) &&
spec.build.host_target =~ /mingw/) ||
spec.cc.command.to_s =~ /mingw/
suggested_hal = if RUBY_PLATFORM =~ /linux|darwin|bsd/ || is_mingw
suggested_hal = if RUBY_PLATFORM =~ /linux|darwin|bsd|mingw/ ||
(spec.build.kind_of?(MRuby::CrossBuild) && spec.build.host_target =~ /mingw/) ||
spec.cc.command.to_s =~ /mingw/
'hal-posix-io'
elsif spec.for_windows?
'hal-win-io'