diff --git a/clang_format.py b/clang_format.py index c32995e424..b72b978d07 100755 --- a/clang_format.py +++ b/clang_format.py @@ -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):