1#!/usr/bin/python 2import os 3 4def purge_src(top_dir): 5 if not os.path.exists(top_dir): 6 return 7 for dir in os.listdir(top_dir): 8 if dir.startswith('.'): 9 continue 10 py = os.path.join (top_dir, dir, dir + '.py') 11 if not os.path.exists(py): 12 continue 13 ret = os.system('grep -q "preserve_srcdir = " ' + py) 14 src_path = os.path.abspath(os.path.join('tests', dir, 'src')) 15 if not os.path.exists(src_path): 16 continue 17 if ret: # This should have a replaceable src dir 18 cmd = 'rm -rf ' + src_path 19 else: 20 cmd = 'cd %s; make clean > /dev/null 2>&1 ' % src_path 21 22 print 'Cleaning %s test dir' % dir 23 os.system(cmd) 24 25if os.path.isdir('tmp'): 26 os.system('cd tmp && ls -A | xargs rm -rf') 27 28for dir in ['site_tests', 'site_profilers', 'tests', 'profilers', 'deps']: 29 purge_src(dir) 30