wscript 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2006-2010 (ita)
  4. VERSION='0.0.1'
  5. APPNAME='cc_test'
  6. top = '.'
  7. import waflib.Configure
  8. waflib.Configure.autoconfig = True
  9. def options(opt):
  10. opt.load('compiler_c')
  11. def configure(conf):
  12. conf.load('compiler_c')
  13. def build(bld):
  14. bld(rule='echo "int ko = $$RANDOM;" > ${TGT}', target='faa.h', always=True, shell=True, name='z2')
  15. bld.program(source='a.c main.c', target='foo', includes='.')
  16. # sort the tasks in reverse order to force the 'faa.h' creation in last position
  17. from waflib import Task, Errors, Logs
  18. old = Task.set_file_constraints
  19. def meth(lst):
  20. try:
  21. lst.sort(cmp=lambda x, y: cmp(x.__class__.__name__, y.__class__.__name__))
  22. except:
  23. lst.sort(key=lambda x: x.__class__.__name__) # python3
  24. old(lst)
  25. Task.set_file_constraints = meth
  26. def are_implicit_nodes_ready(self):
  27. """remove this method if/when the main one is enabled"""
  28. bld = self.generator.bld
  29. try:
  30. cache = bld.dct_implicit_nodes
  31. except:
  32. bld.dct_implicit_nodes = cache = {}
  33. try:
  34. dct = cache[bld.current_group]
  35. except KeyError:
  36. dct = cache[bld.current_group] = {}
  37. for tsk in bld.cur_tasks:
  38. for x in tsk.outputs:
  39. dct[x] = tsk
  40. modified = False
  41. for x in bld.node_deps.get(self.uid(), []):
  42. if x in dct:
  43. self.run_after.add(dct[x])
  44. modified = True
  45. if modified:
  46. for tsk in self.run_after:
  47. if not tsk.hasrun:
  48. Logs.warn('task %r is not ready...', self)
  49. raise Errors.TaskNotReady('not ready')
  50. Task.Task.are_implicit_nodes_ready = are_implicit_nodes_ready