mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/fiddle] Add --enable-debug-build option to extconf.rb
https://github.com/ruby/fiddle/commit/e0498e60ea
This commit is contained in:
parent
791e8eec66
commit
4d1bb460f6
Notes:
git
2021-05-18 12:49:04 +09:00
1 changed files with 41 additions and 0 deletions
|
@ -3,6 +3,47 @@ require 'mkmf'
|
|||
|
||||
# :stopdoc:
|
||||
|
||||
def gcc?
|
||||
RbConfig::CONFIG["GCC"] == "yes"
|
||||
end
|
||||
|
||||
def disable_optimization_build_flag(flags)
|
||||
if gcc?
|
||||
expanded_flags = RbConfig.expand(flags.dup)
|
||||
optimization_option_pattern = /(^|\s)?-O\d(\s|$)?/
|
||||
if optimization_option_pattern.match?(expanded_flags)
|
||||
expanded_flags.gsub(optimization_option_pattern, '\\1-Og\\2')
|
||||
else
|
||||
flags + " -Og"
|
||||
end
|
||||
else
|
||||
flags
|
||||
end
|
||||
end
|
||||
|
||||
def enable_debug_build_flag(flags)
|
||||
if gcc?
|
||||
expanded_flags = RbConfig.expand(flags.dup)
|
||||
debug_option_pattern = /(^|\s)-g(?:gdb)?\d?(\s|$)/
|
||||
if debug_option_pattern.match?(expanded_flags)
|
||||
expanded_flags.gsub(debug_option_pattern, '\\1-ggdb3\\2')
|
||||
else
|
||||
flags + " -ggdb3"
|
||||
end
|
||||
else
|
||||
flags
|
||||
end
|
||||
end
|
||||
|
||||
checking_for(checking_message("--enable-debug-build option")) do
|
||||
enable_debug_build = enable_config("debug-build", false)
|
||||
if enable_debug_build
|
||||
$CFLAGS = disable_optimization_build_flag($CFLAGS)
|
||||
$CFLAGS = enable_debug_build_flag($CFLAGS)
|
||||
end
|
||||
enable_debug_build
|
||||
end
|
||||
|
||||
libffi_version = nil
|
||||
have_libffi = false
|
||||
bundle = enable_config('bundled-libffi')
|
||||
|
|
Loading…
Reference in a new issue