Bug 1520920 - do not 'mach configure' when downloading clang-tidy artifact. r=nalexander
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Tue, 12 Feb 2019 10:44:17 +0000
changeset 458685 9ad69518248dbb19568b8485df6fb6e36cc56f32
parent 458684 2dbc0282899d090127b977912762bf983f56d6c4
child 458686 8d5174a560fac56a1a6046cba5ebe95df62836a3
push id77972
push userbpostelnicu@mozilla.com
push dateTue, 12 Feb 2019 10:47:04 +0000
treeherderautoland@9ad69518248d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1520920
milestone67.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 1520920 - do not 'mach configure' when downloading clang-tidy artifact. r=nalexander Differential Revision: https://phabricator.services.mozilla.com/D16969
python/mozboot/mozboot/base.py
python/mozboot/mozboot/bootstrap.py
python/mozboot/mozboot/freebsd.py
python/mozboot/mozboot/linux_common.py
python/mozboot/mozboot/mozillabuild.py
python/mozboot/mozboot/openbsd.py
python/mozboot/mozboot/osx.py
python/mozboot/mozboot/static_analysis.py
python/mozboot/mozboot/windows.py
--- a/python/mozboot/mozboot/base.py
+++ b/python/mozboot/mozboot/base.py
@@ -248,17 +248,17 @@ class BaseBootstrapper(object):
 
         GeckoView/Firefox for Android Artifact Mode needs an application and an ABI set,
         and it needs paths to the Android SDK.
         '''
         raise NotImplementedError(
             '%s does not yet implement suggest_mobile_android_artifact_mode_mozconfig()'
             % __name__)
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
         '''
         Install the clang static analysis package
         '''
         raise NotImplementedError(
             '%s does not yet implement ensure_clang_static_analysis_package()'
             % __name__)
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
@@ -271,33 +271,25 @@ class BaseBootstrapper(object):
 
     def ensure_node_packages(self, state_dir, checkout_root):
         '''
         Install any necessary packages needed to supply NodeJS'''
         raise NotImplementedError(
             '%s does not yet implement ensure_node_packages()'
             % __name__)
 
-    def install_toolchain_static_analysis(self, checkout_root):
-        mach_binary = os.path.join(checkout_root, 'mach')
-        mach_binary = os.path.abspath(mach_binary)
-        if not os.path.exists(mach_binary):
-            raise ValueError("mach not found at %s" % mach_binary)
-
-        if not sys.executable:
-            raise ValueError("cannot determine path to Python executable")
+    def install_toolchain_static_analysis(self, state_dir, checkout_root, toolchain_job):
+        clang_tools_path = os.path.join(state_dir, 'clang-tools')
+        import shutil
+        if os.path.exists(clang_tools_path):
+            shutil.rmtree(clang_tools_path)
 
-        cmd = [sys.executable, mach_binary, 'static-analysis', 'install',
-               '--force', '--minimal-install']
-
-        from subprocess import CalledProcessError
-        try:
-            subprocess.check_call(cmd)
-        except CalledProcessError as e:
-            print(e.output)
+        # Re-create the directory for clang_tools
+        os.mkdir(clang_tools_path)
+        self.install_toolchain_artifact(clang_tools_path, checkout_root, toolchain_job)
 
     def install_toolchain_artifact(self, state_dir, checkout_root, toolchain_job):
         mach_binary = os.path.join(checkout_root, 'mach')
         mach_binary = os.path.abspath(mach_binary)
         if not os.path.exists(mach_binary):
             raise ValueError("mach not found at %s" % mach_binary)
 
         # If Python can't figure out what its own executable is, there's little
--- a/python/mozboot/mozboot/bootstrap.py
+++ b/python/mozboot/mozboot/bootstrap.py
@@ -377,17 +377,17 @@ class Bootstrapper(object):
         if not have_clone:
             print(STYLE_NODEJS_REQUIRES_CLONE)
             sys.exit(1)
 
         self.instance.state_dir = state_dir
         self.instance.ensure_node_packages(state_dir, checkout_root)
         if not self.instance.artifact_mode:
             self.instance.ensure_stylo_packages(state_dir, checkout_root)
-            self.instance.ensure_clang_static_analysis_package(checkout_root)
+            self.instance.ensure_clang_static_analysis_package(state_dir, checkout_root)
 
     def check_telemetry_opt_in(self, state_dir):
         # We can't prompt the user.
         if self.instance.no_interactive:
             return
         # Don't prompt if the user already has a setting for this value.
         if self.mach_context is not None and 'telemetry' in self.mach_context.settings.build:
             return
--- a/python/mozboot/mozboot/freebsd.py
+++ b/python/mozboot/mozboot/freebsd.py
@@ -61,17 +61,17 @@ class FreeBSDBootstrapper(BaseBootstrapp
 
     def install_browser_artifact_mode_packages(self):
         self.ensure_browser_packages(artifact_mode=True)
 
     def ensure_browser_packages(self, artifact_mode=False):
         # TODO: Figure out what not to install for artifact mode
         self.pkg_install(*self.browser_packages)
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
         # TODO: we don't ship clang base static analysis for this platform
         pass
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         # Clang / llvm already installed as browser package
         self.pkg_install('rust-cbindgen')
 
     def ensure_node_packages(self, state_dir, checkout_root):
--- a/python/mozboot/mozboot/linux_common.py
+++ b/python/mozboot/mozboot/linux_common.py
@@ -44,15 +44,17 @@ class NodeInstall(object):
         from mozboot import node
         self.install_toolchain_artifact(state_dir, checkout_root, node.LINUX)
 
 
 class ClangStaticAnalysisInstall(object):
     def __init__(self, **kwargs):
         pass
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
         if is_non_x86_64():
             print('Cannot install static analysis tools from taskcluster.\n'
                   'Please install these tools manually.')
             return
 
-        self.install_toolchain_static_analysis(checkout_root)
+        from mozboot import static_analysis
+        self.install_toolchain_static_analysis(
+            state_dir, checkout_root, static_analysis.LINUX_CLANG_TIDY)
--- a/python/mozboot/mozboot/mozillabuild.py
+++ b/python/mozboot/mozboot/mozillabuild.py
@@ -67,18 +67,20 @@ class MozillaBuildBootstrapper(BaseBoots
         pass
 
     def install_mobile_android_packages(self):
         pass
 
     def install_mobile_android_artifact_mode_packages(self):
         pass
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
-        self.install_toolchain_static_analysis(checkout_root)
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
+        from mozboot import static_analysis
+        self.install_toolchain_static_analysis(
+            state_dir, checkout_root, static_analysis.WINDOWS_CLANG_TIDY)
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         # On-device artifact builds are supported; on-device desktop builds are not.
         if is_aarch64_host():
             raise Exception('You should not be performing desktop builds on an '
                             'AArch64 device.  If you want to do artifact builds '
                             'instead, please choose the appropriate artifact build '
                             'option when beginning bootstrap.')
--- a/python/mozboot/mozboot/openbsd.py
+++ b/python/mozboot/mozboot/openbsd.py
@@ -42,17 +42,17 @@ class OpenBSDBootstrapper(BaseBootstrapp
     def install_browser_artifact_mode_packages(self):
         self.ensure_browser_packages(artifact_mode=True)
 
     def ensure_browser_packages(self, artifact_mode=False):
         # TODO: Figure out what not to install for artifact mode
         # we use -z because there's no other way to say "any autoconf-2.13"
         self.run_as_root(['pkg_add', '-z'] + self.browser_packages)
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
         # TODO: we don't ship clang base static analysis for this platform
         pass
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         # Clang / llvm already installed as browser package
         self.run_as_root(['pkg_add', 'cbindgen'])
 
     def ensure_node_packages(self, state_dir, checkout_root):
--- a/python/mozboot/mozboot/osx.py
+++ b/python/mozboot/mozboot/osx.py
@@ -511,18 +511,20 @@ class OSXBootstrapper(BaseBootstrapper):
 
             for check in ('/bin', '/usr/bin'):
                 if path == check:
                     print(BAD_PATH_ORDER % (check, p_dir, p_dir, check, p_dir))
                     sys.exit(1)
 
         return active_name.lower()
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
-        self.install_toolchain_static_analysis(checkout_root)
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
+        from mozboot import static_analysis
+        self.install_toolchain_static_analysis(
+            state_dir, checkout_root, static_analysis.MACOS_CLANG_TIDY)
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         from mozboot import stylo
         # We installed clang via homebrew earlier.  However, on Android, we're
         # seeing many compiler errors so we use our own toolchain clang.
         if 'mobile_android' in self.application:
             self.install_toolchain_artifact(state_dir, checkout_root, stylo.MACOS_CLANG)
         self.install_toolchain_artifact(state_dir, checkout_root, stylo.MACOS_CBINDGEN)
new file mode 100644
--- /dev/null
+++ b/python/mozboot/mozboot/static_analysis.py
@@ -0,0 +1,9 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+WINDOWS_CLANG_TIDY = 'win64-clang-tidy'
+LINUX_CLANG_TIDY = 'linux64-clang-tidy'
+MACOS_CLANG_TIDY = 'macosx64-clang-tidy'
--- a/python/mozboot/mozboot/windows.py
+++ b/python/mozboot/mozboot/windows.py
@@ -94,18 +94,20 @@ class WindowsBootstrapper(BaseBootstrapp
         self.pacman_install(*self.BROWSER_PACKAGES)
 
     def install_mobile_android_packages(self):
         raise NotImplementedError('We do not support building Android on Windows. Sorry!')
 
     def install_mobile_android_artifact_mode_packages(self):
         raise NotImplementedError('We do not support building Android on Windows. Sorry!')
 
-    def ensure_clang_static_analysis_package(self, checkout_root):
-        self.install_toolchain_static_analysis(checkout_root)
+    def ensure_clang_static_analysis_package(self, state_dir, checkout_root):
+        from mozboot import static_analysis
+        self.install_toolchain_static_analysis(
+            state_dir, checkout_root, static_analysis.WINDOWS_CLANG_TIDY)
 
     def ensure_stylo_packages(self, state_dir, checkout_root):
         # On-device artifact builds are supported; on-device desktop builds are not.
         if is_aarch64_host():
             raise Exception('You should not be performing desktop builds on an '
                             'AArch64 device.  If you want to do artifact builds '
                             'instead, please choose the appropriate artifact build '
                             'option when beginning bootstrap.')