cpplint.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. import fnmatch
  3. import os
  4. import sys
  5. from lib.util import execute
  6. IGNORE_FILES = [
  7. os.path.join('atom', 'browser', 'mac', 'atom_application.h'),
  8. os.path.join('atom', 'browser', 'mac', 'atom_application_delegate.h'),
  9. os.path.join('atom', 'browser', 'resources', 'win', 'resource.h'),
  10. os.path.join('atom', 'browser', 'ui', 'cocoa', 'atom_menu_controller.h'),
  11. os.path.join('atom', 'browser', 'ui', 'cocoa', 'atom_touch_bar.h'),
  12. os.path.join('atom', 'browser', 'ui', 'cocoa',
  13. 'touch_bar_forward_declarations.h'),
  14. os.path.join('atom', 'common', 'api', 'api_messages.h'),
  15. os.path.join('atom', 'common', 'common_message_generator.cc'),
  16. os.path.join('atom', 'common', 'common_message_generator.h'),
  17. ]
  18. SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  19. def main():
  20. os.chdir(SOURCE_ROOT)
  21. files = list_files(['app', 'browser', 'common', 'renderer', 'utility'],
  22. ['*.cc', '*.h'])
  23. call_cpplint(list(set(files) - set(IGNORE_FILES)))
  24. def list_files(directories, filters):
  25. matches = []
  26. for directory in directories:
  27. for root, _, filenames, in os.walk(os.path.join('atom', directory)):
  28. for f in filters:
  29. for filename in fnmatch.filter(filenames, f):
  30. matches.append(os.path.join(root, filename))
  31. return matches
  32. def call_cpplint(files):
  33. cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py')
  34. execute([sys.executable, cpplint] + files)
  35. if __name__ == '__main__':
  36. sys.exit(main())