mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
[depot_tools] Update clang_format.py with new path
Look for both new and old paths when checking the buildtools/ dir. Currently, there's different binaries for mac x64 and mac arm64. Depending on the host cpu, only one is downloaded to buildtools/mac, meaning that there is an overlap in buildtools/mac. When we migrate to clang-format, buildtools/mac will be for mac x64 and buildtools/mac_arm64 will be for mac arm64. - Verified locally on my macbook that the mac_arm64 path correctly gets chosen. Migration CL: https://chromium-review.googlesource.com/c/chromium/src/+/5484590 Bug: b/336843583, Change-Id: I26f80dff0e39b7ae31ed5d0a1d8e436eb19fbb3d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5484138 Reviewed-by: Joanna Wang <jojwang@chromium.org> Commit-Queue: Stephanie Kim <kimstephanie@google.com>
This commit is contained in:
@@ -8,6 +8,7 @@ clang-format binaries are pulled down from Google Cloud Storage whenever you
|
||||
sync Chrome, to platform-specific locations. This script knows how to locate
|
||||
those tools, assuming the script is invoked from inside a Chromium checkout."""
|
||||
|
||||
import detect_host_arch
|
||||
import gclient_paths
|
||||
import os
|
||||
import subprocess
|
||||
@@ -40,11 +41,23 @@ def FindClangFormatToolInChromiumTree():
|
||||
'Set CHROMIUM_BUILDTOOLS_PATH to use outside of a chromium '
|
||||
'checkout.')
|
||||
|
||||
tool_path = os.path.join(bin_path,
|
||||
'clang-format' + gclient_paths.GetExeSuffix())
|
||||
if not os.path.exists(tool_path):
|
||||
raise NotFoundError('File does not exist: %s' % tool_path)
|
||||
return tool_path
|
||||
# TODO(b/336843583): Remove old_tool_path when migrated over
|
||||
old_tool_path = os.path.join(bin_path,
|
||||
'clang-format' + gclient_paths.GetExeSuffix())
|
||||
|
||||
new_bin_path = bin_path
|
||||
arch = detect_host_arch.HostArch()
|
||||
if sys.platform == 'darwin' and arch == 'arm64':
|
||||
new_bin_path += '_arm64'
|
||||
new_tool_path = os.path.join(new_bin_path, 'format',
|
||||
'clang-format' + gclient_paths.GetExeSuffix())
|
||||
|
||||
possible_paths = [new_tool_path, old_tool_path]
|
||||
for path in possible_paths:
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
raise NotFoundError('File does not exist in either path: %s' %
|
||||
possible_paths)
|
||||
|
||||
|
||||
def FindClangFormatScriptInChromiumTree(script_name):
|
||||
|
||||
Reference in New Issue
Block a user