Skip to content

Commit 19a3547

Browse files
committed
Strip darwin C-ext to remove paths to C files
... which are only valid in the build environment.
1 parent 5e2ac6e commit 19a3547

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ext/extconf.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,20 @@ module PG
330330
create_header()
331331
create_makefile( "pg_ext" )
332332

333+
if gem_platform
334+
# exercise the strip command on native binary gems
335+
# This approach borrowed from
336+
# https://github.com/rake-compiler/rake-compiler-dock/blob/38066d479050f4fdb3956469255b35a05e5949ef/test/rcd_test/ext/mri/extconf.rb#L97C1-L110C42
337+
strip_tool = RbConfig::CONFIG['STRIP']
338+
strip_tool += ' -x' if RUBY_PLATFORM =~ /darwin/
339+
File.open('Makefile.new', 'w') do |o|
340+
o.puts 'hijack: all strip'
341+
o.puts
342+
o.write(File.read('Makefile'))
343+
o.puts
344+
o.puts 'strip: $(DLLIB)'
345+
o.puts "\t$(ECHO) Stripping $(DLLIB)"
346+
o.puts "\t$(Q) #{strip_tool} $(DLLIB)"
347+
end
348+
File.rename('Makefile.new', 'Makefile')
349+
end

0 commit comments

Comments
 (0)