diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 3864e6c97..4a69d1b7a 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -167,9 +167,7 @@ module MRuby def enable_debug compilers.each do |c| c.defines += %w(MRB_DEBUG) - if toolchains.any? { |toolchain| toolchain == "gcc" } - c.flags += %w(-g3 -O0) - end + c.setup_debug(self) end @mrbc.compile_options += ' -g' diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb index c8a3037ee..a3b06cd07 100644 --- a/lib/mruby/build/command.rb +++ b/lib/mruby/build/command.rb @@ -172,6 +172,12 @@ module MRuby def object_ext?(path) File.extname(path) == build.exts.object end + + # This method can be redefined as a singleton method where appropriate. + # Manipulate `flags`, `include_paths` and/or more if necessary. + def setup_debug(conf) + nil + end end class Command::Linker < Command diff --git a/tasks/toolchains/gcc.rake b/tasks/toolchains/gcc.rake index aa1cf777d..675c26880 100644 --- a/tasks/toolchains/gcc.rake +++ b/tasks/toolchains/gcc.rake @@ -20,6 +20,10 @@ MRuby::Toolchain.new(:gcc) do |conf, params| compiler.cxx_compile_flag = '-x c++ -std=gnu++03' compiler.cxx_exception_flag = '-fexceptions' compiler.cxx_invalid_flags = c_mandatory_flags + cxx_invalid_flags + + def compiler.setup_debug(conf) + self.flags << %w(-g3 -O0) + end end conf.linker do |linker|