@@ -22,6 +22,10 @@ def configure(conf):
2222 conf .find_program ('strip' , var = 'STRIP' )
2323 if not conf .env .STRIPFLAGS :
2424 conf .env .STRIPFLAGS = os .environ ['STRIPFLAGS' ] if 'STRIPFLAGS' in os .environ else []
25+
26+ if conf .env .DEST_BINFMT == 'mac-o' :
27+ conf .env .STRIPFLAGS += ['-x' ]
28+ return # macOS don't have objcopy
2529
2630 # a1ba: I am lazy to add `export OBJCOPY=` everywhere in my scripts
2731 # so just try to deduce which objcopy we have
@@ -47,26 +51,26 @@ def copy_fun(self, src, tgt):
4751
4852 if getattr (self .generator , 'link_task' , None ) and self .generator .link_task .outputs [0 ] in self .inputs :
4953 tgt_debug = tgt + '.debug'
50- strip_cmd = self .env .STRIP + self .env .STRIPFLAGS + [tgt ]
51- ocopy_cmd = self .env .OBJCOPY + ['--only-keep-debug' , tgt , tgt_debug ]
52- ocopy_debuglink_cmd = self .env .OBJCOPY + ['--add-gnu-debuglink=%s' % tgt_debug , tgt ]
5354 c1 = Logs .colors .NORMAL
5455 c2 = Logs .colors .CYAN
5556 c3 = Logs .colors .YELLOW
5657 c4 = Logs .colors .BLUE
5758 try :
58- if self .generator .bld .options .strip_to_file :
59+ if self .generator .bld .options .strip_to_file and self .env .DEST_BINFMT == 'elf' :
60+ ocopy_cmd = self .env .OBJCOPY + ['--only-keep-debug' , tgt , tgt_debug ]
5961 self .generator .bld .cmd_and_log (ocopy_cmd , output = Context .BOTH , quiet = Context .BOTH )
6062 if not self .generator .bld .progress_bar :
6163 Logs .info ('%s+ objcopy --only-keep-debug %s%s%s %s%s%s' , c1 , c4 , tgt , c1 , c3 , tgt_debug , c1 )
6264
65+ strip_cmd = self .env .STRIP + self .env .STRIPFLAGS + [tgt ]
6366 self .generator .bld .cmd_and_log (strip_cmd , output = Context .BOTH , quiet = Context .BOTH )
6467 if not self .generator .bld .progress_bar :
6568 f1 = os .path .getsize (src )
6669 f2 = os .path .getsize (tgt )
6770 Logs .info ('%s+ strip %s%s%s (%d bytes change)' , c1 , c2 , tgt , c1 , f2 - f1 )
6871
69- if self .generator .bld .options .strip_to_file :
72+ if self .generator .bld .options .strip_to_file and self .env .DEST_BINFMT == 'elf' :
73+ ocopy_debuglink_cmd = self .env .OBJCOPY + ['--add-gnu-debuglink=%s' % tgt_debug , tgt ]
7074 self .generator .bld .cmd_and_log (ocopy_debuglink_cmd , output = Context .BOTH , quiet = Context .BOTH )
7175 if not self .generator .bld .progress_bar :
7276 Logs .info ('%s+ objcopy --add-gnu-debuglink=%s%s%s %s%s%s' , c1 , c3 , tgt_debug , c1 , c2 , tgt , c1 )
0 commit comments