diff options
author | Sutou Kouhei <[email protected]> | 2021-01-03 06:17:56 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-05-18 12:48:40 +0900 |
commit | 4d1bb460f64eafacc2ef8c4116a1bbe7e63e732f (patch) | |
tree | 925585931392a66c440223800bb1b8f19570328e /ext | |
parent | 791e8eec66d3aebcee36c1369b0bf52bc3815e94 (diff) |
[ruby/fiddle] Add --enable-debug-build option to extconf.rb
https://github.com/ruby/fiddle/commit/e0498e60ea
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4506
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fiddle/extconf.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 6d1d5104a1..562b758bda 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -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') |