mruby-io,mruby-dir: use posix hal for mingw instead of windows hal

mingw provides posix-compatible functions (readlink, symlink, opendir, etc.)
so it should use hal-posix-io/dir instead of hal-win-io/dir. detect mingw by
checking if host_target or compiler command contains "mingw". check posix
platforms first so mingw is caught before for_windows check.

this fixes test failures on mingw where readlink returned absolute paths
instead of relative paths, and symlink/socket tests failed due to api
differences between windows native apis and posix apis.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-16 16:05:49 +09:00
parent b424dfa331
commit 91922e05af
2 changed files with 17 additions and 5 deletions
+8 -2
View File
@@ -6,12 +6,18 @@ MRuby::Gem::Specification.new('mruby-dir') do |spec|
# HAL gems must be explicitly specified in build config (recommended) or via auto-selection below
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
'hal-posix-dir'
elsif spec.for_windows?
'hal-win-dir'
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/
'hal-posix-dir'
else
nil
end
+9 -3
View File
@@ -10,10 +10,16 @@ MRuby::Gem::Specification.new('mruby-io') do |spec|
# HAL gems must be explicitly specified in build config (recommended) or via auto-selection below
spec.build.gems.one? { |g| g.name =~ /^hal-.*-io$/ } or begin
# No HAL found - determine appropriate error message or auto-load
suggested_hal = if spec.for_windows?
'hal-win-io'
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/
# 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
'hal-posix-io'
elsif spec.for_windows?
'hal-win-io'
else
nil
end