Bug 1406309 - better handling of the clobber need when using 'mach static-analysis'.
MozReview-Commit-ID: 5HD5ZrknbjQ
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -2364,18 +2364,52 @@ class StaticAnalysis(MachCommandBase):
return rc
assert os.path.exists(self._compile_db)
return 0
def _build_export(self, jobs, verbose=False):
def on_line(line):
self.log(logging.INFO, 'build_output', {'line': line}, '{line}')
+ def prompt_bool(prompt, limit=5):
+ ''' Prompts the user with prompt and requires a boolean value. '''
+ from distutils.util import strtobool
+ valid = False
+ while not valid and limit > 0:
+ try:
+ choice = strtobool(raw_input(prompt + '[Y/N]\n'))
+ valid = True
+ except ValueError:
+ print("ERROR! Please enter a valid option!")
+ limit -= 1
+
+ if limit > 0:
+ return choice
+ else:
+ raise Exception(
+ "Error! Reached max attempts of entering option.")
+
builder = Build(self._mach_context)
- # First install what we can through install manifests.
+
+ # First if clobber is needed re-configure the tree.
+ from mozbuild.controller.clobber import Clobberer
+
+ clobber = Clobberer(self.topsrcdir, self.topobjdir)
+
+ if clobber.clobber_needed():
+ choice = prompt_bool(
+ '''Configuration has changed and reconfiguration is needed. Do you want to proceed?''')
+
+ if not choice:
+ return 1
+ rc = builder.configure()
+ if rc != 0:
+ return rc
+
+ # Then install what we can through install manifests.
rc = builder._run_make(directory=self.topobjdir, target='pre-export',
line_handler=None, silent=not verbose)
if rc != 0:
return rc
# Then build the rest of the build dependencies by running the full
# export target, because we can't do anything better.
return builder._run_make(directory=self.topobjdir, target='export',