Commit 7201404e authored by take_cheeze's avatar take_cheeze

compile assert.rb once

parent e203383d
......@@ -62,7 +62,7 @@ module MRuby
@test_objs = Dir.glob("#{dir}/test/*.{c,cpp,cxx,m,asm,S}").map do |f|
objfile(f.relative_path_from(dir).to_s.pathmap("#{build_dir}/%X"))
end
@test_preload = 'test/assert.rb'
@test_preload = nil # 'test/assert.rb'
@test_args = {}
@bins = []
......
......@@ -6,11 +6,15 @@ MRuby.each_target do
file g.test_rbireps => [g.test_rbfiles].flatten + [g.build.mrbcfile] do |t|
open(t.name, 'w') do |f|
g.print_gem_test_header(f)
test_preload = [g.dir, MRUBY_ROOT].map {|dir|
test_preload = g.test_preload and [g.dir, MRUBY_ROOT].map {|dir|
File.expand_path(g.test_preload, dir)
}.find {|file| File.exist?(file) }
g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload"
if test_preload.nil?
f.puts %Q[extern const uint8_t mrbtest_assert_irep[];]
else
g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload"
end
g.test_rbfiles.flatten.each_with_index do |rbfile, i|
g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}"
end
......@@ -31,7 +35,11 @@ MRuby.each_target do
f.puts %Q[ if (mrb_test(val3)) {]
f.puts %Q[ mrb_gv_set(mrb2, mrb_intern_cstr(mrb2, "$mrbtest_verbose"), val3);]
f.puts %Q[ }]
f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);]
if test_preload.nil?
f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);]
else
f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);]
end
f.puts %Q[ if (mrb2->exc) {]
f.puts %Q[ mrb_p(mrb2, mrb_obj_value(mrb2->exc));]
f.puts %Q[ exit(EXIT_FAILURE);]
......
......@@ -2,6 +2,7 @@
#include "mruby.h"
#include "mruby/irep.h"
extern const uint8_t mrbtest_assert_irep[];
extern const uint8_t mrbtest_irep[];
void mrbgemtest_init(mrb_state* mrb);
......@@ -9,6 +10,7 @@ void mrbgemtest_init(mrb_state* mrb);
void
mrb_init_mrbtest(mrb_state *mrb)
{
mrb_load_irep(mrb, mrbtest_assert_irep);
mrb_load_irep(mrb, mrbtest_irep);
#ifndef DISABLE_GEMS
mrbgemtest_init(mrb);
......
......@@ -8,10 +8,11 @@ MRuby.each_target do
mlib = clib.ext(exts.object)
mrbs = Dir.glob("#{current_dir}/t/*.rb")
init = "#{current_dir}/init_mrbtest.c"
asslib = "#{current_dir}/assert.rb"
ass_c = "#{current_build_dir}/assert.c"
ass_lib = ass_c.ext(exts.object)
mrbtest_lib = libfile("#{current_build_dir}/mrbtest")
file mrbtest_lib => [mlib, gems.map(&:test_objs), gems.map { |g| g.test_rbireps.ext(exts.object) }].flatten do |t|
file mrbtest_lib => [mlib, ass_lib, gems.map(&:test_objs), gems.map { |g| g.test_rbireps.ext(exts.object) }].flatten do |t|
archiver.run t.name, t.prerequisites
end
......@@ -27,13 +28,21 @@ MRuby.each_target do
end
end
file mlib => [clib]
file clib => [mrbcfile, init, asslib] + mrbs do |t|
file ass_lib => ass_c
file ass_c => "#{current_dir}/assert.rb" do |t|
FileUtils.mkdir_p File.dirname t.name
open(t.name, 'w') do |f|
mrbc.run f, [t.prerequisites], 'mrbtest_assert_irep'
end
end
file mlib => clib
file clib => [mrbcfile, init] + mrbs do |t|
_pp "GEN", "*.rb", "#{clib.relative_path}"
FileUtils.mkdir_p File.dirname(clib)
open(clib, 'w') do |f|
f.puts IO.read(init)
mrbc.run f, [asslib] + mrbs, 'mrbtest_irep'
mrbc.run f, mrbs, 'mrbtest_irep'
gems.each do |g|
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
end
......
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