wscript_build 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #! /usr/bin/env python
  2. bld.shlib(
  3. source = 'test_shlib.c',
  4. target = 'my_shared_lib',
  5. name = 'xyz',
  6. vnum = '1.2.3',
  7. defs = 'foo.def')
  8. t = bld.program(
  9. #features = 'my_precious',
  10. source = 'main.c',
  11. target = 'test_shared_link',
  12. use = 'xyz',
  13. # 1. settings flags directly
  14. #linkflags = ['-L/disk/comp/waf/demos/c/build/shlib', '-lmy_shared_lib']
  15. )
  16. # 2. another way of setting flags
  17. #t.env.linkflags = ['-L/disk/comp/waf/demos/c/build/shlib', '-lmy_shared_lib']
  18. # 3. advanced flag control through 'feature' methods (standard practice when 1. or 2. is not enough)
  19. #import sys
  20. #from waflib import TaskGen
  21. #@TaskGen.feature('my_precious')
  22. #@TaskGen.after_method('apply_link', 'propagate_uselib_vars')
  23. #def set_flags(self):
  24. # if sys.platform == 'linux2':
  25. # self.link_task.env.LINKFLAGS = ['-Lshlib', '--whole-archive', '-lmy_shared_lib']
  26. # self.link_task.env.LIB = []
  27. # self.link_task.env.STLIB = []
  28. # self.link_task.env.STLIB_MARKER = []
  29. # 4. changing the class - setting flags such as LINKFLAGS_cshlib is usually a much better idea
  30. #from waflib.Utils import run_once
  31. #from waflib.Tools.c import cprogram
  32. #class cprogram(cprogram):
  33. # def runnable_status(self):
  34. # self.set_flags()
  35. # self.set_flags() # just to see
  36. # return super(cprogram, self).runnable_status()
  37. # @run_once
  38. # def set_flags(self):
  39. # self.env.append_value('LINKFLAGS', ['-g'])