~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to tools/presubmit.py

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
#
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
6
6
# met:
42
42
import re
43
43
import sys
44
44
import subprocess
 
45
import multiprocessing
45
46
from subprocess import PIPE
46
47
 
47
48
# Disabled LINT rules and reason.
101
102
""".split()
102
103
 
103
104
 
 
105
LINT_OUTPUT_PATTERN = re.compile(r'^.+[:(]\d+[:)]|^Done processing')
 
106
 
 
107
 
 
108
def CppLintWorker(command):
 
109
  try:
 
110
    process = subprocess.Popen(command, stderr=subprocess.PIPE)
 
111
    process.wait()
 
112
    out_lines = ""
 
113
    error_count = -1
 
114
    while True:
 
115
      out_line = process.stderr.readline()
 
116
      if out_line == '' and process.poll() != None:
 
117
        break
 
118
      m = LINT_OUTPUT_PATTERN.match(out_line)
 
119
      if m:
 
120
        out_lines += out_line
 
121
        error_count += 1
 
122
    sys.stderr.write(out_lines)
 
123
    return error_count
 
124
  except KeyboardInterrupt:
 
125
    process.kill()
 
126
  except:
 
127
    print('Error running cpplint.py. Please make sure you have depot_tools' +
 
128
          ' in your $PATH. Lint check skipped.')
 
129
    process.kill()
 
130
 
 
131
 
104
132
class FileContentsCache(object):
105
133
 
106
134
  def __init__(self, sums_file_name):
206
234
      return True
207
235
 
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]
213
241
 
 
242
    commands = join([command + [file] for file in files])
 
243
    count = multiprocessing.cpu_count()
 
244
    pool = multiprocessing.Pool(count)
214
245
    try:
215
 
      process = subprocess.Popen(command, stderr=subprocess.PIPE)
216
 
    except:
217
 
      print('Error running cpplint.py. Please make sure you have depot_tools' +
218
 
            ' in your $PATH. Lint check skipped.')
219
 
      return True
220
 
    LINT_ERROR_PATTERN = re.compile(r'^(.+)[:(]\d+[:)]')
221
 
    while True:
222
 
      out_line = process.stderr.readline()
223
 
      if out_line == '' and process.poll() != None:
224
 
        break
225
 
      sys.stderr.write(out_line)
226
 
      m = LINT_ERROR_PATTERN.match(out_line)
227
 
      if m:
228
 
        good_files_cache.RemoveFile(m.group(1))
229
 
 
 
246
      results = pool.map_async(CppLintWorker, commands).get(999999)
 
247
    except KeyboardInterrupt:
 
248
      print "\nCaught KeyboardInterrupt, terminating workers."
 
249
      sys.exit(1)
 
250
 
 
251
    for i in range(len(files)):
 
252
      if results[i] > 0:
 
253
        good_files_cache.RemoveFile(files[i])
 
254
 
 
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
232
259
 
233
260
 
234
261
COPYRIGHT_HEADER_PATTERN = re.compile(