diff --git a/Rakefile b/Rakefile index 6a04ef87cb3bbef7448e27d3299e990500fcf49e..ac2d43ae5ac24e69ba24074485cc838aa16ab0e8 100644 --- a/Rakefile +++ b/Rakefile @@ -8,8 +8,17 @@ load 'tasks/mrbgem_spec.rake' ############################## # compile flags -MRUBY_CONFIG = File.expand_path(ENV['MRUBY_CONFIG'] || './build_config.rb') -load MRUBY_CONFIG +load 'build_config.rb' + +MRUBY_CONFIGS = ['build_config.rb'] +if ENV['MRUBY_CONFIG'] + MRUBY_CONFIGS << ENV['MRUBY_CONFIG'] + load ENV['MRUBY_CONFIG'] +end + +MRuby.each_target do |build| + build.define_rules +end load 'src/mruby_core.rake' load 'mrblib/mrblib.rake' @@ -34,7 +43,7 @@ depfiles = MRuby.targets['host'].bins.map do |bin| FileUtils.rm t.name, :force => true FileUtils.cp t.prerequisites.first, t.name end - + install_path end diff --git a/build_config.rb b/build_config.rb index eeaa255ab5a05a45ce444cbba59ec3d554ed2b7f..12cf0affd8d13890ed989f3927655b93cb3e277d 100644 --- a/build_config.rb +++ b/build_config.rb @@ -74,5 +74,5 @@ end # conf.cc.flags << "-m32" # conf.linker.flags << "-m32" # -# conf.gem 'examples/mrbgems/c_and_ruby_extension_example' +# conf.gem 'doc/mrbgems/c_and_ruby_extension_example' # end diff --git a/src/vm.c b/src/vm.c index ca31f667502497185474fb3c9d8d9502b35346f6..021fc2c90cdb2af53c344ecc241bb908147d7ccb 100644 --- a/src/vm.c +++ b/src/vm.c @@ -477,7 +477,7 @@ argnum_error(mrb_state *mrb, int num) mrb->exc = (struct RObject*)mrb_object(exc); } -#ifdef __GNUC__ +#ifdef __GNUC__dummy #define DIRECT_THREADED #endif diff --git a/tasks/mrbgem_spec.rake b/tasks/mrbgem_spec.rake index 0e228629ba402d9479b604ef06cbea64d8cfc9a5..5a28053b59656c377f90e85f0c4abf8cd28a4434 100644 --- a/tasks/mrbgem_spec.rake +++ b/tasks/mrbgem_spec.rake @@ -35,7 +35,6 @@ module MRuby def setup MRuby::Gem.current = self - @build.compilers.each do |compiler| compiler.defines -= %w(DISABLE_GEMS) compiler.include_paths << "#{dir}/include" diff --git a/tasks/mrbgems.rake b/tasks/mrbgems.rake index 9d8798ef30b9b4b3a7369eca48a8fcf6a2fde29a..285aa75b81de759f1bf23bde3203cd7ab5040d3d 100644 --- a/tasks/mrbgems.rake +++ b/tasks/mrbgems.rake @@ -8,7 +8,7 @@ MRuby.each_target do # loader all gems self.libmruby << objfile("#{build_dir}/mrbgems/gem_init") file objfile("#{build_dir}/mrbgems/gem_init") => "#{build_dir}/mrbgems/gem_init.c" - file "#{build_dir}/mrbgems/gem_init.c" => [MRUBY_CONFIG] do |t| + file "#{build_dir}/mrbgems/gem_init.c" => [MRUBY_CONFIGS].flatten do |t| FileUtils.mkdir_p "#{build_dir}/mrbgems" open(t.name, 'w') do |f| f.puts %Q[/*] diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake index cd9f77fc48cb17fd8a7516557f33358a89433991..2962e167a41033a95c4111c38ca354fb7fab7987 100644 --- a/tasks/mruby_build.rake +++ b/tasks/mruby_build.rake @@ -53,39 +53,37 @@ module MRuby Exts = Struct.new(:object, :executable, :library) def initialize(name='host', &block) - MRuby::Build.current = self - @name = name - @root = File.expand_path("#{File.dirname(__FILE__)}/..") + @name = name.to_s - if ENV['OS'] == 'Windows_NT' - @exts = Exts.new('.o', '.exe', '.a') - else - @exts = Exts.new('.o', '', '.a') - end - - @file_separator = '/' - @cc = Command::Compiler.new(self, %w(.c)) - @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp)) - @objc = Command::Compiler.new(self, %w(.m)) - @asm = Command::Compiler.new(self, %w(.S .asm)) - @linker = Command::Linker.new(self) - @archiver = Command::Archiver.new(self) - @yacc = Command::Yacc.new(self) - @gperf = Command::Gperf.new(self) - @git = Command::Git.new(self) - @mrbc = Command::Mrbc.new(self) - - @bins = %w(mruby mrbc mirb) - @gems, @libmruby = [], [] + unless MRuby.targets[@name] + @root = File.expand_path("#{File.dirname(__FILE__)}/..") - MRuby.targets[name.to_s] = self - - instance_eval(&block) + if ENV['OS'] == 'Windows_NT' + @exts = Exts.new('.o', '.exe', '.a') + else + @exts = Exts.new('.o', '', '.a') + end - compilers.each do |compiler| - compiler.defines -= %w(DISABLE_GEMS) if respond_to?(:enable_gems?) && enable_gems? - compiler.define_rules build_dir + @file_separator = '/' + @cc = Command::Compiler.new(self, %w(.c)) + @cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp)) + @objc = Command::Compiler.new(self, %w(.m)) + @asm = Command::Compiler.new(self, %w(.S .asm)) + @linker = Command::Linker.new(self) + @archiver = Command::Archiver.new(self) + @yacc = Command::Yacc.new(self) + @gperf = Command::Gperf.new(self) + @git = Command::Git.new(self) + @mrbc = Command::Mrbc.new(self) + + @bins = %w(mruby mrbc mirb) + @gems, @libmruby = [], [] + + MRuby.targets[@name] = self end + + MRuby::Build.current = MRuby.targets[@name] + MRuby.targets[@name].instance_eval(&block) end def toolchain(name) @@ -108,6 +106,13 @@ module MRuby end end + def define_rules + compilers.each do |compiler| + compiler.defines -= %w(DISABLE_GEMS) if respond_to?(:enable_gems?) && enable_gems? + compiler.define_rules build_dir + end + end + def filename(name) if name.is_a?(Array) name.flatten.map { |n| filename(n) } diff --git a/tasks/mruby_build_commands.rake b/tasks/mruby_build_commands.rake index 20203ad7e0e444d2746b224a54006e40bc5c75bb..98a2169205e976c038586a738c74f13e0988b777 100644 --- a/tasks/mruby_build_commands.rake +++ b/tasks/mruby_build_commands.rake @@ -36,14 +36,14 @@ module MRuby def initialize(build, source_exts=[]) super(build) - @command = ENV['CC'] || 'gcc' + @command = ENV['CC'] || 'cc' @flags = [ENV['CFLAGS'] || []] @source_exts = source_exts @include_paths = ["#{build.root}/include"] @defines = %w(DISABLE_GEMS) @option_include_path = '-I%s' @option_define = '-D%s' - @compile_options = "%{flags} -MMD -o %{outfile} -c %{infile}" + @compile_options = '%{flags} -o %{outfile} -c %{infile}' end def all_flags(_defineds=[], _include_paths=[], _flags=[]) @@ -111,7 +111,7 @@ module MRuby def initialize(build) super - @command = ENV['LD'] || 'gcc' + @command = ENV['LD'] || 'ld' @flags = (ENV['LDFLAGS'] || []) @flags_before_libraries, @flags_after_libraries = [], [] @libraries = [] diff --git a/tasks/toolchains/clang.rake b/tasks/toolchains/clang.rake index 1785c4c79669e40d084d5ac3235a489f5f819b41..d5d2ccd7cdda1f1b60176b93b2e966ab8cf8c522 100644 --- a/tasks/toolchains/clang.rake +++ b/tasks/toolchains/clang.rake @@ -1,7 +1,7 @@ MRuby::Toolchain.new(:clang) do |conf| toolchain :gcc - [conf.cc, conf.cxx, conf.objc].each do |cc| + [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc| cc.command = ENV['CC'] || 'clang' end conf.linker.command = ENV['LD'] || 'clang' diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index 2c160683de20b16248cc6242b7cfa64b5fd97a23..bef9b8618428dc9a08bc04571d0f3400e42a2adf 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -1,5 +1,5 @@ MRuby::Toolchain.new(:gcc) do |conf| - [conf.cc, conf.cxx, conf.objc].each do |cc| + [conf.cc, conf.cxx, conf.objc, conf.asm].each do |cc| cc.command = ENV['CC'] || 'gcc' cc.flags = [ENV['CFLAGS'] || %w(-g -O3 -Wall -Werror-implicit-function-declaration)] cc.include_paths = ["#{root}/include"]