Skip to content

Commit

Permalink
Generate dSYM debug information for MRI extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Mar 27, 2021
1 parent d7441d2 commit 4bb2856
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
7 changes: 6 additions & 1 deletion lib/mkmf.rb
Expand Up @@ -2038,14 +2038,15 @@ def configuration(srcdir)
ruby_headers = #{headers.join(' ')}
RM = #{config_string('RM', &possible_command) || '$(RUBY) -run -e rm -- -f'}
RM_RF = #{'$(RUBY) -run -e rm -- -rf'}
RM_RF = #{config_string('RMALL', &possible_command) || '$(RUBY) -run -e rm -- -rf'}
RMDIRS = #{config_string('RMDIRS', &possible_command) || '$(RUBY) -run -e rmdir -- -p'}
MAKEDIRS = #{config_string('MAKEDIRS', &possible_command) || '@$(RUBY) -run -e mkdir -- -p'}
INSTALL = #{config_string('INSTALL', &possible_command) || '@$(RUBY) -run -e install -- -vp'}
INSTALL_PROG = #{config_string('INSTALL_PROG') || '$(INSTALL) -m 0755'}
INSTALL_DATA = #{config_string('INSTALL_DATA') || '$(INSTALL) -m 0644'}
COPY = #{config_string('CP', &possible_command) || '@$(RUBY) -run -e cp -- -v'}
TOUCH = exit >
POSTLINK = #{config_string('POSTLINK')}
#### End of system configuration section. ####
Expand Down Expand Up @@ -2382,6 +2383,9 @@ def create_makefile(target, srcprefix = nil)
if defined?($installed_list)
mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n"
end
unless CONFIG['dsymutil'].to_s.empty?
mfile.print "\tcp -r #{f}.dSYM/ #{dir}/$(DLLIB).dSYM/\n"
end
end
mfile.print "clean-static::\n"
mfile.print "\t-$(Q)$(RM) $(STATIC_LIB)\n"
Expand Down Expand Up @@ -2764,6 +2768,7 @@ def MAIN_DOES_NOTHING(*refs)
clean-so::
clean: clean-so clean-static clean-rb-default clean-rb
\t\t-$(Q)$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep}) .*.time
\t\t-$(Q)$(RM_RF) *.dSYM
distclean-rb-default::
distclean-rb::
Expand Down
2 changes: 1 addition & 1 deletion template/Makefile.in
Expand Up @@ -477,7 +477,7 @@ clean-local::
enc/encinit.c enc/encinit.$(OBJEXT) $(pkgconfig_DATA) \
ruby-runner.$(OBJEXT) ruby-runner.h \
|| $(NULLCMD)
-$(Q)$(RMALL) exe/ *.dSYM
-$(Q)$(RMALL) exe/ *.dSYM $(EXTOUT)/$(arch)/*.dSYM

distclean-local::
$(Q)$(RM) \
Expand Down
22 changes: 9 additions & 13 deletions test/rubygems/test_gem_installer.rb
Expand Up @@ -1422,11 +1422,7 @@ def test_find_lib_file_after_install
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
require "mkmf"
CONFIG['CC'] = '$(TOUCH) $@ ||'
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
$ruby = '#{Gem.ruby}'
$LIBPATH << #{@current_dir.dump} # to link with libruby without needing it installed
create_makefile("#{@spec.name}")
RUBY
end
Expand All @@ -1435,7 +1431,6 @@ def test_find_lib_file_after_install

write_file File.join(@tempdir, "a.c") do |io|
io.write <<-C
#include <ruby.h>
void Init_a() { }
C
end
Expand Down Expand Up @@ -1508,22 +1503,23 @@ def test_install_extension_flat
@spec.require_paths = ["."]

@spec.extensions << "extconf.rb"
@spec.files += %W[depend #{@spec.name}.c]

write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
require "mkmf"
CONFIG['CC'] = '$(TOUCH) $@ ||'
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
$ruby = '#{Gem.ruby}'
$LIBPATH << #{@current_dir.dump} # to link with libruby without needing it installed
create_makefile("#{@spec.name}")
RUBY
end

# empty depend file for no auto dependencies
@spec.files += %W[depend #{@spec.name}.c].each do |file|
write_file File.join(@tempdir, file)
write_file File.join(@tempdir, "depend")

write_file File.join(@tempdir, "#{@spec.name}.c") do |io|
io.write <<-C
void Init_#{@spec.name}() { }
C
end

so = File.join(@spec.gem_dir, "#{@spec.name}.#{RbConfig::CONFIG["DLEXT"]}")
Expand Down

0 comments on commit 4bb2856

Please sign in to comment.