Files
mruby-mruby/mrbgems/mruby-task/mrbgem.rake
T
Yukihiro "Matz" Matsumoto 9c100ab844 mruby-task: introduce HAL (hardware abstraction layer) for platform support
separates platform-specific timer and interrupt code into hal-posix-task
and hal-win-task gems. mruby-task now uses HAL interface defined in
task_hal.h, making it easier to port to new platforms.

hal-posix-task: uses sigalrm/setitimer for timer, sigprocmask for irq
protection, and SA_RESTART flag to prevent EINTR on system calls.

hal-win-task: uses multimedia timer API and critical_section for irq
protection.

both HALs support multiple mrb_state instances with single shared timer.
auto-detection loads appropriate HAL based on platform.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-14 09:14:59 +09:00

36 lines
1.4 KiB
Ruby

MRuby::Gem::Specification.new('mruby-task') do |spec|
spec.license = 'MIT'
spec.authors = 'mruby developers'
spec.summary = 'Cooperative multitasking with preemptive scheduling'
# Enable task scheduler globally (required for vm.c integration)
spec.build.defines << 'MRB_USE_TASK_SCHEDULER'
# 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-.*-task$/ } or begin
# No HAL found - determine appropriate error message or auto-load
suggested_hal = if spec.for_windows?
'hal-win-task'
elsif RUBY_PLATFORM =~ /linux|darwin|bsd/
'hal-posix-task'
else
nil
end
if suggested_hal
# Auto-load HAL gem for convenience (for development)
# This works because HAL gems declare dependency on mruby-task
warn "mruby-task: No HAL specified, loading #{suggested_hal} (explicit selection recommended)"
spec.build.gem core: suggested_hal
else
# Unknown platform - fail with helpful message
fail "mruby-task: No HAL available for platform '#{RUBY_PLATFORM}'.\n" \
"Please specify HAL gem explicitly in your build config:\n" \
" conf.gem core: 'hal-posix-task' # For Linux/macOS/BSD\n" \
" conf.gem core: 'hal-win-task' # For Windows\n" \
"Or create custom HAL - see mrbgems/mruby-task/README.md"
end
end
end