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 3 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] [--exclude=path]
[--extensions=hpp,cpp,...] [--extensions=hpp,cpp,...]
[--includeorder=default|standardcfirst] [--includeorder=default|standardcfirst]
[--config=filename]
[--quiet] [--quiet]
[--version] [--version]
<file> [file] ... <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 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. 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,... headers=x,y,...
The header extensions that cpplint will treat as .h in checks. Values are The header extensions that cpplint will treat as .h in checks. Values are
automatically added to --extensions list. automatically added to --extensions list.
@ -876,6 +880,9 @@ _line_length = 80
# This allows to use different include order rule than default # This allows to use different include order rule than default
_include_order = "default" _include_order = "default"
# This allows different config files to be used
_config_filename = "CPPLINT.cfg"
try: try:
unicode unicode
except NameError: except NameError:
@ -6526,7 +6533,7 @@ def ProcessConfigOverrides(filename):
if not base_name: if not base_name:
break # Reached the root directory. 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 abs_filename = abs_path
if not os.path.isfile(cfg_file): if not os.path.isfile(cfg_file):
continue continue
@ -6746,6 +6753,7 @@ def ParseArguments(args):
'recursive', 'recursive',
'headers=', 'headers=',
'includeorder=', 'includeorder=',
'config=',
'quiet']) 'quiet'])
except getopt.GetoptError: except getopt.GetoptError:
PrintUsage('Invalid arguments.') PrintUsage('Invalid arguments.')
@ -6804,6 +6812,9 @@ def ParseArguments(args):
recursive = True recursive = True
elif opt == '--includeorder': elif opt == '--includeorder':
ProcessIncludeOrderOption(val) ProcessIncludeOrderOption(val)
elif opt == '--config':
global _config_filename
_config_filename = val
if not filenames: if not filenames:
PrintUsage('No files were specified.') PrintUsage('No files were specified.')

Loading…
Cancel
Save