OLD | NEW |
---|---|
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
11 import re | 11 import re |
12 import subprocess | |
12 import sys | 13 import sys |
13 | 14 |
14 | 15 |
15 # Directories that will be scanned by cpplint by the presubmit script. | 16 # Directories that will be scanned by cpplint by the presubmit script. |
16 CPPLINT_DIRS = [ | 17 CPPLINT_DIRS = [ |
17 'webrtc/audio', | 18 'webrtc/audio', |
18 'webrtc/call', | 19 'webrtc/call', |
19 'webrtc/common_video', | 20 'webrtc/common_video', |
20 'webrtc/examples', | 21 'webrtc/examples', |
21 'webrtc/modules/audio_mixer', | 22 'webrtc/modules/audio_mixer', |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 'webrtc/modules/video_coding/codecs/i420/include', | 78 'webrtc/modules/video_coding/codecs/i420/include', |
78 'webrtc/modules/video_coding/codecs/vp8/include', | 79 'webrtc/modules/video_coding/codecs/vp8/include', |
79 'webrtc/modules/video_coding/codecs/vp9/include', | 80 'webrtc/modules/video_coding/codecs/vp9/include', |
80 'webrtc/modules/video_coding/include', | 81 'webrtc/modules/video_coding/include', |
81 'webrtc/system_wrappers/include', | 82 'webrtc/system_wrappers/include', |
82 'webrtc/voice_engine/include', | 83 'webrtc/voice_engine/include', |
83 ) | 84 ) |
84 API_DIRS = NATIVE_API_DIRS[:] + LEGACY_API_DIRS[:] | 85 API_DIRS = NATIVE_API_DIRS[:] + LEGACY_API_DIRS[:] |
85 | 86 |
86 | 87 |
88 def _RunCommand(command, cwd): | |
89 """Runs a command and returns the output from that command.""" | |
90 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
91 cwd=cwd) | |
92 stdout = p.stdout.read() | |
93 stderr = p.stderr.read() | |
94 p.wait() | |
95 p.stdout.close() | |
96 p.stderr.close() | |
97 return p.returncode, stdout, stderr | |
98 | |
99 | |
87 def _VerifyNativeApiHeadersListIsValid(input_api, output_api): | 100 def _VerifyNativeApiHeadersListIsValid(input_api, output_api): |
88 """Ensures the list of native API header directories is up to date.""" | 101 """Ensures the list of native API header directories is up to date.""" |
89 non_existing_paths = [] | 102 non_existing_paths = [] |
90 native_api_full_paths = [ | 103 native_api_full_paths = [ |
91 input_api.os_path.join(input_api.PresubmitLocalPath(), | 104 input_api.os_path.join(input_api.PresubmitLocalPath(), |
92 *path.split('/')) for path in API_DIRS] | 105 *path.split('/')) for path in API_DIRS] |
93 for path in native_api_full_paths: | 106 for path in native_api_full_paths: |
94 if not os.path.isdir(path): | 107 if not os.path.isdir(path): |
95 non_existing_paths.append(path) | 108 non_existing_paths.append(path) |
96 if non_existing_paths: | 109 if non_existing_paths: |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 if violating_gn_files: | 291 if violating_gn_files: |
279 return [output_api.PresubmitError( | 292 return [output_api.PresubmitError( |
280 'GN targets cannot mix .cc and .c source files. Please create a ' | 293 'GN targets cannot mix .cc and .c source files. Please create a ' |
281 'separate target for each collection of sources.\n' | 294 'separate target for each collection of sources.\n' |
282 'Mixed sources: \n' | 295 'Mixed sources: \n' |
283 '%s\n' | 296 '%s\n' |
284 'Violating GN files:' % json.dumps(violating_gn_files, indent=2), | 297 'Violating GN files:' % json.dumps(violating_gn_files, indent=2), |
285 items=violating_gn_files.keys())] | 298 items=violating_gn_files.keys())] |
286 return [] | 299 return [] |
287 | 300 |
301 def _CheckNoPackageBoundaryViolations(input_api, gn_files, output_api): | |
302 cwd = input_api.PresubmitLocalPath() | |
303 script_path = os.path.join('tools-webrtc', 'check_package_boundaries.py') | |
304 webrtc_path = os.path.join('webrtc') | |
305 command = ['python', script_path, '--max_messages=1', webrtc_path] | |
306 command += [gn_file.LocalPath() for gn_file in gn_files] | |
307 returncode, _, stderr = _RunCommand(command, cwd) | |
308 if returncode: | |
309 return [output_api.PresubmitError( | |
310 'There are package boundary violations in the following GN files:\n\n' | |
kjellander_webrtc
2017/01/16 07:26:10
I think since most people are not familiar with wh
ehmaldonado_webrtc
2017/01/16 08:52:50
Acknowledged.
| |
311 '%s' % stderr)] | |
312 return [] | |
313 | |
288 def _CheckGnChanges(input_api, output_api): | 314 def _CheckGnChanges(input_api, output_api): |
289 source_file_filter = lambda x: input_api.FilterSourceFile( | 315 source_file_filter = lambda x: input_api.FilterSourceFile( |
290 x, white_list=(r'.+\.(gn|gni)$',)) | 316 x, white_list=(r'.+\.(gn|gni)$',)) |
291 | 317 |
292 gn_files = [] | 318 gn_files = [] |
293 for f in input_api.AffectedSourceFiles(source_file_filter): | 319 for f in input_api.AffectedSourceFiles(source_file_filter): |
294 if f.LocalPath().startswith('webrtc'): | 320 if f.LocalPath().startswith('webrtc'): |
295 gn_files.append(f) | 321 gn_files.append(f) |
296 | 322 |
297 result = [] | 323 result = [] |
298 if gn_files: | 324 if gn_files: |
299 result.extend(_CheckNoSourcesAbove(input_api, gn_files, output_api)) | 325 result.extend(_CheckNoSourcesAbove(input_api, gn_files, output_api)) |
300 result.extend(_CheckNoMixingCAndCCSources(input_api, gn_files, output_api)) | 326 result.extend(_CheckNoMixingCAndCCSources(input_api, gn_files, output_api)) |
327 result.extend(_CheckNoPackageBoundaryViolations( | |
328 input_api, gn_files, output_api)) | |
301 return result | 329 return result |
302 | 330 |
303 def _CheckUnwantedDependencies(input_api, output_api): | 331 def _CheckUnwantedDependencies(input_api, output_api): |
304 """Runs checkdeps on #include statements added in this | 332 """Runs checkdeps on #include statements added in this |
305 change. Breaking - rules is an error, breaking ! rules is a | 333 change. Breaking - rules is an error, breaking ! rules is a |
306 warning. | 334 warning. |
307 """ | 335 """ |
308 # Copied from Chromium's src/PRESUBMIT.py. | 336 # Copied from Chromium's src/PRESUBMIT.py. |
309 | 337 |
310 # We need to wait until we have an input_api object and use this | 338 # We need to wait until we have an input_api object and use this |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 input_api, output_api)) | 535 input_api, output_api)) |
508 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 536 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
509 input_api, output_api)) | 537 input_api, output_api)) |
510 results.extend(_CheckChangeHasBugField(input_api, output_api)) | 538 results.extend(_CheckChangeHasBugField(input_api, output_api)) |
511 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 539 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
512 input_api, output_api)) | 540 input_api, output_api)) |
513 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 541 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
514 input_api, output_api, | 542 input_api, output_api, |
515 json_url='http://webrtc-status.appspot.com/current?format=json')) | 543 json_url='http://webrtc-status.appspot.com/current?format=json')) |
516 return results | 544 return results |
OLD | NEW |