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