Refactor `mrblib/mrblib.rake`
MRuby.each_target do
- current_dir = File.dirname(__FILE__)
- relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT)
- current_build_dir = "#{build_dir}/#{relative_from_root}"
+ src = "#{build_dir}/mrblib/mrblib.c"
+ obj = objfile(src.ext)
+ rbfiles = Dir["#{MRUBY_ROOT}/mrblib/*.rb"].sort!
- self.libmruby_objs << objfile("#{current_build_dir}/mrblib")
+ self.libmruby_objs << obj
- file objfile("#{current_build_dir}/mrblib") => "#{current_build_dir}/mrblib.c"
- file "#{current_build_dir}/mrblib.c" => [mrbcfile, __FILE__] + Dir.glob("#{current_dir}/*.rb").sort do |t|
- _, _, *rbfiles = t.prerequisites
+ file obj => src
+ file src => [mrbcfile, __FILE__, *rbfiles] do |t|
mkdir_p File.dirname(t.name)
- open(t.name, 'w') do |f|
- _pp "GEN", "*.rb", "#{t.name.relative_path}"
+ File.open(t.name, 'w') do |f|
+ _pp "GEN", "mrblib/*.rb", "#{t.name.relative_path}"
f.puts %Q[/*]
f.puts %Q[ * This file is loading the mrblib]
f.puts %Q[ *]
