mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
hal: fix selection to use toolchain instead of RUBY_PLATFORM
when building with MSVC on Windows, RUBY_PLATFORM (from the Ruby installation running rake) may indicate "mingw" if Ruby was installed via RubyInstaller, causing incorrect selection of POSIX HALs instead of Windows HALs. fixed by checking spec.build.primary_toolchain first: - if toolchain is "visualcpp", select Windows HALs - otherwise fall through to existing platform checks this ensures MSVC builds use hal-win-* gems even when Ruby itself was installed with MinGW. affected gems: - mruby-dir - mruby-io - mruby-socket - mruby-task Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,9 @@ MRuby::Gem::Specification.new('mruby-dir') do |spec|
|
||||
# MinGW provides POSIX compatibility, so use hal-posix-dir
|
||||
suggested_hal = if ENV['MRUBY_DIR_HAL']
|
||||
ENV['MRUBY_DIR_HAL']
|
||||
elsif spec.build.primary_toolchain == 'visualcpp'
|
||||
# Visual C++ on Windows - use native Windows HAL
|
||||
'hal-win-dir'
|
||||
elsif RUBY_PLATFORM =~ /linux|darwin|bsd|mingw/ ||
|
||||
(spec.build.kind_of?(MRuby::CrossBuild) && spec.build.host_target =~ /mingw/) ||
|
||||
spec.cc.command.to_s =~ /mingw/
|
||||
|
||||
@@ -11,9 +11,12 @@ 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
|
||||
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/
|
||||
suggested_hal = if spec.build.primary_toolchain == 'visualcpp'
|
||||
# Visual C++ on Windows - use native Windows HAL
|
||||
'hal-win-io'
|
||||
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-io'
|
||||
elsif spec.for_windows?
|
||||
'hal-win-io'
|
||||
|
||||
@@ -13,10 +13,15 @@ MRuby::Gem::Specification.new('mruby-socket') 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-.*-socket$/ } or begin
|
||||
# No HAL found - determine appropriate error message or auto-load
|
||||
suggested_hal = if spec.for_windows?
|
||||
suggested_hal = if spec.build.primary_toolchain == 'visualcpp'
|
||||
# Visual C++ on Windows - use native Windows HAL
|
||||
'hal-win-socket'
|
||||
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/
|
||||
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-socket'
|
||||
elsif spec.for_windows?
|
||||
'hal-win-socket'
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -10,10 +10,15 @@ MRuby::Gem::Specification.new('mruby-task') 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-.*-task$/ } or begin
|
||||
# No HAL found - determine appropriate error message or auto-load
|
||||
suggested_hal = if spec.for_windows?
|
||||
suggested_hal = if spec.build.primary_toolchain == 'visualcpp'
|
||||
# Visual C++ on Windows - use native Windows HAL
|
||||
'hal-win-task'
|
||||
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/
|
||||
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-task'
|
||||
elsif spec.for_windows?
|
||||
'hal-win-task'
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user