wscript_build 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #! /usr/bin/env python
  2. def write_header(tsk):
  3. tsk.outputs[0].write('int abc = 423;\n')
  4. bld(features='use', rule=write_header, target='b.h', ext_out=['.h'], name='XYZ')
  5. tg = bld.program(
  6. features = 'aaa',
  7. source = 'main.c',
  8. includes = '. ..',
  9. #cflags = ['-O3'], # for example
  10. defines = ['foo=bar'],
  11. target = 'myprogram',
  12. use = 'M XYZ')
  13. # just for fun, make main.c depend on wscript_build
  14. bld.add_manual_dependency('main.c', bld.path.find_resource('wscript_build'))
  15. # ----------------------------------------
  16. from waflib import TaskGen
  17. @TaskGen.feature('aaa')
  18. @TaskGen.before('apply_link')
  19. def add_one_task(self):
  20. """this is a task generator method, it is bound to the feature 'aaa' """
  21. tsk = self.create_task('foo')
  22. tsk.outputs = [self.bld.path.find_or_declare('abc.h')]
  23. import waflib.Task
  24. class foo(waflib.Task.Task):
  25. """this is a task class"""
  26. before = ['c']
  27. color = 'BLUE'
  28. def run(self):
  29. self.outputs[0].write('int kik = 343;\n')
  30. if bld.env.CC_NAME == 'msvc':
  31. tg.source += ' msvc_resource.rc'