Commit 73b41525 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Make it possible that `libmruby.a` is not created

Previously, `libmruby.a` was created even if only `mruby-bin-mrbc` or`
mruby-compiler` was specified for gem, but by specifying `disable_libmruby`,
the creation of `libmruby.a` can be suppressed.

### Note

The https://github.com/mruby/mruby/pull/5084#issuecomment-723521971
incompatibility seems to be difficult for users to avoid, so the original
behavior has been restored. Therefore, if we need `mrbc` other than the
`host` build, we need to explicitly specify `mruby-bin-mrbc` gem.

Due to the above changes, `build_config/boxing.rb` etc. will not work, but I
have added` mruby-bin-mrbc` to `default.gembox` to fix it. I don't think
this change is a big deal because originally `mruby-compiler` was included.
parent 4cd34937
...@@ -230,7 +230,7 @@ desc "preallocated symbols" ...@@ -230,7 +230,7 @@ desc "preallocated symbols"
task :gensym => presym_file task :gensym => presym_file
depfiles += MRuby.targets.map { |n, t| depfiles += MRuby.targets.map { |n, t|
t.libraries t.libmruby_enabled? ? t.libraries : t.libmruby_core_static
}.flatten }.flatten
depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t| depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
......
MRuby::Build.new("host") do |conf|
# load specific toolchain settings
toolchain :gcc
conf.gem :core => "mruby-bin-mrbc"
end
# Define cross build settings # Define cross build settings
MRuby::CrossBuild.new('no-float') do |conf| MRuby::CrossBuild.new('no-float') do |conf|
toolchain :gcc toolchain :gcc
......
...@@ -53,7 +53,7 @@ module MRuby ...@@ -53,7 +53,7 @@ module MRuby
include Rake::DSL include Rake::DSL
include LoadGems include LoadGems
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url attr_reader :libmruby_core_objs, :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url
alias libmruby libmruby_objs alias libmruby libmruby_objs
...@@ -66,7 +66,7 @@ module MRuby ...@@ -66,7 +66,7 @@ module MRuby
def initialize(name='host', build_dir=nil, &block) def initialize(name='host', build_dir=nil, &block)
@name = name.to_s @name = name.to_s
unless MRuby.targets[@name] unless current = MRuby.targets[@name]
if ENV['OS'] == 'Windows_NT' if ENV['OS'] == 'Windows_NT'
@exts = Exts.new('.o', '.exe', '.a') @exts = Exts.new('.o', '.exe', '.a')
else else
...@@ -91,7 +91,9 @@ module MRuby ...@@ -91,7 +91,9 @@ module MRuby
@bins = [] @bins = []
@gems = MRuby::Gem::List.new @gems = MRuby::Gem::List.new
@libmruby_objs = [] @libmruby_core_objs = []
@libmruby_objs = [@libmruby_core_objs]
@enable_libmruby = true
@build_mrbtest_lib_only = false @build_mrbtest_lib_only = false
@cxx_exception_enabled = false @cxx_exception_enabled = false
@cxx_exception_disabled = false @cxx_exception_disabled = false
...@@ -102,15 +104,22 @@ module MRuby ...@@ -102,15 +104,22 @@ module MRuby
@toolchains = [] @toolchains = []
@gem_dir_to_repo_url = {} @gem_dir_to_repo_url = {}
MRuby.targets[@name] = self MRuby.targets[@name] = self.class.current = current = self
end end
current = MRuby.targets[@name]
MRuby::Build.current = current
current.instance_eval(&block) current.instance_eval(&block)
current.build_mrbc_exec if current.libmruby_enabled? && @name == "host"
current.build_mrbtest if current.test_enabled? current.build_mrbtest if current.test_enabled?
end end
def libmruby_enabled?
@enable_libmruby
end
def disable_libmruby
@enable_libmruby = false
end
def debug_enabled? def debug_enabled?
@enable_debug @enable_debug
end end
...@@ -255,11 +264,9 @@ EOS ...@@ -255,11 +264,9 @@ EOS
def mrbcfile def mrbcfile
return @mrbcfile if @mrbcfile return @mrbcfile if @mrbcfile
unless gems.detect {|v| v.name == 'mruby-bin-mrbc' } gem_name = "mruby-bin-mrbc"
build_mrbc_exec gem = gems[gem_name] || MRuby.targets["host"].gems[gem_name]
gems.detect {|v| v.name == 'mruby-bin-mrbc' }.setup @mrbcfile = exefile("#{gem.build.build_dir}/bin/mrbc")
end
@mrbcfile = self.exefile("#{self.build_dir}/bin/mrbc")
end end
def compilers def compilers
...@@ -392,6 +399,7 @@ EOS ...@@ -392,6 +399,7 @@ EOS
toolchain :gcc toolchain :gcc
end end
conf.gem :core => 'mruby-bin-mrbc' conf.gem :core => 'mruby-bin-mrbc'
conf.disable_libmruby
end end
end end
@endian = nil @endian = nil
...@@ -400,8 +408,7 @@ EOS ...@@ -400,8 +408,7 @@ EOS
end end
def mrbcfile def mrbcfile
host = MRuby.targets['host'] MRuby.targets['host'].mrbcfile
host.exefile("#{host.build_dir}/bin/mrbc")
end end
def run_test def run_test
......
...@@ -353,6 +353,10 @@ module MRuby ...@@ -353,6 +353,10 @@ module MRuby
@ary.each(&b) @ary.each(&b)
end end
def [](name)
@ary.detect {|g| g.name == name}
end
def <<(gem) def <<(gem)
unless @ary.detect {|g| g.dir == gem.dir } unless @ary.detect {|g| g.dir == gem.dir }
@ary << gem @ary << gem
......
...@@ -78,6 +78,9 @@ MRuby::GemBox.new do |conf| ...@@ -78,6 +78,9 @@ MRuby::GemBox.new do |conf|
conf.gem :core => "mruby-rational" conf.gem :core => "mruby-rational"
conf.gem :core => "mruby-complex" conf.gem :core => "mruby-complex"
# Generate mrbc command
conf.gem :core => "mruby-bin-mrbc"
# Generate mirb command # Generate mirb command
conf.gem :core => "mruby-bin-mirb" conf.gem :core => "mruby-bin-mirb"
......
...@@ -2,15 +2,14 @@ MRuby::Gem::Specification.new 'mruby-bin-mrbc' do |spec| ...@@ -2,15 +2,14 @@ MRuby::Gem::Specification.new 'mruby-bin-mrbc' do |spec|
spec.license = 'MIT' spec.license = 'MIT'
spec.author = 'mruby developers' spec.author = 'mruby developers'
spec.summary = 'mruby compiler executable' spec.summary = 'mruby compiler executable'
spec.add_dependency 'mruby-compiler', :core => 'mruby-compiler' spec.add_dependency 'mruby-compiler', :core => 'mruby-compiler'
exec = exefile("#{build.build_dir}/bin/mrbc") exec = exefile("#{build.build_dir}/bin/mrbc")
mrbc_objs = Dir.glob("#{spec.dir}/tools/mrbc/*.c").map { |f| objfile(f.pathmap("#{spec.build_dir}/tools/mrbc/%n")) }.flatten mrbc_objs = Dir.glob("#{spec.dir}/tools/mrbc/*.c").map { |f| objfile(f.pathmap("#{spec.build_dir}/tools/mrbc/%n")) }
file exec => mrbc_objs + [build.libmruby_core_static] do |t| file exec => mrbc_objs << build.libmruby_core_static do |t|
build.linker.run t.name, t.prerequisites build.linker.run t.name, t.prerequisites
end end
build.bins << 'mrbc' unless build.bins.find { |v| v == 'mrbc' } build.bins << 'mrbc'
end end
...@@ -3,20 +3,18 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec| ...@@ -3,20 +3,18 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec|
spec.author = 'mruby developers' spec.author = 'mruby developers'
spec.summary = 'mruby compiler library' spec.summary = 'mruby compiler library'
lex_def = "#{dir}/core/lex.def" as_cxx_srcs = %w[codegen y.tab].map{|name| "#{dir}/core/#{name}.c"}
core_objs = Dir.glob("#{dir}/core/*.c").map { |f| objs = Dir.glob("#{dir}/core/*.c").map do |src|
next nil if build.cxx_exception_enabled? and f =~ /(codegen|y\.tab)\.c$/ dst = src.pathmap("#{build_dir}/core/%n")
objfile(f.pathmap("#{build_dir}/core/%n")) if build.cxx_exception_enabled? && as_cxx_srcs.include?(src)
}.compact build.compile_as_cxx(src, "#{dst}.cxx")
else
if build.cxx_exception_enabled? objfile(dst)
core_objs << end
build.compile_as_cxx("#{dir}/core/y.tab.c", "#{build_dir}/core/y.tab.cxx",
objfile("#{build_dir}/y.tab"), ["#{dir}/core"]) <<
build.compile_as_cxx("#{dir}/core/codegen.c", "#{build_dir}/core/codegen.cxx")
else
core_objs << objfile("#{build_dir}/core/y.tab")
end end
build.libmruby_core_objs << objs
lex_def = "#{dir}/core/lex.def"
# Parser # Parser
file "#{dir}/core/y.tab.c" => ["#{dir}/core/parse.y", lex_def] do |t| file "#{dir}/core/y.tab.c" => ["#{dir}/core/parse.y", lex_def] do |t|
...@@ -30,9 +28,6 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec| ...@@ -30,9 +28,6 @@ MRuby::Gem::Specification.new 'mruby-compiler' do |spec|
replace_line_directive(t.name) replace_line_directive(t.name)
end end
file build.libmruby_core_static => core_objs
build.libmruby << core_objs
def replace_line_directive(path) def replace_line_directive(path)
content = File.read(path).gsub(%r{ content = File.read(path).gsub(%r{
^\#line\s+\d+\s+"\K.*$ | # #line directive ^\#line\s+\d+\s+"\K.*$ | # #line directive
......
...@@ -9,9 +9,5 @@ MRuby.each_target do ...@@ -9,9 +9,5 @@ MRuby.each_target do
objfile(dst) objfile(dst)
end end
end end
self.libmruby_objs << objs self.libmruby_core_objs << objs
file libmruby_core_static => objs do |t|
archiver.run t.name, t.prerequisites
end
end end
MRuby.each_target do MRuby.each_target do
file libmruby_core_static => libmruby_core_objs.flatten do |t|
archiver.run t.name, t.prerequisites
end
next unless libmruby_enabled?
file libmruby_static => libmruby_objs.flatten do |t| file libmruby_static => libmruby_objs.flatten do |t|
archiver.run t.name, t.prerequisites archiver.run t.name, t.prerequisites
end end
......
MRuby.each_target do MRuby.each_target do
next unless libmruby_enabled?
src = "#{build_dir}/mrblib/mrblib.c" src = "#{build_dir}/mrblib/mrblib.c"
obj = objfile(src.ext) obj = objfile(src.ext)
rbfiles = Dir["#{MRUBY_ROOT}/mrblib/*.rb"].sort! rbfiles = Dir["#{MRUBY_ROOT}/mrblib/*.rb"].sort!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment