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 platform | 11 import platform |
12 import re | 12 import re |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 | 16 |
17 NATIVE_API_DIRS = ( | |
18 'talk/app/webrtc', | |
19 'webrtc', | |
20 'webrtc/common_audio/include', # DEPRECATED (will go away). | |
21 'webrtc/modules/audio_coding/include', | |
22 'webrtc/modules/audio_conference_mixer/include', # DEPRECATED (will go away). | |
23 'webrtc/modules/audio_device/include', | |
24 'webrtc/modules/audio_processing/include', | |
25 'webrtc/modules/bitrate_controller/include', | |
26 'webrtc/modules/include', | |
27 'webrtc/modules/remote_bitrate_estimator/include', | |
28 'webrtc/modules/rtp_rtcp/include', | |
29 'webrtc/modules/rtp_rtcp/source', # DEPRECATED (will go away). | |
30 'webrtc/modules/utility/include', | |
31 'webrtc/modules/video_coding/codecs/h264/include', | |
32 'webrtc/modules/video_coding/codecs/i420/include', | |
33 'webrtc/modules/video_coding/codecs/vp8/include', | |
34 'webrtc/modules/video_coding/codecs/vp9/include', | |
35 'webrtc/modules/video_coding/include', | |
36 'webrtc/system_wrappers/include', | |
Andrew MacDonald
2015/11/30 17:12:36
This should be deprecated to, no? If anything webr
kjellander_webrtc
2015/11/30 17:29:26
That makes sense. I added a similar comment for it
| |
37 'webrtc/voice_engine/include', | |
38 ) | |
39 | |
40 | |
41 def _VerifyNativeApiHeadersListIsValid(input_api, output_api): | |
42 """Ensures the list of native API header directories is up to date.""" | |
43 non_existing_paths = [] | |
44 native_api_full_paths = [ | |
45 input_api.os_path.join(input_api.PresubmitLocalPath(), | |
46 *path.split('/')) for path in NATIVE_API_DIRS] | |
47 for path in native_api_full_paths: | |
48 if not os.path.isdir(path): | |
49 non_existing_paths.append(path) | |
50 if non_existing_paths: | |
51 return [output_api.PresubmitError( | |
52 'Directories to native API headers have changed which has made the ' | |
53 'list in PRESUBMIT.py outdated.\nPlease update it to the current ' | |
54 'location of our native APIs.', | |
55 non_existing_paths)] | |
56 return [] | |
57 | |
58 | |
59 def _CheckNativeApiHeaderChanges(input_api, output_api): | |
60 """Checks to remind proper changing of native APIs.""" | |
61 files = [] | |
62 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | |
63 if f.LocalPath().endswith('.h'): | |
64 for path in NATIVE_API_DIRS: | |
65 if os.path.dirname(f.LocalPath()) == path: | |
66 files.append(f) | |
67 | |
68 if files: | |
69 return [output_api.PresubmitPromptWarning( | |
70 'You seem to be changing native API header files. Please make sure ' | |
71 'you:\n' | |
72 ' 1. Make compatible changes that don\'t break existing clients.\n' | |
73 ' 2. Mark the old APIs as deprecated.\n' | |
74 ' 3. Create a timeline and plan for when the deprecated method will ' | |
75 'be removed (preferably 3 months or so).\n' | |
76 ' 4. Update/inform existing downstream code owners to stop using the ' | |
77 'deprecated APIs: \n' | |
78 'send announcement to discuss-webrtc@googlegroups.com and ' | |
79 'webrtc-users@google.com.\n' | |
80 ' 5. (after ~3 months) remove the deprecated API.\n' | |
81 'Related files:', | |
82 files)] | |
83 return [] | |
84 | |
85 | |
17 def _CheckNoIOStreamInHeaders(input_api, output_api): | 86 def _CheckNoIOStreamInHeaders(input_api, output_api): |
18 """Checks to make sure no .h files include <iostream>.""" | 87 """Checks to make sure no .h files include <iostream>.""" |
19 files = [] | 88 files = [] |
20 pattern = input_api.re.compile(r'^#include\s*<iostream>', | 89 pattern = input_api.re.compile(r'^#include\s*<iostream>', |
21 input_api.re.MULTILINE) | 90 input_api.re.MULTILINE) |
22 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | 91 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
23 if not f.LocalPath().endswith('.h'): | 92 if not f.LocalPath().endswith('.h'): |
24 continue | 93 continue |
25 contents = input_api.ReadFile(f) | 94 contents = input_api.ReadFile(f) |
26 if pattern.search(contents): | 95 if pattern.search(contents): |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS')) | 361 black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS')) |
293 results.extend(input_api.canned_checks.CheckLongLines( | 362 results.extend(input_api.canned_checks.CheckLongLines( |
294 input_api, output_api, maxlen=80, source_file_filter=long_lines_sources)) | 363 input_api, output_api, maxlen=80, source_file_filter=long_lines_sources)) |
295 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( | 364 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( |
296 input_api, output_api)) | 365 input_api, output_api)) |
297 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( | 366 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( |
298 input_api, output_api)) | 367 input_api, output_api)) |
299 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( | 368 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( |
300 input_api, output_api)) | 369 input_api, output_api)) |
301 results.extend(_CheckApprovedFilesLintClean(input_api, output_api)) | 370 results.extend(_CheckApprovedFilesLintClean(input_api, output_api)) |
371 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api)) | |
302 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 372 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
303 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 373 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
304 results.extend(_CheckGypChanges(input_api, output_api)) | 374 results.extend(_CheckGypChanges(input_api, output_api)) |
305 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 375 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
306 results.extend(_RunPythonTests(input_api, output_api)) | 376 results.extend(_RunPythonTests(input_api, output_api)) |
307 return results | 377 return results |
308 | 378 |
309 | 379 |
310 def CheckChangeOnUpload(input_api, output_api): | 380 def CheckChangeOnUpload(input_api, output_api): |
311 results = [] | 381 results = [] |
312 results.extend(_CommonChecks(input_api, output_api)) | 382 results.extend(_CommonChecks(input_api, output_api)) |
313 results.extend( | 383 results.extend( |
314 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 384 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
315 return results | 385 return results |
316 | 386 |
317 | 387 |
318 def CheckChangeOnCommit(input_api, output_api): | 388 def CheckChangeOnCommit(input_api, output_api): |
319 results = [] | 389 results = [] |
320 results.extend(_CommonChecks(input_api, output_api)) | 390 results.extend(_CommonChecks(input_api, output_api)) |
391 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) | |
321 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 392 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
322 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 393 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
323 input_api, output_api)) | 394 input_api, output_api)) |
324 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 395 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
325 input_api, output_api)) | 396 input_api, output_api)) |
326 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 397 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
327 input_api, output_api)) | 398 input_api, output_api)) |
328 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 399 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
329 input_api, output_api)) | 400 input_api, output_api)) |
330 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 401 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
(...skipping 18 matching lines...) Expand all Loading... | |
349 for builder in masters[master]: | 420 for builder in masters[master]: |
350 if 'presubmit' in builder: | 421 if 'presubmit' in builder: |
351 # Do not trigger presubmit builders, since they're likely to fail | 422 # Do not trigger presubmit builders, since they're likely to fail |
352 # (e.g. OWNERS checks before finished code review), and we're running | 423 # (e.g. OWNERS checks before finished code review), and we're running |
353 # local presubmit anyway. | 424 # local presubmit anyway. |
354 pass | 425 pass |
355 else: | 426 else: |
356 try_config[master][builder] = ['defaulttests'] | 427 try_config[master][builder] = ['defaulttests'] |
357 | 428 |
358 return try_config | 429 return try_config |
OLD | NEW |