waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

strip.py (987B)


      1 #! /usr/bin/env python
      2 
      3 """
      4 Strip a program/library after it is created.
      5 
      6 Since creating the file and modifying it occurs in the same
      7 task, there will be no race condition with other tasks dependent
      8 on the output.
      9 
     10 For other implementation possibilities, see strip_hack.py and strip_on_install.py
     11 """
     12 
     13 from waflib import Task
     14 
     15 def configure(conf):
     16 	conf.find_program('strip')
     17 
     18 def wrap_compiled_task(classname):
     19 	# override the class to add a new 'run' method
     20 	# such an implementation guarantees that the absence of race conditions
     21 	#
     22 	cls1 = Task.classes[classname]
     23 	cls2 = type(classname, (cls1,), {'run_str': '${STRIP} ${TGT[0].abspath()}'})
     24 	cls3 = type(classname, (cls2,), {})
     25 
     26 	def run_all(self):
     27 		if self.env.NO_STRIPPING:
     28 			return cls1.run(self)
     29 		ret = cls1.run(self)
     30 		if ret:
     31 			return ret
     32 		return cls2.run(self)
     33 	cls3.run = run_all
     34 
     35 for k in 'cprogram cshlib cxxprogram cxxshlib fcprogram fcshlib dprogram dshlib'.split():
     36 	if k in Task.classes:
     37 		wrap_compiled_task(k)
     38