зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1816443 - Use auto-bootstrap code to bootstrap clang-tidy in both bootstrap and code-analysis. r=andi,firefox-build-system-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D168962
This commit is contained in:
Родитель
383759bb16
Коммит
0ea0ba74cc
|
@ -142,6 +142,11 @@ def bootstrap_path(path, **kwargs):
|
|||
if not path:
|
||||
return
|
||||
path_parts = path.split("/")
|
||||
path_prefix = ""
|
||||
# Small hack until clang-tidy stops being a separate toolchain in a
|
||||
# weird location.
|
||||
if path_parts[0] == "clang-tools":
|
||||
path_prefix = path_parts.pop(0)
|
||||
|
||||
def try_bootstrap(exists):
|
||||
if not tasks:
|
||||
|
@ -228,9 +233,9 @@ def bootstrap_path(path, **kwargs):
|
|||
log.info(
|
||||
"%s bootstrapped toolchain in %s",
|
||||
"Updating" if exists else "Installing",
|
||||
os.path.join(toolchains_base_dir, path_parts[0]),
|
||||
os.path.join(toolchains_base_dir, path_prefix, path_parts[0]),
|
||||
)
|
||||
os.makedirs(toolchains_base_dir, exist_ok=True)
|
||||
os.makedirs(os.path.join(toolchains_base_dir, path_prefix), exist_ok=True)
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
|
@ -238,7 +243,7 @@ def bootstrap_path(path, **kwargs):
|
|||
"--log-no-times",
|
||||
]
|
||||
+ command,
|
||||
cwd=toolchains_base_dir,
|
||||
cwd=os.path.join(toolchains_base_dir, path_prefix),
|
||||
check=True,
|
||||
)
|
||||
ensureParentDir(index_file)
|
||||
|
@ -246,7 +251,7 @@ def bootstrap_path(path, **kwargs):
|
|||
fh.write(task_index)
|
||||
return True
|
||||
|
||||
path = os.path.join(toolchains_base_dir, *path_parts)
|
||||
path = os.path.join(toolchains_base_dir, path_prefix, *path_parts)
|
||||
if bootstrap:
|
||||
try:
|
||||
if not try_bootstrap(os.path.exists(path)):
|
||||
|
|
|
@ -333,27 +333,12 @@ class BaseBootstrapper(object):
|
|||
% __name__
|
||||
)
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
"""
|
||||
Install the clang static analysis package
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"%s does not yet implement ensure_clang_static_analysis_package()"
|
||||
% __name__
|
||||
)
|
||||
|
||||
def ensure_sccache_packages(self):
|
||||
"""
|
||||
Install sccache.
|
||||
"""
|
||||
pass
|
||||
|
||||
def install_toolchain_static_analysis(self, toolchain_job):
|
||||
clang_tools_path = self.state_dir / "clang-tools"
|
||||
if not clang_tools_path.exists():
|
||||
clang_tools_path.mkdir()
|
||||
self.install_toolchain_artifact_impl(clang_tools_path, toolchain_job)
|
||||
|
||||
def install_toolchain_artifact(self, toolchain_job, no_unpack=False):
|
||||
if no_unpack:
|
||||
return self.install_toolchain_artifact_impl(
|
||||
|
|
|
@ -261,7 +261,7 @@ class Bootstrapper(object):
|
|||
self.instance.install_toolchain_artifact("fix-stacks")
|
||||
self.instance.install_toolchain_artifact("minidump-stackwalk")
|
||||
if not self.instance.artifact_mode:
|
||||
self.instance.ensure_clang_static_analysis_package()
|
||||
self.instance.install_toolchain_artifact("clang-tools/clang-tidy")
|
||||
self.instance.ensure_sccache_packages()
|
||||
# Like 'ensure_browser_packages' or 'ensure_mobile_android_packages'
|
||||
getattr(self.instance, "ensure_%s_packages" % application)()
|
||||
|
|
|
@ -66,9 +66,5 @@ class FreeBSDBootstrapper(BaseBootstrapper):
|
|||
def install_browser_artifact_mode_packages(self, mozconfig_builder):
|
||||
self.install_browser_packages(mozconfig_builder, artifact_mode=True)
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
# TODO: we don't ship clang base static analysis for this platform
|
||||
pass
|
||||
|
||||
def upgrade_mercurial(self, current):
|
||||
self.pkg_install("mercurial")
|
||||
|
|
|
@ -13,23 +13,6 @@ def is_non_x86_64():
|
|||
return platform.machine() != "x86_64"
|
||||
|
||||
|
||||
class ClangStaticAnalysisInstall(object):
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
if is_non_x86_64():
|
||||
print(
|
||||
"Cannot install static analysis tools from taskcluster.\n"
|
||||
"Please install these tools manually."
|
||||
)
|
||||
return
|
||||
|
||||
from mozboot import static_analysis
|
||||
|
||||
self.install_toolchain_static_analysis(static_analysis.LINUX_CLANG_TIDY)
|
||||
|
||||
|
||||
class MobileAndroidBootstrapper(object):
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
@ -80,10 +63,7 @@ class MobileAndroidBootstrapper(object):
|
|||
return self.generate_mobile_android_mozconfig(artifact_mode=True)
|
||||
|
||||
|
||||
class LinuxBootstrapper(
|
||||
ClangStaticAnalysisInstall,
|
||||
MobileAndroidBootstrapper,
|
||||
):
|
||||
class LinuxBootstrapper(MobileAndroidBootstrapper):
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
|
|
|
@ -222,11 +222,6 @@ class MozillaBuildBootstrapper(BaseBootstrapper):
|
|||
def generate_mobile_android_artifact_mode_mozconfig(self):
|
||||
return self.generate_mobile_android_mozconfig(artifact_mode=True)
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
from mozboot import static_analysis
|
||||
|
||||
self.install_toolchain_static_analysis(static_analysis.WINDOWS_CLANG_TIDY)
|
||||
|
||||
def ensure_sccache_packages(self):
|
||||
from mozboot import sccache
|
||||
|
||||
|
|
|
@ -32,7 +32,3 @@ class OpenBSDBootstrapper(BaseBootstrapper):
|
|||
|
||||
def install_browser_artifact_mode_packages(self, mozconfig_builder):
|
||||
self.install_browser_packages(mozconfig_builder, artifact_mode=True)
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
# TODO: we don't ship clang base static analysis for this platform
|
||||
pass
|
||||
|
|
|
@ -164,9 +164,6 @@ class OSXBootstrapperLight(OSXAndroidBootstrapper, BaseBootstrapper):
|
|||
def install_browser_artifact_mode_packages(self, mozconfig_builder):
|
||||
pass
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
pass
|
||||
|
||||
|
||||
class OSXBootstrapper(OSXAndroidBootstrapper, BaseBootstrapper):
|
||||
def __init__(self, version, **kwargs):
|
||||
|
@ -272,16 +269,6 @@ class OSXBootstrapper(OSXAndroidBootstrapper, BaseBootstrapper):
|
|||
if not homebrew_found:
|
||||
self.install_homebrew()
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
from mozboot import static_analysis
|
||||
|
||||
if platform.machine() == "arm64":
|
||||
self.install_toolchain_static_analysis(
|
||||
static_analysis.MACOS_AARCH64_CLANG_TIDY
|
||||
)
|
||||
else:
|
||||
self.install_toolchain_static_analysis(static_analysis.MACOS_CLANG_TIDY)
|
||||
|
||||
def ensure_sccache_packages(self):
|
||||
from mozboot import sccache
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
# 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/.
|
||||
|
||||
WINDOWS_CLANG_TIDY = "win64-clang-tidy"
|
||||
LINUX_CLANG_TIDY = "linux64-clang-tidy"
|
||||
MACOS_CLANG_TIDY = "macosx64-clang-tidy"
|
||||
MACOS_AARCH64_CLANG_TIDY = "macosx64-aarch64-clang-tidy"
|
|
@ -99,11 +99,6 @@ class WindowsBootstrapper(BaseBootstrapper):
|
|||
"We do not support building Android on Windows. Sorry!"
|
||||
)
|
||||
|
||||
def ensure_clang_static_analysis_package(self):
|
||||
from mozboot import static_analysis
|
||||
|
||||
self.install_toolchain_static_analysis(static_analysis.WINDOWS_CLANG_TIDY)
|
||||
|
||||
def _update_package_manager(self):
|
||||
self.pacman_update()
|
||||
|
||||
|
|
|
@ -1592,38 +1592,12 @@ def get_clang_tools(
|
|||
if source:
|
||||
return _get_clang_tools_from_source(command_context, clang_paths, source)
|
||||
|
||||
from mozbuild.artifact_commands import artifact_toolchain
|
||||
|
||||
if not download_if_needed:
|
||||
return 0, clang_paths
|
||||
|
||||
job, _ = command_context.platform
|
||||
from mozbuild.bootstrap import bootstrap_toolchain
|
||||
|
||||
if job is None:
|
||||
raise Exception(
|
||||
"The current platform isn't supported. "
|
||||
"Currently only the following platforms are "
|
||||
"supported: win32/win64, linux64 and macosx64."
|
||||
)
|
||||
|
||||
job += "-clang-tidy"
|
||||
|
||||
# We want to unpack data in the clang-tidy mozbuild folder
|
||||
currentWorkingDir = os.getcwd()
|
||||
os.chdir(clang_paths._clang_tools_path)
|
||||
rc = artifact_toolchain(
|
||||
command_context,
|
||||
verbose=verbose,
|
||||
skip_cache=skip_cache,
|
||||
from_build=[job],
|
||||
no_unpack=False,
|
||||
retry=0,
|
||||
)
|
||||
# Change back the cwd
|
||||
os.chdir(currentWorkingDir)
|
||||
|
||||
if rc:
|
||||
return rc, clang_paths
|
||||
bootstrap_toolchain("clang-tools/clang-tidy")
|
||||
|
||||
return 0 if _is_version_eligible(command_context, clang_paths) else 1, clang_paths
|
||||
|
||||
|
|
|
@ -123,7 +123,6 @@ def bootstrap_tasks(config, tasks):
|
|||
"python/mozboot/mozboot/mozconfig.py",
|
||||
"python/mozboot/mozboot/rust.py",
|
||||
"python/mozboot/mozboot/sccache.py",
|
||||
"python/mozboot/mozboot/static_analysis.py",
|
||||
"python/mozboot/mozboot/util.py",
|
||||
]
|
||||
+ [f"python/mozboot/mozboot/{f}" for f in os_specific]
|
||||
|
|
Загрузка…
Ссылка в новой задаче