diff mxtool/mx.py @ 16087:64e172733061

mx clean: delete distributions
author Bernhard Urban <bernhard.urban@jku.at>
date Thu, 12 Jun 2014 11:40:33 +0200
parents 6eef506c173d
children 1f4955abca9b
line wrap: on
line diff
--- a/mxtool/mx.py	Thu Jun 12 11:39:53 2014 +0200
+++ b/mxtool/mx.py	Thu Jun 12 11:40:33 2014 +0200
@@ -2849,6 +2849,7 @@
     parser = parser if suppliedParser else ArgumentParser(prog='mx clean')
     parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects')
     parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects')
+    parser.add_argument('--no-dist', action='store_false', dest='dist', help='do not delete distributions')
 
     args = parser.parse_args(args)
 
@@ -2858,6 +2859,10 @@
             path = unicode("\\\\?\\" + dirPath)
         shutil.rmtree(path)
 
+    def _rmIfExists(name):
+        if os.path.isfile(name):
+            os.unlink(name)
+
     for p in projects_opt_limit_to_suites():
         if p.native:
             if args.native:
@@ -2881,6 +2886,12 @@
                 if config.exists():
                     os.unlink(config.path)
 
+    if args.dist:
+        for d in _dists.keys():
+            log('Removing distribution {0}...'.format(d))
+            _rmIfExists(distribution(d).path)
+            _rmIfExists(distribution(d).sourcesPath)
+
     if suppliedParser:
         return args