mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Add presubmit test to use RTC_OBJC_TYPE on RTC_OBJC_EXPORT types.
Bug: None Change-Id: I0962cadbcf7db920b5e400b80cfd04c937cdcedc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179524 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31755}
This commit is contained in:
parent
3cb525b378
commit
d74c0e600a
2 changed files with 33 additions and 2 deletions
31
PRESUBMIT.py
31
PRESUBMIT.py
|
@ -941,6 +941,8 @@ def CommonChecks(input_api, output_api):
|
|||
input_api, output_api, non_third_party_sources))
|
||||
results.extend(CheckBannedAbslMakeUnique(
|
||||
input_api, output_api, non_third_party_sources))
|
||||
results.extend(CheckObjcApiSymbols(
|
||||
input_api, output_api, non_third_party_sources))
|
||||
return results
|
||||
|
||||
|
||||
|
@ -1017,6 +1019,35 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
|||
files)]
|
||||
return []
|
||||
|
||||
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
file_filter = lambda f: (f.LocalPath().endswith(('.h'))
|
||||
and source_file_filter(f))
|
||||
|
||||
files = []
|
||||
file_filter = lambda x: (input_api.FilterSourceFile(x)
|
||||
and source_file_filter(x))
|
||||
for f in input_api.AffectedSourceFiles(file_filter):
|
||||
if not f.LocalPath().endswith('.h') or not 'sdk/objc' in f.LocalPath():
|
||||
continue
|
||||
contents = input_api.ReadFile(f)
|
||||
for match in rtc_objc_export.finditer(contents):
|
||||
export_block = match.group(0)
|
||||
if 'RTC_OBJC_TYPE' not in export_block:
|
||||
files.append(f.LocalPath())
|
||||
|
||||
if len(files):
|
||||
return [output_api.PresubmitError(
|
||||
'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() ' +
|
||||
'macro.\n\n' +
|
||||
'For example:\n' +
|
||||
'RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||
'RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE(RtcFoo)\n\n' +
|
||||
'Please fix the following files:',
|
||||
files)]
|
||||
return []
|
||||
|
||||
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
|
||||
pattern = input_api.re.compile(
|
||||
r'^#include\s*"absl/memory/memory.h"', input_api.re.MULTILINE)
|
||||
|
|
|
@ -21,8 +21,8 @@ RTC_OBJC_EXPORT
|
|||
@protocol RTC_OBJC_TYPE
|
||||
(RTCRtpSender)<NSObject>
|
||||
|
||||
/** A unique identifier for this sender. */
|
||||
@property(nonatomic, readonly) NSString *senderId;
|
||||
/** A unique identifier for this sender. */
|
||||
@property(nonatomic, readonly) NSString *senderId;
|
||||
|
||||
/** The currently active RTCRtpParameters, as defined in
|
||||
* https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters.
|
||||
|
|
Loading…
Reference in a new issue