diff --git a/.gitattributes b/.gitattributes index d8ac36b460..3f263d62be 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,7 @@ patches/**/.patches merge=union *.md text eol=lf *.mm text eol=lf *.mojom text eol=lf +*.patches text eol=lf *.proto text eol=lf *.py text eol=lf *.ps1 text eol=lf diff --git a/script/lint.js b/script/lint.js index 775895770f..abdf89dbb8 100755 --- a/script/lint.js +++ b/script/lint.js @@ -55,7 +55,7 @@ const CPPLINT_FILTERS = [ ]; function spawnAndCheckExitCode (cmd, args, opts) { - opts = { stdio: 'inherit', ...opts }; + opts = { stdio: 'inherit', shell: IS_WINDOWS, ...opts }; const { error, status, signal } = childProcess.spawnSync(cmd, args, opts); if (error) { // the subprocess failed or timed out @@ -100,9 +100,12 @@ const LINTERS = [{ roots: ['shell'], test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)), run: (opts, filenames) => { + const env = { + CHROMIUM_BUILDTOOLS_PATH: path.resolve(ELECTRON_ROOT, '..', 'buildtools') + }; const clangFormatFlags = opts.fix ? ['--fix'] : []; for (const chunk of chunkFilenames(filenames)) { - spawnAndCheckExitCode('python3', ['script/run-clang-format.py', ...clangFormatFlags, ...chunk]); + spawnAndCheckExitCode('python3', ['script/run-clang-format.py', ...clangFormatFlags, ...chunk], { env }); cpplint([`--filter=${CPPLINT_FILTERS.join(',')}`, ...chunk]); } } @@ -111,8 +114,11 @@ const LINTERS = [{ roots: ['shell'], test: filename => filename.endsWith('.mm') || (filename.endsWith('.h') && isObjCHeader(filename)), run: (opts, filenames) => { + const env = { + CHROMIUM_BUILDTOOLS_PATH: path.resolve(ELECTRON_ROOT, '..', 'buildtools') + }; const clangFormatFlags = opts.fix ? ['--fix'] : []; - spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', ...clangFormatFlags, ...filenames]); + spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', ...clangFormatFlags, ...filenames], { env }); const filter = [...CPPLINT_FILTERS, '-readability/braces']; cpplint(['--extensions=mm,h', `--filter=${filter.join(',')}`, ...filenames]); } @@ -124,7 +130,7 @@ const LINTERS = [{ const rcfile = path.join(DEPOT_TOOLS, 'pylintrc-2.17'); const args = ['--rcfile=' + rcfile, ...filenames]; const env = { PYTHONPATH: path.join(ELECTRON_ROOT, 'script'), ...process.env }; - spawnAndCheckExitCode('pylint-2.17', args, { env }); + spawnAndCheckExitCode(IS_WINDOWS ? 'pylint-2.17.bat' : 'pylint-2.17', args, { env }); } }, { key: 'javascript', @@ -170,8 +176,6 @@ const LINTERS = [{ DEPOT_TOOLS_WIN_TOOLCHAIN: '0', ...process.env }; - // Users may not have depot_tools in PATH. - env.PATH = `${env.PATH}${path.delimiter}${DEPOT_TOOLS}`; const args = ['format', filename]; if (!opts.fix) args.push('--dry-run'); const result = childProcess.spawnSync('gn', args, { env, stdio: 'inherit', shell: true }); diff --git a/script/run-clang-format.py b/script/run-clang-format.py index b5432da0a5..dfb83dd866 100644 --- a/script/run-clang-format.py +++ b/script/run-clang-format.py @@ -134,6 +134,7 @@ def run_clang_format_diff(args, file_name): stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, + encoding='utf-8', shell=True) as proc: outs = list(proc.stdout.readlines()) errs = list(proc.stderr.readlines()) @@ -186,10 +187,7 @@ def colorize(diff_lines): def print_diff(diff_lines, use_color): if use_color: diff_lines = colorize(diff_lines) - if sys.version_info[0] < 3: - sys.stdout.writelines((l.encode('utf-8') for l in diff_lines)) - else: - sys.stdout.writelines(diff_lines) + sys.stdout.writelines(diff_lines) def print_trouble(prog, message, use_colors):