build: fix clang format/lint (#42715)

* build: fix clang format path

* fix: use gclient sync instead of gclient runhooks

Refs https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5659261

* fix: use gclient sync instead of gclient runhooks in GHA

---------

Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
Keeley Hammond 2024-06-28 13:30:07 -07:00 committed by GitHub
parent 398dde9dfb
commit 3ac57e17d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 10 deletions

View file

@ -31,7 +31,7 @@ steps:
mkdir -p src/buildtools mkdir -p src/buildtools
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
gclient runhooks --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]" gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
- run: - run:
name: Run Lint name: Run Lint
command: | command: |

View file

@ -56,7 +56,7 @@ jobs:
mkdir -p src/buildtools mkdir -p src/buildtools
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/buildtools/DEPS?format=TEXT" | base64 -d > src/buildtools/DEPS
gclient runhooks --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]" gclient sync --spec="solutions=[{'name':'src/buildtools','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':True},'managed':False}]"
- name: Run Lint - name: Run Lint
shell: bash shell: bash
run: | run: |

View file

@ -195,14 +195,20 @@ def get_buildtools_executable(name):
else: else:
raise Exception(f"Unsupported platform: {sys.platform}") raise Exception(f"Unsupported platform: {sys.platform}")
if name == 'clang-format':
path = os.path.join(buildtools, chromium_platform, 'format', name)
else:
path = os.path.join(buildtools, chromium_platform, name) path = os.path.join(buildtools, chromium_platform, name)
if sys.platform == 'win32': if sys.platform == 'win32':
path += '.exe' path += '.exe'
return path return path
def get_depot_tools_executable(name):
buildtools = os.path.realpath(
os.path.join(ELECTRON_DIR, '..', 'third_party', 'depot_tools'))
path = os.path.join(buildtools, name)
if sys.platform == 'win32':
path += '.bat'
return path
def get_linux_binaries(): def get_linux_binaries():
return [ return [
'chrome-sandbox', 'chrome-sandbox',

View file

@ -23,7 +23,7 @@ import traceback
import tempfile import tempfile
from functools import partial from functools import partial
from lib.util import get_buildtools_executable from lib.util import get_depot_tools_executable
DEFAULT_EXTENSIONS = 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,mm' DEFAULT_EXTENSIONS = 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,mm'
DEFAULT_CLANG_FORMAT_IGNORE = '.clang-format-ignore' DEFAULT_CLANG_FORMAT_IGNORE = '.clang-format-ignore'
@ -205,7 +205,7 @@ def main():
'--clang-format-executable', '--clang-format-executable',
metavar='EXECUTABLE', metavar='EXECUTABLE',
help='path to the clang-format executable', help='path to the clang-format executable',
default=get_buildtools_executable('clang-format')) default=get_depot_tools_executable('clang-format'))
parser.add_argument( parser.add_argument(
'--extensions', '--extensions',
help='comma-separated list of file extensions' help='comma-separated list of file extensions'

View file

@ -2,7 +2,7 @@ import os
import subprocess import subprocess
import sys import sys
from lib.util import get_buildtools_executable from lib.util import get_depot_tools_executable
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
@ -15,7 +15,7 @@ def main():
os.path.join(SOURCE_ROOT, '..', 'buildtools') os.path.join(SOURCE_ROOT, '..', 'buildtools')
) )
gn_path = get_buildtools_executable('gn') gn_path = get_depot_tools_executable('gn')
for gn_file in sys.argv[1:]: for gn_file in sys.argv[1:]:
subprocess.check_call( subprocess.check_call(
[gn_path, 'format', gn_file], [gn_path, 'format', gn_file],