Bug 1406309 - add `AUTOCLOBBER` for our static-analysis targets. r=bastien
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 12 Nov 2019 14:01:46 +0000
changeset 501706 10992479f249f70907e688b5c5622deb042d9ba7
parent 501705 2f19e7b646e0a52fa855b75c868f0a3f3a990ad3
child 501707 373ebff70ac21d0a39944739b4573c3f2d30ded9
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbastien
bugs1406309
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1406309 - add `AUTOCLOBBER` for our static-analysis targets. r=bastien Differential Revision: https://phabricator.services.mozilla.com/D52169
python/mozbuild/mozbuild/code-analysis/mach_commands.py
--- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py
+++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py
@@ -30,16 +30,18 @@ from mozbuild.base import MachCommandBas
 
 from mozbuild.build_commands import Build
 from mozbuild.nodeutil import find_node_executable
 
 import mozpack.path as mozpath
 
 from mozversioncontrol import get_repository_object
 
+from mozbuild.controller.clobber import Clobberer
+
 
 # Function used to run clang-format on a batch of files. It is a helper function
 # in order to integrate into the futures ecosystem clang-format.
 def run_one_clang_format_batch(args):
     try:
         subprocess.check_output(args)
     except subprocess.CalledProcessError as e:
         return e
@@ -55,16 +57,29 @@ def map_file_to_source(abs_path, source)
         abs_path = mozpath.realpath(abs_path)
 
     # Look for abs_path in source
     if abs_path in source:
         return abs_path
     return None
 
 
+def prompt_bool(prompt, limit=5):
+    ''' Prompts the user with prompt and requires a boolean value. '''
+    from distutils.util import strtobool
+
+    for _ in range(limit):
+        try:
+            return strtobool(raw_input(prompt + "[Y/N]\n"))
+        except ValueError:
+            print("ERROR! Please enter a valid option! Please use any of the following:"
+                  " Y, N, True, False, 1, 0")
+    return False
+
+
 class StaticAnalysisSubCommand(SubCommand):
     def __call__(self, func):
         after = SubCommand.__call__(self, func)
         args = [
             CommandArgument('--verbose', '-v', action='store_true',
                             help='Print verbose output.'),
         ]
         for arg in args:
@@ -1730,17 +1745,32 @@ class StaticAnalysis(MachCommandBase):
     def _get_config_environment(self):
         ran_configure = False
         config = None
         builder = Build(self._mach_context)
 
         try:
             config = self.config_environment
         except Exception:
-            print('Looks like configure has not run yet, running it now...')
+            self.log(logging.WARNING, 'static-analysis', {},
+                     "Looks like configure has not run yet, running it now...")
+
+            clobber = Clobberer(self.topsrcdir, self.topobjdir)
+
+            if clobber.clobber_needed():
+                choice = prompt_bool(
+                    "Configuration has changed and Clobber is needed. "
+                    "Do you want to proceed?"
+                )
+                if not choice:
+                    self.log(logging.ERROR, 'static-analysis', {},
+                             "Without Clobber we cannot continue execution!")
+                    return (1, None, None)
+                os.environ["AUTOCLOBBER"] = "1"
+
             rc = builder.configure()
             if rc != 0:
                 return (rc, config, ran_configure)
             ran_configure = True
             try:
                 config = self.config_environment
             except Exception:
                 pass