mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
feca90ceab
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>
41 lines
1.7 KiB
Ruby
41 lines
1.7 KiB
Ruby
MRuby::Gem::Specification.new('mruby-io') do |spec|
|
|
spec.license = 'MIT'
|
|
spec.authors = ['Internet Initiative Japan Inc.', 'mruby developers']
|
|
spec.summary = 'IO and File class'
|
|
|
|
spec.build.defines << "HAVE_MRUBY_IO_GEM"
|
|
spec.add_test_dependency 'mruby-time', core: 'mruby-time'
|
|
|
|
# Check if HAL gem is loaded
|
|
# 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
|
|
# MinGW provides POSIX compatibility, so use hal-posix-io
|
|
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'
|
|
else
|
|
nil
|
|
end
|
|
|
|
if suggested_hal
|
|
# Auto-load HAL gem for convenience (for development)
|
|
# This works because HAL gems declare dependency on mruby-io
|
|
warn "mruby-io: No HAL specified, loading #{suggested_hal} (explicit selection recommended)"
|
|
spec.build.gem core: suggested_hal
|
|
else
|
|
# Unknown platform - fail with helpful message
|
|
fail "mruby-io: No HAL available for platform '#{RUBY_PLATFORM}'.\n" \
|
|
"Please specify HAL gem explicitly in your build config:\n" \
|
|
" conf.gem core: 'hal-posix-io' # For Linux/macOS/BSD\n" \
|
|
" conf.gem core: 'hal-win-io' # For Windows"
|
|
end
|
|
end
|
|
end
|