Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: PRESUBMIT.py

Issue 1408783008: Add PRESUBMIT check for native API changes. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase + added deprecation notice for system_wrappers Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # Directories that will be scanned by cpplint by the presubmit script. 17 # Directories that will be scanned by cpplint by the presubmit script.
18 CPPLINT_DIRS = [ 18 CPPLINT_DIRS = [
19 'webrtc/video_engine', 19 'webrtc/video_engine',
20 ] 20 ]
21 21
22 NATIVE_API_DIRS = (
23 'talk/app/webrtc',
24 'webrtc',
25 'webrtc/common_audio/include', # DEPRECATED (will go away).
26 'webrtc/modules/audio_coding/include',
27 'webrtc/modules/audio_conference_mixer/include', # DEPRECATED (will go away).
28 'webrtc/modules/audio_device/include',
29 'webrtc/modules/audio_processing/include',
30 'webrtc/modules/bitrate_controller/include',
31 'webrtc/modules/include',
32 'webrtc/modules/remote_bitrate_estimator/include',
33 'webrtc/modules/rtp_rtcp/include',
34 'webrtc/modules/rtp_rtcp/source', # DEPRECATED (will go away).
35 'webrtc/modules/utility/include',
36 'webrtc/modules/video_coding/codecs/h264/include',
37 'webrtc/modules/video_coding/codecs/i420/include',
38 'webrtc/modules/video_coding/codecs/vp8/include',
39 'webrtc/modules/video_coding/codecs/vp9/include',
40 'webrtc/modules/video_coding/include',
41 'webrtc/system_wrappers/include', # DEPRECATED (will go away).
42 'webrtc/voice_engine/include',
43 )
44
45
46 def _VerifyNativeApiHeadersListIsValid(input_api, output_api):
47 """Ensures the list of native API header directories is up to date."""
48 non_existing_paths = []
49 native_api_full_paths = [
50 input_api.os_path.join(input_api.PresubmitLocalPath(),
51 *path.split('/')) for path in NATIVE_API_DIRS]
52 for path in native_api_full_paths:
53 if not os.path.isdir(path):
54 non_existing_paths.append(path)
55 if non_existing_paths:
56 return [output_api.PresubmitError(
57 'Directories to native API headers have changed which has made the '
58 'list in PRESUBMIT.py outdated.\nPlease update it to the current '
59 'location of our native APIs.',
60 non_existing_paths)]
61 return []
62
63
64 def _CheckNativeApiHeaderChanges(input_api, output_api):
65 """Checks to remind proper changing of native APIs."""
66 files = []
67 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
68 if f.LocalPath().endswith('.h'):
69 for path in NATIVE_API_DIRS:
70 if os.path.dirname(f.LocalPath()) == path:
71 files.append(f)
72
73 if files:
74 return [output_api.PresubmitPromptWarning(
75 'You seem to be changing native API header files. Please make sure '
76 'you:\n'
77 ' 1. Make compatible changes that don\'t break existing clients.\n'
78 ' 2. Mark the old APIs as deprecated.\n'
79 ' 3. Create a timeline and plan for when the deprecated method will '
80 'be removed (preferably 3 months or so).\n'
81 ' 4. Update/inform existing downstream code owners to stop using the '
82 'deprecated APIs: \n'
83 'send announcement to discuss-webrtc@googlegroups.com and '
84 'webrtc-users@google.com.\n'
85 ' 5. (after ~3 months) remove the deprecated API.\n'
86 'Related files:',
87 files)]
88 return []
89
22 90
23 def _CheckNoIOStreamInHeaders(input_api, output_api): 91 def _CheckNoIOStreamInHeaders(input_api, output_api):
24 """Checks to make sure no .h files include <iostream>.""" 92 """Checks to make sure no .h files include <iostream>."""
25 files = [] 93 files = []
26 pattern = input_api.re.compile(r'^#include\s*<iostream>', 94 pattern = input_api.re.compile(r'^#include\s*<iostream>',
27 input_api.re.MULTILINE) 95 input_api.re.MULTILINE)
28 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 96 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
29 if not f.LocalPath().endswith('.h'): 97 if not f.LocalPath().endswith('.h'):
30 continue 98 continue
31 contents = input_api.ReadFile(f) 99 contents = input_api.ReadFile(f)
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 long_lines_sources = lambda x: input_api.FilterSourceFile(x, 385 long_lines_sources = lambda x: input_api.FilterSourceFile(x,
318 black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS')) 386 black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS'))
319 results.extend(input_api.canned_checks.CheckLongLines( 387 results.extend(input_api.canned_checks.CheckLongLines(
320 input_api, output_api, maxlen=80, source_file_filter=long_lines_sources)) 388 input_api, output_api, maxlen=80, source_file_filter=long_lines_sources))
321 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( 389 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
322 input_api, output_api)) 390 input_api, output_api))
323 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( 391 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
324 input_api, output_api)) 392 input_api, output_api))
325 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( 393 results.extend(input_api.canned_checks.CheckChangeTodoHasOwner(
326 input_api, output_api)) 394 input_api, output_api))
395 results.extend(_CheckApprovedFilesLintClean(input_api, output_api))
396 results.extend(_CheckNativeApiHeaderChanges(input_api, output_api))
327 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 397 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
328 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) 398 results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
329 results.extend(_CheckGypChanges(input_api, output_api)) 399 results.extend(_CheckGypChanges(input_api, output_api))
330 results.extend(_CheckUnwantedDependencies(input_api, output_api)) 400 results.extend(_CheckUnwantedDependencies(input_api, output_api))
331 results.extend(_RunPythonTests(input_api, output_api)) 401 results.extend(_RunPythonTests(input_api, output_api))
332 return results 402 return results
333 403
334 404
335 def CheckChangeOnUpload(input_api, output_api): 405 def CheckChangeOnUpload(input_api, output_api):
336 results = [] 406 results = []
337 results.extend(_CommonChecks(input_api, output_api)) 407 results.extend(_CommonChecks(input_api, output_api))
338 results.extend( 408 results.extend(
339 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) 409 input_api.canned_checks.CheckGNFormatted(input_api, output_api))
340 return results 410 return results
341 411
342 412
343 def CheckChangeOnCommit(input_api, output_api): 413 def CheckChangeOnCommit(input_api, output_api):
344 results = [] 414 results = []
345 results.extend(_CommonChecks(input_api, output_api)) 415 results.extend(_CommonChecks(input_api, output_api))
416 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api))
346 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) 417 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
347 results.extend(input_api.canned_checks.CheckChangeWasUploaded( 418 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
348 input_api, output_api)) 419 input_api, output_api))
349 results.extend(input_api.canned_checks.CheckChangeHasDescription( 420 results.extend(input_api.canned_checks.CheckChangeHasDescription(
350 input_api, output_api)) 421 input_api, output_api))
351 results.extend(input_api.canned_checks.CheckChangeHasBugField( 422 results.extend(input_api.canned_checks.CheckChangeHasBugField(
352 input_api, output_api)) 423 input_api, output_api))
353 results.extend(input_api.canned_checks.CheckChangeHasTestField( 424 results.extend(input_api.canned_checks.CheckChangeHasTestField(
354 input_api, output_api)) 425 input_api, output_api))
355 results.extend(input_api.canned_checks.CheckTreeIsOpen( 426 results.extend(input_api.canned_checks.CheckTreeIsOpen(
(...skipping 18 matching lines...) Expand all
374 for builder in masters[master]: 445 for builder in masters[master]:
375 if 'presubmit' in builder: 446 if 'presubmit' in builder:
376 # Do not trigger presubmit builders, since they're likely to fail 447 # Do not trigger presubmit builders, since they're likely to fail
377 # (e.g. OWNERS checks before finished code review), and we're running 448 # (e.g. OWNERS checks before finished code review), and we're running
378 # local presubmit anyway. 449 # local presubmit anyway.
379 pass 450 pass
380 else: 451 else:
381 try_config[master][builder] = ['defaulttests'] 452 try_config[master][builder] = ['defaulttests']
382 453
383 return try_config 454 return try_config
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698