wscript 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /usr/bin/env python3
  2. from waflib import Utils
  3. top = '.'
  4. out = 'bin'
  5. def options(opt):
  6. opt.load('compiler_c')
  7. def configure(conf):
  8. conf.load('compiler_c')
  9. def build(bld):
  10. bld(rule='echo hi')
  11. bld(rule='touch ${TGT}', target='foo.txt')
  12. bld(rule='touch ${TGT}', target='aaa')
  13. t = bld(rule='touch ${TGT}', target='bbb', source='aaa')
  14. t = bld(rule='touch ${TGT}', target='ccc', source='bbb')
  15. t = bld(rule='touch ${TGT}', target='ddd', source='ccc')
  16. t = bld(rule=('touch ${TGT}', 'touch ${TGT}'), target='eee', source='ddd', chmod=Utils.O755)
  17. t.create_task('foo')
  18. #print( 'path from srcnode', bld.path.find_or_declare('aaa').path_from(bld.bldnode) )
  19. # folders as nodes are best avoided
  20. dnode = bld.path.get_bld().make_node('testdir')
  21. bld(rule='mkdir -p ${TGT}', target=dnode)
  22. bld(rule='touch ${TGT}', source=dnode, target=dnode.make_node('stuff'), cls_str=lambda x: 'stuff')
  23. bld.install_files('/tmp/bar', 'wscript')
  24. bld(features='c cprogram', source='main.c', target='app')
  25. def init(self):
  26. print('init')
  27. def shutdown(self):
  28. print('shutdown')
  29. def bar(ctx):
  30. print("command ok")
  31. from waflib import Task
  32. class foo(Task.Task):
  33. always_run = True
  34. def run(self):
  35. print("running foo")
  36. print("classes", Task.classes)
  37. #-----------------------------------------------
  38. # variant example below
  39. # call "../waf debug"
  40. #
  41. import os
  42. from waflib import Build, Options
  43. class debug_context(Build.BuildContext):
  44. cmd = 'debug'
  45. fun = 'build'
  46. variant = 'test'
  47. def __init__(self, start=None):
  48. Build.BuildContext.__init__(self, start=start)
  49. # looks evil
  50. #def debug(bld):
  51. # build(bld)