Rewrite cpplint script in python.
This commit is contained in:
		
					parent
					
						
							
								5c48f03dfe
							
						
					
				
			
			
				commit
				
					
						cce712549b
					
				
			
		
					 2 changed files with 45 additions and 26 deletions
				
			
		| 
						 | 
					@ -1,26 +0,0 @@
 | 
				
			||||||
#!/bin/bash
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cd "`dirname $0`/.."
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# List all Objective-C headers here, should not cpplint them.
 | 
					 | 
				
			||||||
OBJC_HEADERS='
 | 
					 | 
				
			||||||
browser/atom_event_processing_window.h
 | 
					 | 
				
			||||||
browser/atom_application_mac.h
 | 
					 | 
				
			||||||
browser/atom_application_delegate_mac.h
 | 
					 | 
				
			||||||
browser/native_window_mac.h
 | 
					 | 
				
			||||||
browser/nsalert_synchronous_sheet.h
 | 
					 | 
				
			||||||
common/api/api_messages.cc
 | 
					 | 
				
			||||||
common/api/api_messages.h'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
FILES=`find app browser common renderer -type f -name '*.h' -or -name '*.cc'`
 | 
					 | 
				
			||||||
FILTERED_FILES=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
while read file; do
 | 
					 | 
				
			||||||
  if ! echo "$OBJC_HEADERS" | grep "$file" > /dev/null ; then
 | 
					 | 
				
			||||||
    FILTERED_FILES="$FILTERED_FILES $file"
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
done <<< "$FILES"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
python ./vendor/cpplint.py \
 | 
					 | 
				
			||||||
  --filter=-build/header_guard,-build/include_what_you_use \
 | 
					 | 
				
			||||||
  $FILTERED_FILES
 | 
					 | 
				
			||||||
							
								
								
									
										45
									
								
								script/cpplint.py
									
										
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										45
									
								
								script/cpplint.py
									
										
									
									
										vendored
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,45 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import fnmatch
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					import subprocess
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					OBJC_HEADERS = [
 | 
				
			||||||
 | 
					  'browser/atom_event_processing_window.h',
 | 
				
			||||||
 | 
					  'browser/atom_application_mac.h',
 | 
				
			||||||
 | 
					  'browser/atom_application_delegate_mac.h',
 | 
				
			||||||
 | 
					  'browser/native_window_mac.h',
 | 
				
			||||||
 | 
					  'browser/nsalert_synchronous_sheet.h',
 | 
				
			||||||
 | 
					  'common/api/api_messages.cc',
 | 
				
			||||||
 | 
					  'common/api/api_messages.h',
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
 | 
					  os.chdir(SOURCE_ROOT)
 | 
				
			||||||
 | 
					  files = list_files(['app', 'browser', 'common', 'renderer'],
 | 
				
			||||||
 | 
					                     ['*.cc', '*.h'])
 | 
				
			||||||
 | 
					  call_cpplint(list(set(files) - set(OBJC_HEADERS)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def list_files(directories, filters):
 | 
				
			||||||
 | 
					  matches = []
 | 
				
			||||||
 | 
					  for directory in directories:
 | 
				
			||||||
 | 
					    for root, dirs, 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 call_cpplint(files):
 | 
				
			||||||
 | 
					  cpplint = os.path.join(SOURCE_ROOT, 'vendor', 'cpplint.py')
 | 
				
			||||||
 | 
					  rules = '--filter=-build/header_guard,-build/include_what_you_use'
 | 
				
			||||||
 | 
					  subprocess.call([sys.executable, cpplint, rules] + files)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					  sys.exit(main())
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue