strip.py 987 B

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