waf/playground/strip/strip.py

39 lines
987 B
Python
Raw Normal View History

2011-09-10 11:13:51 +02:00
#! /usr/bin/env python
"""
Strip a program/library after it is created.
2011-09-10 11:13:51 +02:00
Since creating the file and modifying it occurs in the same
task, there will be no race condition with other tasks dependent
on the output.
2011-09-10 11:13:51 +02:00
For other implementation possibilities, see strip_hack.py and strip_on_install.py
2011-09-10 11:13:51 +02:00
"""
2016-08-13 18:51:55 +02:00
from waflib import Task
2011-09-10 11:13:51 +02:00
def configure(conf):
conf.find_program('strip')
2016-08-13 18:51:55 +02:00
def wrap_compiled_task(classname):
# override the class to add a new 'run' method
# such an implementation guarantees that the absence of race conditions
#
2016-08-13 18:55:12 +02:00
cls1 = Task.classes[classname]
cls2 = type(classname, (cls1,), {'run_str': '${STRIP} ${TGT[0].abspath()}'})
cls3 = type(classname, (cls2,), {})
2016-08-13 18:51:55 +02:00
def run_all(self):
if self.env.NO_STRIPPING:
return cls1.run(self)
2016-08-15 19:44:23 +02:00
ret = cls1.run(self)
if ret:
return ret
return cls2.run(self)
2016-08-13 18:55:12 +02:00
cls3.run = run_all
2016-08-13 18:51:55 +02:00
2016-08-13 18:55:12 +02:00
for k in 'cprogram cshlib cxxprogram cxxshlib fcprogram fcshlib dprogram dshlib'.split():
2016-08-13 18:51:55 +02:00
if k in Task.classes:
wrap_compiled_task(k)
2016-08-13 18:21:08 +02:00