File indexing completed on 2024-11-17 04:55:14

0001 #!/usr/bin/env python
0002 
0003 import fnmatch
0004 import os
0005 import sys
0006 
0007 from lib.util import execute
0008 
0009 IGNORE_FILES = [
0010   os.path.join('./bad_fingerprints.h'),
0011   os.path.join('./bad_fingerprints4.h'),
0012   os.path.join('./bad_fingerprints5.h'),
0013   os.path.join('./bad_fingerprints6.h'),
0014   os.path.join('./bad_fingerprints7.h'),
0015   os.path.join('./bad_fingerprints8.h')
0016 ]
0017 
0018 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
0019 
0020 
0021 def main():
0022   os.chdir(SOURCE_ROOT)
0023   files = list_files([''],
0024                      ['*.cpp', '*.cc', '*.h'])
0025 
0026   node_modules_files = list_files(['node_modules'],
0027                      ['*.cpp', '*.cc', '*.h'])
0028 
0029   call_cpplint(list(set(files) - set(IGNORE_FILES) - set(node_modules_files)))
0030 
0031 
0032 def list_files(directories, filters):
0033   matches = []
0034   for directory in directories:
0035     for root, _, filenames, in os.walk(os.path.join('./', directory)):
0036       for f in filters:
0037         for filename in fnmatch.filter(filenames, f):
0038           matches.append(os.path.join(root, filename))
0039   return matches
0040 
0041 
0042 def call_cpplint(files):
0043   cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py')
0044   execute([sys.executable, cpplint] + files)
0045 
0046 
0047 if __name__ == '__main__':
0048   sys.exit(main())