blob: 9cee4f5b33fec241b739df1c7e6ce482e45d5e33 [file] [log] [blame]
Derek Beckettcc2950e2022-01-04 19:35:09 -08001#!/usr/bin/python3
Derek Beckett0790b362020-11-18 13:32:38 -08002from __future__ import absolute_import
3from __future__ import division
4from __future__ import print_function
5
mbligh8fc0e5a2007-10-11 18:39:03 +00006import os
7
8def purge_src(top_dir):
mbligh94bdda02009-09-02 19:26:28 +00009 if not os.path.exists(top_dir):
10 return
jadmanski0afbb632008-06-06 21:10:57 +000011 for dir in os.listdir(top_dir):
12 if dir.startswith('.'):
13 continue
14 py = os.path.join (top_dir, dir, dir + '.py')
15 if not os.path.exists(py):
16 continue
17 ret = os.system('grep -q "preserve_srcdir = " ' + py)
18 src_path = os.path.abspath(os.path.join('tests', dir, 'src'))
19 if not os.path.exists(src_path):
20 continue
21 if ret: # This should have a replaceable src dir
22 cmd = 'rm -rf ' + src_path
23 else:
24 cmd = 'cd %s; make clean > /dev/null 2>&1 ' % src_path
mbligh8fc0e5a2007-10-11 18:39:03 +000025
Derek Beckett0790b362020-11-18 13:32:38 -080026 print('Cleaning %s test dir' % dir)
jadmanski0afbb632008-06-06 21:10:57 +000027 os.system(cmd)
mbligh8fc0e5a2007-10-11 18:39:03 +000028
mblighef8f1f32010-01-08 01:07:42 +000029if os.path.isdir('tmp'):
30 os.system('cd tmp && ls -A | xargs rm -rf')
mbligh6fd44282009-06-08 16:44:30 +000031
mbligh94bdda02009-09-02 19:26:28 +000032for dir in ['site_tests', 'site_profilers', 'tests', 'profilers', 'deps']:
jadmanski0afbb632008-06-06 21:10:57 +000033 purge_src(dir)