Allow setting cpplint config file name

This is a copy of cpplint/cpplint#198, letting us use alternative config files
when running cpplint.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1156/head
Michael Richters 2 years ago
parent 5d1d7ae003
commit 5c0f20ca58
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

13
bin/cpplint.py vendored

@ -83,6 +83,7 @@ Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed]
[--exclude=path]
[--extensions=hpp,cpp,...]
[--includeorder=default|standardcfirst]
[--config=filename]
[--quiet]
[--version]
<file> [file] ...
@ -229,6 +230,9 @@ Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed]
treat all others as separate group of "other system headers". The C headers
included are those of the C-standard lib and closely related ones.
config=filename
Search for config files with the specified name instead of CPPLINT.cfg
headers=x,y,...
The header extensions that cpplint will treat as .h in checks. Values are
automatically added to --extensions list.
@ -876,6 +880,9 @@ _line_length = 80
# This allows to use different include order rule than default
_include_order = "default"
# This allows different config files to be used
_config_filename = "CPPLINT.cfg"
try:
unicode
except NameError:
@ -6526,7 +6533,7 @@ def ProcessConfigOverrides(filename):
if not base_name:
break # Reached the root directory.
cfg_file = os.path.join(abs_path, "CPPLINT.cfg")
cfg_file = os.path.join(abs_path, _config_filename)
abs_filename = abs_path
if not os.path.isfile(cfg_file):
continue
@ -6746,6 +6753,7 @@ def ParseArguments(args):
'recursive',
'headers=',
'includeorder=',
'config=',
'quiet'])
except getopt.GetoptError:
PrintUsage('Invalid arguments.')
@ -6804,6 +6812,9 @@ def ParseArguments(args):
recursive = True
elif opt == '--includeorder':
ProcessIncludeOrderOption(val)
elif opt == '--config':
global _config_filename
_config_filename = val
if not filenames:
PrintUsage('No files were specified.')

Loading…
Cancel
Save