mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Add new parameter --project_root to cpplint.py.
Chrome on iOS downstream repository tracks Chromium via DEPS and wants to use cpplint canned presubmit check but the cpplint.py errors due at the include guard as it stops at the inner most git repository. Add a new parameter --project_root to cpplint.py. If set, it overrides the automatic detection of the project root that searches the root of the version control repository. The --root parameter cannot be used as it is used after the automatic resolution is performed (and allow chopping the head of the relative path while the need is to expend the path to include ios_internal/). BUG=598090 Review-Url: https://codereview.chromium.org/2036773002
This commit is contained in:
16
cpplint.py
vendored
16
cpplint.py
vendored
@@ -524,6 +524,10 @@ _error_suppressions = {}
|
||||
# This is set by --root flag.
|
||||
_root = None
|
||||
|
||||
# The project root directory. Used for deriving header guard CPP variable.
|
||||
# This is set by --project_root flag. Must be an absolute path.
|
||||
_project_root = None
|
||||
|
||||
# The allowed line length of files.
|
||||
# This is set by --linelength flag.
|
||||
_line_length = 80
|
||||
@@ -1065,6 +1069,10 @@ class FileInfo(object):
|
||||
if os.path.exists(fullname):
|
||||
project_dir = os.path.dirname(fullname)
|
||||
|
||||
if _project_root:
|
||||
prefix = os.path.commonprefix([_project_root, project_dir])
|
||||
return fullname[len(prefix) + 1:]
|
||||
|
||||
if os.path.exists(os.path.join(project_dir, ".svn")):
|
||||
# If there's a .svn file in the current directory, we recursively look
|
||||
# up the directory tree for the top of the SVN checkout
|
||||
@@ -6025,7 +6033,8 @@ def ParseArguments(args):
|
||||
'filter=',
|
||||
'root=',
|
||||
'linelength=',
|
||||
'extensions='])
|
||||
'extensions=',
|
||||
'project_root='])
|
||||
except getopt.GetoptError:
|
||||
PrintUsage('Invalid arguments.')
|
||||
|
||||
@@ -6054,6 +6063,11 @@ def ParseArguments(args):
|
||||
elif opt == '--root':
|
||||
global _root
|
||||
_root = val
|
||||
elif opt == '--project_root':
|
||||
global _project_root
|
||||
_project_root = val
|
||||
if not os.path.isabs(_project_root):
|
||||
PrintUsage('Project root must be an absolute path.')
|
||||
elif opt == '--linelength':
|
||||
global _line_length
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user