mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Separating the build setup portion from the GEMS setup block
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
This commit is contained in:
+27
-4
@@ -53,10 +53,8 @@ module MRuby
|
||||
return if defined?(@bins) # return if already set up
|
||||
|
||||
MRuby::Gem.current = self
|
||||
MRuby::Build::COMMANDS.each do |command|
|
||||
instance_variable_set("@#{command}", @build.send(command).clone)
|
||||
end
|
||||
@linker.run_attrs.each(&:clear)
|
||||
reset_commands # for backward compatibility, reset the commands from the beginning.
|
||||
@build_settings = nil
|
||||
|
||||
@rbfiles = Dir.glob("#{@dir}/mrblib/**/*.rb").sort
|
||||
@objs = srcs_to_objs("src")
|
||||
@@ -192,6 +190,19 @@ module MRuby
|
||||
end
|
||||
end
|
||||
|
||||
def build_settings(&blk)
|
||||
@build_settings = blk
|
||||
end
|
||||
|
||||
def setup_build
|
||||
if @build_settings
|
||||
# by this point, build.cc or other commands may have been modified.
|
||||
# therefore, reset the commands again before calling build_settings.
|
||||
reset_commands
|
||||
@build_settings.call(self)
|
||||
end
|
||||
end
|
||||
|
||||
def define_gem_init_builder
|
||||
file "#{build_dir}/gem_init.c" => [build.mrbcfile, __FILE__] + [rbfiles].flatten do |t|
|
||||
mkdir_p build_dir
|
||||
@@ -303,6 +314,13 @@ module MRuby
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
private def reset_commands
|
||||
MRuby::Build::COMMANDS.each do |command|
|
||||
instance_variable_set("@#{command}", @build.send(command).clone)
|
||||
end
|
||||
@linker.run_attrs.each(&:clear)
|
||||
end
|
||||
end # Specification
|
||||
|
||||
class Version
|
||||
@@ -410,6 +428,11 @@ module MRuby
|
||||
end until gemset == gemset_prev
|
||||
end
|
||||
|
||||
def setup_build
|
||||
each(&:setup_build)
|
||||
self
|
||||
end
|
||||
|
||||
def setup_dependencies(build)
|
||||
gem_table = each_with_object({}) { |spec, h| h[spec.name] = spec }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user