зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1391231 - Use the list provided by .clang-format-ignore instead of only thirdpartypath.txt r=gps
MozReview-Commit-ID: CY1fS7Fg1y --HG-- extra : rebase_source : a419bfba44e2e74e3ac9f7592d6da04b702590ec
This commit is contained in:
Родитель
762be623bf
Коммит
89677ada26
|
@ -9,6 +9,7 @@ import os
|
|||
import stat
|
||||
import platform
|
||||
import errno
|
||||
import re
|
||||
|
||||
from mach.decorators import (
|
||||
CommandArgument,
|
||||
|
@ -277,18 +278,22 @@ class FormatProvider(MachCommandBase):
|
|||
|
||||
def generate_path_list(self, paths):
|
||||
pathToThirdparty = os.path.join(self.topsrcdir,
|
||||
"tools",
|
||||
"rewriting",
|
||||
"ThirdPartyPaths.txt")
|
||||
with open(pathToThirdparty) as f:
|
||||
# Normalize the path (no trailing /)
|
||||
ignored_dir = tuple(d.rstrip('/') for d in f.read().splitlines())
|
||||
".clang-format-ignore")
|
||||
ignored_dir = []
|
||||
for line in open(pathToThirdparty):
|
||||
# Remove comments and empty lines
|
||||
if line.startswith('#') or len(line.strip()) == 0:
|
||||
continue
|
||||
ignored_dir.append(line.rstrip())
|
||||
|
||||
# Generates the list of regexp
|
||||
ignored_dir_re = '(%s)' % '|'.join(ignored_dir)
|
||||
extensions = ('.cpp', '.c', '.h')
|
||||
|
||||
path_list = []
|
||||
for f in paths:
|
||||
if f.startswith(ignored_dir):
|
||||
if re.match(ignored_dir_re, f):
|
||||
# Early exit if we have provided an ignored directory
|
||||
print("clang-format: Ignored third party code '{0}'".format(f))
|
||||
continue
|
||||
|
||||
|
@ -298,8 +303,8 @@ class FormatProvider(MachCommandBase):
|
|||
subs.sort()
|
||||
for filename in sorted(files):
|
||||
f_in_dir = os.path.join(folder, filename)
|
||||
if f_in_dir.endswith(extensions):
|
||||
# Supported extension
|
||||
if f_in_dir.endswith(extensions) and not re.match(ignored_dir_re, f_in_dir):
|
||||
# Supported extension and accepted path
|
||||
path_list.append(f_in_dir)
|
||||
else:
|
||||
if f.endswith(extensions):
|
||||
|
|
Загрузка…
Ссылка в новой задаче