summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2020-12-05 09:16:08 +0900
committerKOBAYASHI Shuji <[email protected]>2020-12-05 09:16:08 +0900
commit73b4152574f0dd6747488662751f59f8c4c0b50d (patch)
tree276b3dd985af38345c4561f43d7961b4c13a1a9f /lib
parent4cd349373779bb643444f85fa1d04b0769c58c63 (diff)
downloadmruby-73b4152574f0dd6747488662751f59f8c4c0b50d.tar.gz
mruby-73b4152574f0dd6747488662751f59f8c4c0b50d.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/mruby/build.rb33
-rw-r--r--lib/mruby/gem.rb4
2 files changed, 24 insertions, 13 deletions
diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb
index a9e84effe..c4ed79fb1 100644
--- a/lib/mruby/build.rb
+++ b/lib/mruby/build.rb
@@ -53,7 +53,7 @@ module MRuby
include Rake::DSL
include LoadGems
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
@@ -66,7 +66,7 @@ module MRuby
def initialize(name='host', build_dir=nil, &block)
@name = name.to_s
- unless MRuby.targets[@name]
+ unless current = MRuby.targets[@name]
if ENV['OS'] == 'Windows_NT'
@exts = Exts.new('.o', '.exe', '.a')
else
@@ -91,7 +91,9 @@ module MRuby
@bins = []
@gems = MRuby::Gem::List.new
- @libmruby_objs = []
+ @libmruby_core_objs = []
+ @libmruby_objs = [@libmruby_core_objs]
+ @enable_libmruby = true
@build_mrbtest_lib_only = false
@cxx_exception_enabled = false
@cxx_exception_disabled = false
@@ -102,15 +104,22 @@ module MRuby
@toolchains = []
@gem_dir_to_repo_url = {}
- MRuby.targets[@name] = self
+ MRuby.targets[@name] = self.class.current = current = self
end
- current = MRuby.targets[@name]
- MRuby::Build.current = current
current.instance_eval(&block)
+ current.build_mrbc_exec if current.libmruby_enabled? && @name == "host"
current.build_mrbtest if current.test_enabled?
end
+ def libmruby_enabled?
+ @enable_libmruby
+ end
+
+ def disable_libmruby
+ @enable_libmruby = false
+ end
+
def debug_enabled?
@enable_debug
end
@@ -255,11 +264,9 @@ EOS
def mrbcfile
return @mrbcfile if @mrbcfile
- unless gems.detect {|v| v.name == 'mruby-bin-mrbc' }
- build_mrbc_exec
- gems.detect {|v| v.name == 'mruby-bin-mrbc' }.setup
- end
- @mrbcfile = self.exefile("#{self.build_dir}/bin/mrbc")
+ gem_name = "mruby-bin-mrbc"
+ gem = gems[gem_name] || MRuby.targets["host"].gems[gem_name]
+ @mrbcfile = exefile("#{gem.build.build_dir}/bin/mrbc")
end
def compilers
@@ -392,6 +399,7 @@ EOS
toolchain :gcc
end
conf.gem :core => 'mruby-bin-mrbc'
+ conf.disable_libmruby
end
end
@endian = nil
@@ -400,8 +408,7 @@ EOS
end
def mrbcfile
- host = MRuby.targets['host']
- host.exefile("#{host.build_dir}/bin/mrbc")
+ MRuby.targets['host'].mrbcfile
end
def run_test
diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb
index eb94c9eda..e3b758f4f 100644
--- a/lib/mruby/gem.rb
+++ b/lib/mruby/gem.rb
@@ -353,6 +353,10 @@ module MRuby
@ary.each(&b)
end
+ def [](name)
+ @ary.detect {|g| g.name == name}
+ end
+
def <<(gem)
unless @ary.detect {|g| g.dir == gem.dir }
@ary << gem