wscript 877 B

1234567891011121314151617181920212223242526272829303132333435
  1. #! /usr/bin/env python
  2. # coding: utf-8
  3. def options(opt):
  4. opt.load('compiler_c')
  5. def configure(cnf):
  6. cnf.load('compiler_c')
  7. def build(bld):
  8. from waflib import Build
  9. bld.post_mode = Build.POST_LAZY
  10. def create_files(tsk):
  11. out = tsk.generator.path.make_node('generated')
  12. from waflib import Utils
  13. for x in out.ant_glob('*.c'):
  14. x.delete()
  15. import random
  16. for x in range(2):
  17. num = random.randint(0, 2**31)
  18. k = out.make_node('test%d.c' % num)
  19. k.write('int k%d = %d;' % (num, num))
  20. bld(rule=create_files, source='wscript', name='codegen')
  21. bld.add_group()
  22. bld.program(features='find_them', source=['main.c'], target='app')
  23. from waflib.TaskGen import feature, before
  24. from waflib import Utils
  25. @feature('find_them')
  26. @before('process_source')
  27. def list_the_source_files(self):
  28. self.source = Utils.to_list(self.source) + self.path.ant_glob('generated/*.c')