fix: use gn/clang-format from src (#19145)

* fix: use gn/clang-format from src

* fix: download clang-format in lint job

* chore: fix linting warning

* chore: get_path_in_buildtools => get_buildtools_executable

* chore: the clang-format npm package is not used
This commit is contained in:
Cheng Zhao 2019-07-09 17:40:26 +09:00 committed by GitHub
parent d79e6bbffe
commit 436d5c9ac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 26 deletions

View file

@ -246,3 +246,15 @@ def get_electron_exec():
raise Exception(
"get_electron_exec: unexpected platform '{0}'".format(sys.platform))
def get_buildtools_executable(name):
buildtools = os.path.realpath(os.path.join(ELECTRON_DIR, '..', 'buildtools'))
chromium_platform = {
'darwin': 'mac',
'linux2': 'linux64',
'win32': 'win',
}[sys.platform]
path = os.path.join(buildtools, chromium_platform, name)
if sys.platform == 'win32':
path += '.exe'
return path

View file

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

View file

@ -2,6 +2,8 @@ import os
import subprocess
import sys
from lib.util import get_buildtools_executable
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
# Helper to run gn format on multiple files
@ -12,9 +14,11 @@ def main():
new_env['CHROMIUM_BUILDTOOLS_PATH'] = os.path.realpath(
os.path.join(SOURCE_ROOT, '..', 'buildtools')
)
gn_path = get_buildtools_executable('gn')
for gn_file in sys.argv[1:]:
subprocess.check_call(
['gn', 'format', gn_file],
[gn_path, 'format', gn_file],
env=new_env
)