Commit b8a6c5ce authored by Yuichiro MASUI's avatar Yuichiro MASUI

Changed objccflags to objcflags

Added cxxflags, objcflags, asmflags to mrbgem.rake
Support .cxx and .cc as C++ source in mrbgems
parent db2fed84
......@@ -20,7 +20,7 @@ module MRuby
attr_accessor :ld, :ldflags, :libs
attr_accessor :ar
attr_writer :cxx, :cxxflags
attr_writer :objcc, :objccflags
attr_writer :objcc, :objcflags
attr_writer :asm, :asmflags
attr_accessor :gperf, :yacc
attr_accessor :cat, :git
......@@ -46,13 +46,13 @@ module MRuby
end
def cxx; @cxx || cc; end
def cxxflags; @cxxflags.empty? ? cflags : @cxxflags; end
def cxxflags; !@cxxflags || @cxxflags.empty? ? cflags : @cxxflags; end
def objcc; @objcc || cc; end
def objccflags; @objccflags.empty? ? cflags : @objccflags; end
def objcflags; !@objcflags || @objcflags.empty? ? cflags : @objcflags; end
def asm; @asm || cc; end
def asmflags; @asmflags.empty? ? cflags : @asmflags; end
def asmflags; !@asmflags || @asmflags.empty? ? cflags : @asmflags; end
def ld; @ld || cc; end
......
......@@ -33,7 +33,7 @@ module MRuby
@name = name
@build = MRuby.build
@dir = Gem.processing_path
@cflags = []
@cflags, @cxxflags, @objcflags, @asmflags = [], [], [], []
@mruby_cflags, @mruby_ldflags, @mruby_libs = [], [], []
@mruby_includes = ["#{dir}/include"]
@rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
......@@ -113,9 +113,11 @@ __EOF__
obj_matcher = Regexp.new("^#{build_dir}/(.*)\\.o$")
{
'.c' => proc { |t| build.compile_c t.name, t.prerequisites.first, cflags },
'.cpp' => proc { |t| build.compile_cxx t.name, t.prerequisites.first, cflags },
'.m' => proc { |t| build.compile_objc t.name, t.prerequisites.first, cflags },
'.S' => proc { |t| build.compile_asm t.name, t.prerequisites.first, cflags }
'.cpp' => proc { |t| build.compile_cxx t.name, t.prerequisites.first, cxxflags },
'.cxx' => proc { |t| build.compile_cxx t.name, t.prerequisites.first, cxxflags },
'.cc' => proc { |t| build.compile_cxx t.name, t.prerequisites.first, cxxflags },
'.m' => proc { |t| build.compile_objc t.name, t.prerequisites.first, objcflags },
'.S' => proc { |t| build.compile_asm t.name, t.prerequisites.first, asmflags }
}.each do |ext, compile|
rule obj_matcher => [
proc { |file|
......@@ -147,7 +149,7 @@ __EOF__
build.compile_mruby f, rbfiles, "gem_mrblib_irep_#{funcname}" unless rbfiles.empty?
f.puts "void mrb_#{funcname}_gem_init(mrb_state *mrb);"
f.puts "void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {"
f.puts " mrb_#{funcname}_gem_init(mrb);" unless objs.empty?
f.puts " mrb_#{funcname}_gem_init(mrb);" if objs != ["#{build_dir}/gem_init.o"]
f.puts <<__EOF__ unless rbfiles.empty?
mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});
if (mrb->exc) {
......
......@@ -12,6 +12,8 @@ MRuby.each_target do |t|
{
'.c' => proc { |t| compile_c t.name, t.prerequisites.first },
'.cpp' => proc { |t| compile_cxx t.name, t.prerequisites.first },
'.cxx' => proc { |t| compile_cxx t.name, t.prerequisites.first },
'.cc' => proc { |t| compile_cxx t.name, t.prerequisites.first },
'.m' => proc { |t| compile_objc t.name, t.prerequisites.first },
'.S' => proc { |t| compile_asm t.name, t.prerequisites.first }
}.each do |ext, compile|
......
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