blob: c8c0364c0bf88eacba52c4fb513a262837d5323e [file] [log] [blame]
mbligh8fc0e5a2007-10-11 18:39:03 +00001#!/usr/bin/python
2import os
3
4def purge_src(top_dir):
mbligh94bdda02009-09-02 19:26:28 +00005 if not os.path.exists(top_dir):
6 return
jadmanski0afbb632008-06-06 21:10:57 +00007 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
mbligh8fc0e5a2007-10-11 18:39:03 +000021
mblighd0e94982009-07-11 00:15:18 +000022 print 'Cleaning %s test dir' % dir
jadmanski0afbb632008-06-06 21:10:57 +000023 os.system(cmd)
mbligh8fc0e5a2007-10-11 18:39:03 +000024
mblighef8f1f32010-01-08 01:07:42 +000025if os.path.isdir('tmp'):
26 os.system('cd tmp && ls -A | xargs rm -rf')
mbligh6fd44282009-06-08 16:44:30 +000027
mbligh94bdda02009-09-02 19:26:28 +000028for dir in ['site_tests', 'site_profilers', 'tests', 'profilers', 'deps']:
jadmanski0afbb632008-06-06 21:10:57 +000029 purge_src(dir)