2013-11-17 22:36:57 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
CPPLINT = os.path.join(SOURCE_ROOT, 'vendor', 'google-styleguide', 'trunk', 'cpplint', 'cpplint.py')
|
2013-12-19 19:19:12 +00:00
|
|
|
LINE_LENGTH = 100
|
2013-11-17 22:36:57 +00:00
|
|
|
|
2013-11-17 23:55:06 +00:00
|
|
|
IGNORED_FILES = [
|
2014-07-09 02:38:00 +00:00
|
|
|
os.path.join('browser', 'mac', 'bry_inspectable_web_contents_view.h'),
|
2013-11-17 23:55:06 +00:00
|
|
|
]
|
|
|
|
|
2013-11-18 00:19:58 +00:00
|
|
|
FILTERS = [
|
|
|
|
'-build/header_guard',
|
|
|
|
'-build/include_what_you_use',
|
|
|
|
'-legal/copyright',
|
|
|
|
# cpplint doesn't like the BOOL& parameters that ui::WindowImpl uses.
|
|
|
|
'-runtime/references',
|
|
|
|
]
|
|
|
|
|
2013-11-17 22:36:57 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
os.chdir(SOURCE_ROOT)
|
|
|
|
files = list_files(['browser', 'common'],
|
2013-11-17 23:53:16 +00:00
|
|
|
['*.cc', '*.h'])
|
2013-11-17 23:55:06 +00:00
|
|
|
return cpplint(set(files) - set(IGNORED_FILES))
|
2013-11-17 22:36:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def list_files(directories, filters):
|
|
|
|
matches = []
|
|
|
|
for directory in directories:
|
|
|
|
for root, _, filenames, in os.walk(directory):
|
|
|
|
for f in filters:
|
|
|
|
for filename in fnmatch.filter(filenames, f):
|
|
|
|
matches.append(os.path.join(root, filename))
|
|
|
|
return matches
|
|
|
|
|
|
|
|
|
|
|
|
def cpplint(files):
|
2013-12-19 19:19:12 +00:00
|
|
|
return subprocess.call([sys.executable, CPPLINT, '--linelength=%d' % LINE_LENGTH, '--filter=' + ','.join(FILTERS)] + list(files))
|
2013-11-17 22:36:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|