wscript 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. Example providing a clean context for when top==out.
  5. When top==out, waf will not do anything by default
  6. in the clean or distclean operations, because it is dangerous.
  7. The example below illustrates project-specific cleaning operations.
  8. Notes:
  9. - The clean operation below can only remove the generated file that
  10. are created during the current build (intermediate .o files)
  11. will not be removed
  12. - File outputs of dynamic builds cannot be removed
  13. (output files are to be known in advance)
  14. - The distclean operation, which normally removes the build folder
  15. completely plus some files, is also modified to remove
  16. the rest of waf-generated files.
  17. """
  18. VERSION='0.0.1'
  19. APPNAME='clean_test'
  20. top = '.'
  21. out = '.'
  22. def options(opt):
  23. opt.load('compiler_cxx')
  24. def configure(conf):
  25. conf.load('compiler_cxx')
  26. conf.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=False)
  27. def build(bld):
  28. bld(features='cxx', source='a.cpp', target='pouet')
  29. if bld.cmd == 'clean':
  30. for tgen in bld.get_all_task_gen():
  31. tgen.post()
  32. for t in tgen.tasks:
  33. for n in t.outputs:
  34. if n.is_child_of(bld.bldnode):
  35. n.delete()
  36. def distclean(ctx):
  37. import os, shutil
  38. from waflib import Context
  39. for fn in os.listdir('.'):
  40. if fn.startswith(('.conf_check_', ".lock-w")) \
  41. or fn in (Context.DBFILE, 'config.log') \
  42. or fn == 'c4che':
  43. if os.path.isdir(fn):
  44. shutil.rmtree(fn)
  45. else:
  46. os.remove(fn)