--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -568,51 +568,16 @@ class Build(MachCommandBase):
try:
browser = webbrowser.get().open_new_tab(server.url)
except Exception:
print('Please open %s in a browser.' % server.url)
print('Hit CTRL+c to stop server.')
server.run()
- CLOBBER_CHOICES = ['objdir', 'python']
- @Command('clobber', category='build',
- description='Clobber the tree (delete the object directory).')
- @CommandArgument('what', default=['objdir'], nargs='*',
- help='Target to clobber, must be one of {{{}}} (default objdir).'.format(
- ', '.join(CLOBBER_CHOICES)))
- def clobber(self, what):
- invalid = set(what) - set(self.CLOBBER_CHOICES)
- if invalid:
- print('Unknown clobber target(s): {}'.format(', '.join(invalid)))
- return 1
-
- ret = 0
- if 'objdir' in what:
- try:
- self.remove_objdir()
- except OSError as e:
- if sys.platform.startswith('win'):
- if isinstance(e, WindowsError) and e.winerror in (5,32):
- self.log(logging.ERROR, 'file_access_error', {'error': e},
- "Could not clobber because a file was in use. If the "
- "application is running, try closing it. {error}")
- return 1
- raise
-
- if 'python' in what:
- if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')):
- cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]']
- elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')):
- cmd = ['git', 'clean', '-f', '-x', '*.py[co]']
- else:
- cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete']
- ret = subprocess.call(cmd, cwd=self.topsrcdir)
- return ret
-
@Command('build-backend', category='build',
description='Generate a backend used to build the tree.')
@CommandArgument('-d', '--diff', action='store_true',
help='Show a diff of changes.')
# It would be nice to filter the choices below based on
# conditions, but that is for another day.
@CommandArgument('-b', '--backend', nargs='+', choices=sorted(backends),
help='Which backend to build.')
@@ -653,16 +618,54 @@ class Doctor(MachCommandBase):
help='Attempt to fix found problems.')
def doctor(self, fix=None):
self._activate_virtualenv()
from mozbuild.doctor import Doctor
doctor = Doctor(self.topsrcdir, self.topobjdir, fix)
return doctor.check_all()
@CommandProvider
+class Clobber(MachCommandBase):
+ NO_AUTO_LOG = True
+ CLOBBER_CHOICES = ['objdir', 'python']
+ @Command('clobber', category='build',
+ description='Clobber the tree (delete the object directory).')
+ @CommandArgument('what', default=['objdir'], nargs='*',
+ help='Target to clobber, must be one of {{{}}} (default objdir).'.format(
+ ', '.join(CLOBBER_CHOICES)))
+ def clobber(self, what):
+ invalid = set(what) - set(self.CLOBBER_CHOICES)
+ if invalid:
+ print('Unknown clobber target(s): {}'.format(', '.join(invalid)))
+ return 1
+
+ ret = 0
+ if 'objdir' in what:
+ try:
+ self.remove_objdir()
+ except OSError as e:
+ if sys.platform.startswith('win'):
+ if isinstance(e, WindowsError) and e.winerror in (5,32):
+ self.log(logging.ERROR, 'file_access_error', {'error': e},
+ "Could not clobber because a file was in use. If the "
+ "application is running, try closing it. {error}")
+ return 1
+ raise
+
+ if 'python' in what:
+ if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')):
+ cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]']
+ elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')):
+ cmd = ['git', 'clean', '-f', '-x', '*.py[co]']
+ else:
+ cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete']
+ ret = subprocess.call(cmd, cwd=self.topsrcdir)
+ return ret
+
+@CommandProvider
class Logs(MachCommandBase):
"""Provide commands to read mach logs."""
NO_AUTO_LOG = True
@Command('show-log', category='post-build',
description='Display mach logs')
@CommandArgument('log_file', nargs='?', type=argparse.FileType('rb'),
help='Filename to read log data from. Defaults to the log of the last '