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:

committed by
Commit Bot

parent
3cb525b378
commit
d74c0e600a
31
PRESUBMIT.py
31
PRESUBMIT.py
@ -941,6 +941,8 @@ def CommonChecks(input_api, output_api):
|
|||||||
input_api, output_api, non_third_party_sources))
|
input_api, output_api, non_third_party_sources))
|
||||||
results.extend(CheckBannedAbslMakeUnique(
|
results.extend(CheckBannedAbslMakeUnique(
|
||||||
input_api, output_api, non_third_party_sources))
|
input_api, output_api, non_third_party_sources))
|
||||||
|
results.extend(CheckObjcApiSymbols(
|
||||||
|
input_api, output_api, non_third_party_sources))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@ -1017,6 +1019,35 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
|
|||||||
files)]
|
files)]
|
||||||
return []
|
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):
|
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
|
||||||
pattern = input_api.re.compile(
|
pattern = input_api.re.compile(
|
||||||
r'^#include\s*"absl/memory/memory.h"', input_api.re.MULTILINE)
|
r'^#include\s*"absl/memory/memory.h"', input_api.re.MULTILINE)
|
||||||
|
Reference in New Issue
Block a user