Add -s option to mrbc for make variable static

This commit is contained in:
KOBAYASHI Shuji
2021-02-14 11:55:53 +09:00
parent c3ec5861ac
commit a6a76d8fd2
7 changed files with 41 additions and 22 deletions
+5 -2
View File
@@ -328,13 +328,16 @@ module MRuby
@compile_options = "-B%{funcname} -o-"
end
def run(out, infiles, funcname, cdump = true)
def run(out, infiles, funcname, cdump: true, static: false)
@command ||= @build.mrbcfile
infiles = [infiles].flatten
infiles.each_with_index do |f, i|
_pp i == 0 ? "MRBC" : "", f.relative_path, indent: 2
end
cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
opt = @compile_options % {funcname: funcname}
opt << " -S" if cdump
opt << " -s" if static
cmd = %["#{filename @command}" #{opt} #{filename(infiles).map{|f| %["#{f}"]}.join(' ')}]
puts cmd if Rake.verbose
IO.popen(cmd, 'r+') do |io|
out.puts io.read
+3 -2
View File
@@ -198,10 +198,11 @@ module MRuby
open(fname, 'w') do |f|
print_gem_init_header f
unless rbfiles.empty?
opts = {cdump: cdump?, static: true}
if cdump?
build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc"
build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc", **opts
else
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", false
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", **opts
end
end
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]