1
1
#!/usr/bin/env python
3
# Copyright 2011 the V8 project authors. All rights reserved.
3
# Copyright 2012 the V8 project authors. All rights reserved.
4
4
# Redistribution and use in source and binary forms, with or without
5
5
# modification, are permitted provided that the following conditions are
105
LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing')
108
def CppLintWorker(command):
110
process = subprocess.Popen(command, stderr=subprocess.PIPE)
115
out_line = process.stderr.readline()
116
if out_line == '' and process.poll() != None:
118
m = LINT_OUTPUT_PATTERN.match(out_line)
120
out_lines += out_line
122
sys.stderr.write(out_lines)
124
except KeyboardInterrupt:
127
print('Error running cpplint.py. Please make sure you have depot_tools' +
128
' in your $PATH. Lint check skipped.')
104
132
class FileContentsCache(object):
106
134
def __init__(self, sums_file_name):
208
236
filt = '-,' + ",".join(['+' + n for n in ENABLED_LINT_RULES])
209
command = ['cpplint.py', '--filter', filt] + join(files)
237
command = ['cpplint.py', '--filter', filt]
210
238
local_cpplint = join(path, "tools", "cpplint.py")
211
239
if exists(local_cpplint):
212
command = ['python', local_cpplint, '--filter', filt] + join(files)
240
command = ['python', local_cpplint, '--filter', filt]
242
commands = join([command + [file] for file in files])
243
count = multiprocessing.cpu_count()
244
pool = multiprocessing.Pool(count)
215
process = subprocess.Popen(command, stderr=subprocess.PIPE)
217
print('Error running cpplint.py. Please make sure you have depot_tools' +
218
' in your $PATH. Lint check skipped.')
220
LINT_ERROR_PATTERN = re.compile(r'^(.+)[:(]\d+[:)]')
222
out_line = process.stderr.readline()
223
if out_line == '' and process.poll() != None:
225
sys.stderr.write(out_line)
226
m = LINT_ERROR_PATTERN.match(out_line)
228
good_files_cache.RemoveFile(m.group(1))
246
results = pool.map_async(CppLintWorker, commands).get(999999)
247
except KeyboardInterrupt:
248
print "\nCaught KeyboardInterrupt, terminating workers."
251
for i in range(len(files)):
253
good_files_cache.RemoveFile(files[i])
255
total_errors = sum(results)
256
print "Total errors found: %d" % total_errors
230
257
good_files_cache.Save()
231
return process.returncode == 0
258
return total_errors == 0
234
261
COPYRIGHT_HEADER_PATTERN = re.compile(