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

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('./node_modules', 'nan', 'nan_implementation_12_inl.h')
0011 ]
0012 
0013 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
0014 
0015 
0016 def main():
0017   os.chdir(SOURCE_ROOT)
0018   files = list_files([''],
0019                      ['*.cpp', '*.cc', '*.h'])
0020 
0021   node_modules_files = list_files(['node_modules'],
0022                      ['*.cpp', '*.cc', '*.h'])
0023 
0024   call_cpplint(list(set(files) - set(IGNORE_FILES) - set(node_modules_files)))
0025 
0026 
0027 def list_files(directories, filters):
0028   matches = []
0029   for directory in directories:
0030     for root, _, filenames, in os.walk(os.path.join('./', directory)):
0031       for f in filters:
0032         for filename in fnmatch.filter(filenames, f):
0033           matches.append(os.path.join(root, filename))
0034   return matches
0035 
0036 
0037 def call_cpplint(files):
0038   cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py')
0039   execute([sys.executable, cpplint] + files)
0040 
0041 
0042 if __name__ == '__main__':
0043   sys.exit(main())