Bug 1406309 - better handling of the clobber need when using 'mach static-analysis'. draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Fri, 06 Oct 2017 12:17:06 +0300
changeset 675961 37ed1ae21f6374a9458c16453cb67c070a474868
parent 675689 19b32a138d08f73961df878a29de6f0aad441683
child 734785 ba291165dee784f2b0a410dde3ce1eeac44f34d2
push id83324
push userbmo:bpostelnicu@mozilla.com
push dateFri, 06 Oct 2017 09:17:33 +0000
bugs1406309
milestone58.0a1
Bug 1406309 - better handling of the clobber need when using 'mach static-analysis'. MozReview-Commit-ID: 5HD5ZrknbjQ
python/mozbuild/mozbuild/mach_commands.py
--- 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',