Bug 1414781 - Rename some stuffs from clang-tidy to clang-toolchain as we are using it also for clang-format now r?glandium draft
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 06 Nov 2017 10:50:10 +0100
changeset 693490 bf0811f22c860332a8d61a9158377e0ab0e0213b
parent 693376 179dae92e4d794e7f45ad080ff01908c80691f31
child 693491 dbc12baecae763ddf3979d0032fcbafcf7976abf
push id87829
push userbmo:sledru@mozilla.com
push dateMon, 06 Nov 2017 11:10:24 +0000
reviewersglandium
bugs1414781
milestone58.0a1
Bug 1414781 - Rename some stuffs from clang-tidy to clang-toolchain as we are using it also for clang-format now r?glandium In the future, we should also rename the tc job MozReview-Commit-ID: 8zzM0UlQN5o
python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -2218,17 +2218,17 @@ class StaticAnalysis(MachCommandBase):
         rc = self._build_compile_db(verbose=verbose)
         if rc != 0:
             return rc
 
         rc = self._build_export(jobs=jobs, verbose=verbose)
         if rc != 0:
             return rc
 
-        rc = self._get_clang_tidy(verbose=verbose)
+        rc = self._get_clang_toolchain(verbose=verbose)
         if rc != 0:
             return rc
 
         python = self.virtualenv_manager.python_path
 
         if checks == '-*':
             checks = self._get_checks()
 
@@ -2283,36 +2283,36 @@ class StaticAnalysis(MachCommandBase):
                           'Can be omitted, in which case the latest clang-tidy '
                           ' helper for the platform would be automatically '
                           'detected and installed.')
     @CommandArgument('--skip-cache', action='store_true',
                      help='Skip all local caches to force re-fetching the helper tool.',
                      default=False)
     def install(self, source=None, skip_cache=False, verbose=False):
         self._set_log_level(verbose)
-        rc = self._get_clang_tidy(force=True, skip_cache=skip_cache,
+        rc = self._get_clang_toolchain(force=True, skip_cache=skip_cache,
                                   source=source, verbose=verbose)
         return rc
 
     @StaticAnalysisSubCommand('static-analysis', 'clear-cache',
                               'Delete local helpers and reset static analysis helper tool cache')
     def clear_cache(self, verbose=False):
         self._set_log_level(verbose)
-        rc = self._get_clang_tidy(force=True, download_if_needed=False,
+        rc = self._get_clang_toolchain(force=True, download_if_needed=False,
                                   verbose=verbose)
         if rc != 0:
             return rc
 
         self._artifact_manager.artifact_clear_cache()
 
     @StaticAnalysisSubCommand('static-analysis', 'print-checks',
                               'Print a list of the static analysis checks performed by default')
     def print_checks(self, verbose=False):
         self._set_log_level(verbose)
-        rc = self._get_clang_tidy(verbose=verbose)
+        rc = self._get_clang_toolchain(verbose=verbose)
         if rc != 0:
             return rc
         args = [self._clang_tidy_path, '-list-checks', '-checks=-*,mozilla-*']
         return self._run_command_in_objdir(args=args, pass_thru=True)
 
     def _get_checks(self):
         checks = '-*'
         import yaml
@@ -2385,53 +2385,53 @@ class StaticAnalysis(MachCommandBase):
             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',
                                  line_handler=None, silent=not verbose,
                                  num_jobs=jobs)
 
-    def _get_clang_tidy(self, force=False, skip_cache=False,
+    def _get_clang_toolchain(self, force=False, skip_cache=False,
                         source=None, download_if_needed=True,
                         verbose=False):
         rc, config, _ = self._get_config_environment()
 
         if rc != 0:
             return rc
 
-        clang_tidy_path = mozpath.join(self._mach_context.state_dir,
+        clang_toolchain_path = mozpath.join(self._mach_context.state_dir,
                                        "clang-tidy")
-        self._clang_tidy_path = mozpath.join(clang_tidy_path, "clang", "bin",
+        self._clang_tidy_path = mozpath.join(clang_toolchain_path, "clang", "bin",
                                              "clang-tidy" + config.substs.get('BIN_SUFFIX', ''))
-        self._clang_apply_replacements = mozpath.join(clang_tidy_path, "clang", "bin",
+        self._clang_apply_replacements = mozpath.join(clang_toolchain_path, "clang", "bin",
                                                       "clang-apply-replacements" + config.substs.get('BIN_SUFFIX', ''))
-        self._run_clang_tidy_path = mozpath.join(clang_tidy_path, "clang", "share",
+        self._run_clang_tidy_path = mozpath.join(clang_toolchain_path, "clang", "share",
                                                  "clang", "run-clang-tidy.py")
 
         if os.path.exists(self._clang_tidy_path) and \
            os.path.exists(self._clang_apply_replacements) and \
            os.path.exists(self._run_clang_tidy_path) and \
            not force:
             return 0
         else:
-            if os.path.isdir(clang_tidy_path) and download_if_needed:
+            if os.path.isdir(clang_toolchain_path) and download_if_needed:
                 # The directory exists, perhaps it's corrupted?  Delete it
                 # and start from scratch.
                 import shutil
-                shutil.rmtree(clang_tidy_path)
-                return self._get_clang_tidy(force=force, skip_cache=skip_cache,
+                shutil.rmtree(clang_toolchain_path)
+                return self._get_clang_toolchain(force=force, skip_cache=skip_cache,
                                             source=source, verbose=verbose,
                                             download_if_needed=download_if_needed)
 
             # Create base directory where we store clang binary
-            os.mkdir(clang_tidy_path)
+            os.mkdir(clang_toolchain_path)
 
             if source:
-                return self._get_clang_tidy_from_source(source)
+                return self._get_clang_toolchain_from_source(source)
 
             self._artifact_manager = PackageFrontend(self._mach_context)
 
             if not download_if_needed:
                 return 0
 
             job, _ = self.platform
 
@@ -2439,41 +2439,41 @@ class StaticAnalysis(MachCommandBase):
                 raise Exception('The current platform isn\'t supported. '
                                 'Currently only the following platforms are '
                                 'supported: win32/win64, linux64 and macosx64.')
             else:
                 job += '-clang-tidy'
 
             # We want to unpack data in the clang-tidy mozbuild folder
             currentWorkingDir = os.getcwd()
-            os.chdir(clang_tidy_path)
+            os.chdir(clang_toolchain_path)
             rc = self._artifact_manager.artifact_toolchain(verbose=verbose,
                                                            skip_cache=skip_cache,
                                                            from_build=[job],
                                                            no_unpack=False,
                                                            retry=0)
             # Change back the cwd
             os.chdir(currentWorkingDir)
 
             return rc
 
-    def _get_clang_tidy_from_source(self, filename):
+    def _get_clang_toolchain_from_source(self, filename):
         from mozbuild.action.tooltool import unpack_file
-        clang_tidy_path = mozpath.join(self._mach_context.state_dir,
+        clang_toolchain_path = mozpath.join(self._mach_context.state_dir,
                                        "clang-tidy")
 
         currentWorkingDir = os.getcwd()
-        os.chdir(clang_tidy_path)
+        os.chdir(clang_toolchain_path)
 
         unpack_file(filename)
 
         # Change back the cwd
         os.chdir(currentWorkingDir)
 
-        clang_path = mozpath.join(clang_tidy_path, 'clang')
+        clang_path = mozpath.join(clang_toolchain_path, 'clang')
 
         if not os.path.isdir(clang_path):
             raise Exception('Extracted the archive but didn\'t find '
                             'the expected output')
 
         assert os.path.exists(self._clang_tidy_path)
         assert os.path.exists(self._clang_apply_replacements)
         assert os.path.exists(self._run_clang_tidy_path)