diff options
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/benchmark.rake | 2 | ||||
| -rw-r--r-- | tasks/bin.rake | 35 | ||||
| -rw-r--r-- | tasks/core.rake | 5 | ||||
| -rw-r--r-- | tasks/libmruby.rake | 4 | ||||
| -rw-r--r-- | tasks/mrblib.rake | 30 | ||||
| -rw-r--r-- | tasks/presym.rake | 41 | ||||
| -rw-r--r-- | tasks/toolchains/gcc.rake | 4 | ||||
| -rw-r--r-- | tasks/toolchains/openwrt.rake | 23 | ||||
| -rw-r--r-- | tasks/toolchains/visualcpp.rake | 38 |
9 files changed, 131 insertions, 51 deletions
diff --git a/tasks/benchmark.rake b/tasks/benchmark.rake index 6f0b0ef6a..12e0d4602 100644 --- a/tasks/benchmark.rake +++ b/tasks/benchmark.rake @@ -50,7 +50,7 @@ end MRuby.each_target do |target| - next if target.name == 'host' + next if target.name == 'host' || target.internal? mruby_bin = "#{target.build_dir}/bin/mruby" bm_files.each do |bm_file| diff --git a/tasks/bin.rake b/tasks/bin.rake new file mode 100644 index 000000000..afef065a1 --- /dev/null +++ b/tasks/bin.rake @@ -0,0 +1,35 @@ +install_task = ->(src) do + dst = "#{MRuby::Build.install_dir}/#{File.basename(src)}" + file dst => src do + install_D src, dst + end + dst +end + +MRuby.each_target do |build| + if build.host? && build.mrbc_build && !build.gems["mruby-bin-mrbc"] + exe = build.exefile("#{build.mrbc_build.build_dir}/bin/mrbc") + build.products << install_task.(exe) + end + + build.bins.each do |bin| + exe = build.exefile("#{build.build_dir}/bin/#{bin}") + build.products << (build.host? ? install_task.(exe) : exe) + end + + linker_attrs = build.gems.map{|gem| gem.linker.run_attrs}.transpose + build.gems.each do |gem| + gem.bins.each do |bin| + exe = build.exefile("#{build.build_dir}/bin/#{bin}") + objs = Dir["#{gem.dir}/tools/#{bin}/*.{c,cpp,cxx,cc}"].map do |f| + build.objfile(f.pathmap("#{gem.build_dir}/tools/#{bin}/%n")) + end + + file exe => objs.concat(build.libraries) do |t| + build.linker.run t.name, t.prerequisites, *linker_attrs + end + + build.products << (build.host? ? install_task.(exe) : exe) + end + end +end diff --git a/tasks/core.rake b/tasks/core.rake index aca5faed8..a47722e8b 100644 --- a/tasks/core.rake +++ b/tasks/core.rake @@ -2,11 +2,10 @@ as_cxx_srcs = %w[vm error gc].map{|name| "#{MRUBY_ROOT}/src/#{name}.c"} MRuby.each_target do objs = Dir.glob("#{MRUBY_ROOT}/src/*.c").map do |src| - dst = src.pathmap("#{build_dir}/src/%n") if cxx_exception_enabled? && as_cxx_srcs.include?(src) - compile_as_cxx(src, "#{dst}.cxx") + compile_as_cxx(src) else - objfile(dst) + objfile(src.pathmap("#{build_dir}/src/%n")) end end self.libmruby_core_objs << objs diff --git a/tasks/libmruby.rake b/tasks/libmruby.rake index c73b25d3b..23cd992ff 100644 --- a/tasks/libmruby.rake +++ b/tasks/libmruby.rake @@ -3,6 +3,8 @@ MRuby.each_target do archiver.run t.name, t.prerequisites end + products << libmruby_core_static + next unless libmruby_enabled? file libmruby_static => libmruby_objs.flatten do |t| @@ -27,4 +29,6 @@ MRuby.each_target do f.puts "MRUBY_LIBMRUBY_PATH = #{libmruby_static}" end end + + products << libmruby_static end diff --git a/tasks/mrblib.rake b/tasks/mrblib.rake index a7f592593..5567515d6 100644 --- a/tasks/mrblib.rake +++ b/tasks/mrblib.rake @@ -2,13 +2,18 @@ MRuby.each_target do next unless libmruby_enabled? src = "#{build_dir}/mrblib/mrblib.c" - obj = objfile(src.ext) rbfiles = Dir["#{MRUBY_ROOT}/mrblib/*.rb"].sort! - self.libmruby_objs << obj + self.libmruby_objs << objfile(src.ext) - file obj => src file src => [mrbcfile, __FILE__, *rbfiles] do |t| + if presym_enabled? + cdump = true + suffix = "proc" + else + cdump = false + suffix = "irep" + end mkdir_p File.dirname(t.name) File.open(t.name, 'w') do |f| _pp "GEN", "mrblib/*.rb", "#{t.name.relative_path}" @@ -19,14 +24,17 @@ MRuby.each_target do f.puts %Q[ * This file was generated!] f.puts %Q[ * All manual changes will get lost.] f.puts %Q[ */] - mrbc.run f, rbfiles, 'mrblib_proc' - f.puts <<INIT_END -void -mrb_init_mrblib(mrb_state *mrb) -{ - mrb_load_proc(mrb, mrblib_proc); -} -INIT_END + unless presym_enabled? + f.puts %Q[#include <mruby.h>] + f.puts %Q[#include <mruby/irep.h>] + end + mrbc.run f, rbfiles, "mrblib_#{suffix}", cdump + f.puts %Q[void] + f.puts %Q[mrb_init_mrblib(mrb_state *mrb)] + f.puts %Q[{] + f.puts %Q[ mrblib_#{suffix}_init_syms(mrb);] if cdump + f.puts %Q[ mrb_load_#{suffix}(mrb, mrblib_#{suffix});] + f.puts %Q[}] end end end diff --git a/tasks/presym.rake b/tasks/presym.rake new file mode 100644 index 000000000..f3a076ac6 --- /dev/null +++ b/tasks/presym.rake @@ -0,0 +1,41 @@ +all_prerequisites = ->(task_name, prereqs) do + Rake::Task[task_name].prerequisites.each do |prereq_name| + next if prereqs[prereq_name] + prereqs[prereq_name] = true + all_prerequisites.(Rake::Task[prereq_name].name, prereqs) + end +end + +MRuby.each_target do |build| + gensym_task = task(:gensym) + next unless build.presym_enabled? + + presym = build.presym + + include_dir = "#{build.build_dir}/include" + build.compilers.each{|c| c.include_paths << include_dir} + build.gems.each{|gem| gem.compilers.each{|c| c.include_paths << include_dir}} + + prereqs = {} + pps = [] + mrbtest = "#{build.class.install_dir}/mrbtest" + mrbc_build_dir = "#{build.mrbc_build.build_dir}/" if build.mrbc_build + build.products.each do |product| + all_prerequisites.(product, prereqs) unless product == mrbtest + end + prereqs.each_key do |prereq| + next unless File.extname(prereq) == build.exts.object + next if mrbc_build_dir && prereq.start_with?(mrbc_build_dir) + pps << prereq.ext(build.exts.preprocessed) + end + + file presym.list_path => pps do + presyms = presym.scan(pps) + current_presyms = presym.read_list if File.exist?(presym.list_path) + update = presyms != current_presyms + presym.write_list(presyms) if update + presym.write_header(presyms) if update || !File.exist?(presym.header_path) + end + + gensym_task.enhance([presym.list_path]) +end diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index 316d2d9a1..8714e1854 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -3,6 +3,7 @@ MRuby::Toolchain.new(:gcc) do |conf, params| compiler_flags = %w(-g -O3 -Wall -Wundef) c_mandatory_flags = %w(-std=gnu99) cxx_invalid_flags = %w(-Werror-implicit-function-declaration) + compile_opt = '%{flags} -MMD -MF "%{outfile}.d" -o "%{outfile}" "%{infile}"' [conf.cc, conf.objc, conf.asm, conf.cxx].each do |compiler| if compiler == conf.cxx @@ -14,7 +15,8 @@ MRuby::Toolchain.new(:gcc) do |conf, params| end compiler.option_include_path = %q[-I"%s"] compiler.option_define = '-D%s' - compiler.compile_options = %q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"] + compiler.compile_options = "-c #{compile_opt}" + compiler.preprocess_options = "-E -P #{compile_opt}" compiler.cxx_compile_flag = '-x c++ -std=gnu++03' compiler.cxx_exception_flag = '-fexceptions' compiler.cxx_invalid_flags = c_mandatory_flags + cxx_invalid_flags diff --git a/tasks/toolchains/openwrt.rake b/tasks/toolchains/openwrt.rake index c376d96ec..d5763d8de 100644 --- a/tasks/toolchains/openwrt.rake +++ b/tasks/toolchains/openwrt.rake @@ -1,24 +1,19 @@ # usage of environmental variables to set the # cross compiling toolchain proper MRuby::Toolchain.new(:openwrt) do |conf| - [conf.cc, conf.objc, conf.asm].each do |cc| - cc.command = ENV['TARGET_CC'] - cc.flags = ENV['TARGET_CFLAGS'] - cc.include_paths = ["#{MRUBY_ROOT}/include"] + [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc| + if cc == conf.cxx + cc.command = ENV['TARGET_CXX'] + cc.flags = ENV['TARGET_CXXFLAGS'] + else + cc.command = ENV['TARGET_CC'] + cc.flags = ENV['TARGET_CFLAGS'] + end cc.option_include_path = %q[-I"%s"] cc.option_define = '-D%s' - cc.compile_options = %q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"] + cc.compile_options = %q[%{flags} -MMD -MF "%{outfile}.d" -o "%{outfile}" -c "%{infile}"] end - [conf.cxx].each do |cxx| - cxx.command = ENV['TARGET_CXX'] - cxx.flags = ENV['TARGET_CXXFLAGS'] - cxx.include_paths = ["#{MRUBY_ROOT}/include"] - cxx.option_include_path = %q[-I"%s"] - cxx.option_define = '-D%s' - cxx.compile_options = %q[%{flags} -MMD -o "%{outfile}" -c "%{infile}"] - end - conf.linker do |linker| linker.command = ENV['TARGET_CC'] linker.flags = ENV['TARGET_LDFLAGS'] diff --git a/tasks/toolchains/visualcpp.rake b/tasks/toolchains/visualcpp.rake index 5094495e3..00e364082 100644 --- a/tasks/toolchains/visualcpp.rake +++ b/tasks/toolchains/visualcpp.rake @@ -1,25 +1,21 @@ MRuby::Toolchain.new(:visualcpp) do |conf, _params| - conf.cc do |cc| - cc.command = ENV['CC'] || 'cl.exe' - # C4013: implicit function declaration - cc.flags = [ENV['CFLAGS'] || %w(/c /nologo /W3 /we4013 /Zi /MD /O2 /D_CRT_SECURE_NO_WARNINGS)] - cc.defines = %w(MRB_STACK_EXTEND_DOUBLING) - cc.option_include_path = %q[/I"%s"] - cc.option_define = '/D%s' - cc.compile_options = %Q[%{flags} /Fo"%{outfile}" "%{infile}"] - cc.cxx_compile_flag = '/TP' - cc.cxx_exception_flag = '/EHs' - end - - conf.cxx do |cxx| - cxx.command = ENV['CXX'] || 'cl.exe' - cxx.flags = [ENV['CXXFLAGS'] || ENV['CFLAGS'] || %w(/c /nologo /W3 /Zi /MD /O2 /EHs /D_CRT_SECURE_NO_WARNINGS)] - cxx.defines = %w(MRB_STACK_EXTEND_DOUBLING) - cxx.option_include_path = %q[/I"%s"] - cxx.option_define = '/D%s' - cxx.compile_options = %Q[%{flags} /Fo"%{outfile}" "%{infile}"] - cxx.cxx_compile_flag = '/TP' - cxx.cxx_exception_flag = '/EHs' + compiler_flags = %w(/nologo /W3 /MD /O2 /D_CRT_SECURE_NO_WARNINGS) + [conf.cc, conf.cxx].each do |compiler| + if compiler == conf.cc + compiler.command = ENV['CC'] || 'cl.exe' + # C4013: implicit function declaration + compiler.flags = [*(ENV['CFLAGS'] || compiler_flags + %w(/we4013))] + else + compiler.command = ENV['CXX'] || 'cl.exe' + compiler.flags = [*(ENV['CXXFLAGS'] || ENV['CFLAGS'] || compiler_flags + %w(/EHs))] + end + compiler.defines = %w(MRB_STACK_EXTEND_DOUBLING) + compiler.option_include_path = %q[/I"%s"] + compiler.option_define = '/D%s' + compiler.compile_options = %Q[/Zi /c /Fo"%{outfile}" %{flags} "%{infile}"] + compiler.preprocess_options = %Q[/EP %{flags} "%{infile}" > "%{outfile}"] + compiler.cxx_compile_flag = '/TP' + compiler.cxx_exception_flag = '/EHs' end conf.linker do |linker| |
