Commit a74f92b4 authored by Yuichiro MASUI's avatar Yuichiro MASUI

Generate mrbtest.a file for sparete from driver.o

parent dfff7323
......@@ -62,9 +62,9 @@ task :all => depfiles do
end
desc "run all mruby tests"
task :test => MRuby.targets.values.map { |t| t.exefile("#{t.build_dir}/test/mrbtest") } do
task :test => MRuby.targets.values.map { |t| t.build_mrbtest_lib_only? ? t.libfile("#{t.build_dir}/test/mrbtest") : t.exefile("#{t.build_dir}/test/mrbtest") } do
MRuby.each_target do
run_test
run_test unless build_mrbtest_lib_only?
end
end
......
......@@ -74,5 +74,7 @@ end
# conf.cc.flags << "-m32"
# conf.linker.flags << "-m32"
#
# conf.build_mrbtest_lib_only
#
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
# end
......@@ -160,6 +160,16 @@ Integrate GEMs in the build process.
# Integrate GEM without additional configuration
conf.gem 'path/to/another/gem'
### Mrbtest
Configuration Mrbtest build process.
If you want mrbtest.a only, You should set ```conf.build_mrbtest_lib_only```
conf.build_mrbtest_lib_only
## Cross-Compilation
mruby can also be cross-compiled from one platform to another. To
......
......@@ -77,8 +77,8 @@ module MRuby
"#{build.build_dir}/mrbgems/#{name}"
end
def testlib
libfile("#{build_dir}/libmrb-#{name}-gem-test")
def test_rbireps
"#{build_dir}/gem_test.c"
end
def funcname
......
......@@ -2,15 +2,10 @@ MRuby.each_target do
dir = File.dirname(__FILE__).relative_path_from(root)
gems.each do |g|
test_rbc = "#{g.build_dir}/gem_test.c"
test_rbobj = test_rbc.ext(exts.object)
test_rbobj = g.test_rbireps.ext(exts.object)
file g.testlib => [g.test_objs, test_rbobj].flatten do |t|
g.build.archiver.run t.name, t.prerequisites
end
file test_rbobj => test_rbc
file test_rbc => [g.test_rbfiles].flatten + [g.build.mrbcfile, libfile("#{build_dir}/lib/libmruby")] do |t|
file test_rbobj => g.test_rbireps
file g.test_rbireps => [g.test_rbfiles].flatten + [g.build.mrbcfile, libfile("#{build_dir}/lib/libmruby")] do |t|
open(t.name, 'w') do |f|
g.print_gem_init_header(f)
g.build.mrbc.run f, g.test_preload, "gem_test_irep_#{g.funcname}_preload"
......
......@@ -78,6 +78,7 @@ module MRuby
@bins = %w(mruby mrbc mirb)
@gems, @libmruby = [], []
@build_mrbtest_lib_only = false
MRuby.targets[@name] = self
end
......@@ -149,6 +150,14 @@ module MRuby
end
end
def build_mrbtest_lib_only
@build_mrbtest_lib_only = true
end
def build_mrbtest_lib_only?
@build_mrbtest_lib_only
end
def run_test
puts ">>> Test #{name} <<<"
mrbtest = exefile("#{build_dir}/test/mrbtest")
......
......@@ -8,9 +8,14 @@ MRuby.each_target do
init = "#{dir}/init_mrbtest.c"
asslib = "#{dir}/assert.rb"
objs = [objfile("#{build_dir}/#{dir}/driver"), mlib].flatten
mrbtest_lib = libfile("#{build_dir}/#{dir}/mrbtest")
file mrbtest_lib => [mlib, gems.map(&:test_objs), gems.map { |g| g.test_rbireps.ext(exts.object) }].flatten do |t|
archiver.run t.name, t.prerequisites
end
file exec => objs + gems.map(&:testlib).flatten + [libfile("#{build_dir}/lib/libmruby")] do |t|
unless build_mrbtest_lib_only?
driver_obj = objfile("#{build_dir}/#{dir}/driver")
file exec => [driver_obj, mrbtest_lib, libfile("#{build_dir}/lib/libmruby")] do |t|
gem_flags = gems.map { |g| g.linker.flags }
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
......@@ -18,10 +23,12 @@ MRuby.each_target do
gem_library_paths = gems.map { |g| g.linker.library_paths }
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries
end
end
file mlib => [clib]
file clib => [mrbcfile, init, asslib] + mrbs do |t|
_pp "GEN", "*.rb", "#{clib}"
FileUtils.mkdir_p File.dirname(__FILE__)
open(clib, 'w') do |f|
f.puts IO.read(init)
mrbc.run f, [asslib] + mrbs, 'mrbtest_irep'
......
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