mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
db1578c123
The issue resolved by the preceding patch was solely the C++ exception task within the mruby core. This patch aims to resolve a similar sequencing issue that also exists in GEMS. In practice, `mruby-compiler` is sometimes loaded via dependencies rather than being explicitly specified in the build configuration file. In such cases, when `mruby-compiler/mrbgem.rake` is loaded, it is not yet determined whether C++ exceptions will be used. Consequently, even if it later becomes clear that `core/codegen-cxx.cxx` and `core/y.tab-cxx.cxx` are required, the system could not handle this. To resolve this issue, we introduce the `MRuby::Gem::Specification#build_settings` method as a mechanism for lazily evaluating build setup. However, for backward compatibility, the commands are cloned twice in `gem.setup` and `gem.setup_build`. This is because many existing GEMS configure commands directly within the setup block. ref. https://github.com/mruby/mruby/issues/6615
mruby-compiler
This mrbgem provides the mruby compiler, which is responsible for parsing Ruby code and generating mruby bytecode.
Functionality
The mruby-compiler gem includes the following components:
- Parser: Translates Ruby source code into an abstract syntax tree (AST).
- Code Generator: Traverses the AST to produce executable mruby bytecode.
mrbcexecutable: A command-line tool for compiling.rbfiles into.mrbbytecode files.
Usage
The mrbc (mruby-bin-mrbc) executable will generate compiled binary from Ruby
programs via this gem.
Example of using mrbc:
# Compile a Ruby script to bytecode
bin/mrbc my_script.rb
# Run the compiled script
bin/mruby my_script.mrb