mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Use checkdeps to ensure API headers don't include internal headers.
This CL updates the checkdeps configuration for the api/ folder in order to explicitly avoid to #include non API headers from API headers. In order to force a careful review of potential exceptions to this rule, the CL also adds mbonadei@ and kwiberg@ as OWNERS of api/DEPS. Bug: webrtc:9887 Change-Id: I0ada6f1020186b2782c7d060af36079c452ba1aa Reviewed-on: https://webrtc-review.googlesource.com/c/106800 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25338}
This commit is contained in:
parent
ec9b77bc42
commit
a418e67c53
3 changed files with 352 additions and 11 deletions
56
PRESUBMIT.py
56
PRESUBMIT.py
|
@ -862,6 +862,62 @@ def CommonChecks(input_api, output_api):
|
|||
results.extend(CheckNoStreamUsageIsAdded(
|
||||
input_api, output_api, non_third_party_sources))
|
||||
results.extend(CheckAddedDepsHaveTargetApprovals(input_api, output_api))
|
||||
results.extend(CheckApiDepsFileIsUpToDate(input_api, output_api))
|
||||
return results
|
||||
|
||||
|
||||
def CheckApiDepsFileIsUpToDate(input_api, output_api):
|
||||
results = []
|
||||
api_deps = os.path.join(input_api.PresubmitLocalPath(), 'api', 'DEPS')
|
||||
with open(api_deps) as f:
|
||||
deps_content = _ParseDeps(f.read())
|
||||
|
||||
include_rules = deps_content.get('include_rules', [])
|
||||
specific_include_rules = deps_content.get('specific_include_rules', [])
|
||||
cc_include_rules = specific_include_rules.get(r'.*\.cc', [])
|
||||
|
||||
top_level_files = [f for f in os.listdir(input_api.PresubmitLocalPath())
|
||||
if f != 'api' and not f.startswith('.')]
|
||||
top_level_dirs = []
|
||||
for f in top_level_files:
|
||||
if os.path.isdir(os.path.join(input_api.PresubmitLocalPath(), f)):
|
||||
top_level_dirs.append(f)
|
||||
|
||||
missing_include_rules = []
|
||||
for p in top_level_dirs:
|
||||
rule = '-%s' % p
|
||||
if rule not in include_rules:
|
||||
missing_include_rules.append(rule)
|
||||
if missing_include_rules:
|
||||
results.append(output_api.PresubmitError(
|
||||
'Please add the following lines to `include_rules` in file\n'
|
||||
'%s:\n%s' % (api_deps, str(missing_include_rules))))
|
||||
|
||||
missing_cc_include_rules = []
|
||||
non_webrtc_dirs = [
|
||||
'base',
|
||||
'build',
|
||||
'build_overrides',
|
||||
'buildtools',
|
||||
'data',
|
||||
'infra',
|
||||
'out',
|
||||
'resources',
|
||||
'testing',
|
||||
'style-guide',
|
||||
]
|
||||
webrtc_top_level_dirs = [d for d in top_level_dirs
|
||||
if d not in non_webrtc_dirs]
|
||||
|
||||
for p in webrtc_top_level_dirs:
|
||||
rule = '+%s' % p
|
||||
if rule not in cc_include_rules:
|
||||
missing_cc_include_rules.append(rule)
|
||||
if missing_cc_include_rules:
|
||||
results.append(output_api.PresubmitError(
|
||||
r'Please add the following lines to the `.*\.cc` rule under '
|
||||
'`specific_include_rules` in file\n'
|
||||
'%s:\n%s' % (api_deps, str(missing_cc_include_rules))))
|
||||
return results
|
||||
|
||||
|
||||
|
|
304
api/DEPS
304
api/DEPS
|
@ -1,14 +1,51 @@
|
|||
include_rules = [
|
||||
"+third_party/libyuv",
|
||||
"+media",
|
||||
"+p2p",
|
||||
"+pc",
|
||||
"+logging/rtc_event_log/rtc_event_log_factory_interface.h",
|
||||
"+modules/audio_processing/include",
|
||||
"+system_wrappers/include",
|
||||
"-audio",
|
||||
"-base",
|
||||
"-build",
|
||||
"-buildtools",
|
||||
"-build_overrides",
|
||||
"-call",
|
||||
"-common_audio",
|
||||
"-common_video",
|
||||
"-data",
|
||||
"-examples",
|
||||
"-infra",
|
||||
"-logging",
|
||||
"-media",
|
||||
"-modules",
|
||||
"-out",
|
||||
"-p2p",
|
||||
"-pc",
|
||||
"-resources",
|
||||
"-rtc_base",
|
||||
"-rtc_tools",
|
||||
"-sdk",
|
||||
"-stats",
|
||||
"-style-guide",
|
||||
"-system_wrappers",
|
||||
"-test",
|
||||
"-testing",
|
||||
"-third_party",
|
||||
"-tools",
|
||||
"-tools_webrtc",
|
||||
"-video",
|
||||
"-external/webrtc/webrtc", # Android platform build.
|
||||
"-libyuv",
|
||||
"-common_types.h",
|
||||
"-WebRTC",
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
# Some internal headers are allowed even in API headers:
|
||||
".*\.h": [
|
||||
"+rtc_base/checks.h",
|
||||
"+rtc_base/system/rtc_export.h",
|
||||
],
|
||||
|
||||
"array_view\.h": [
|
||||
"+rtc_base/type_traits.h",
|
||||
],
|
||||
|
||||
# Needed because AudioEncoderOpus is in the wrong place for
|
||||
# backwards compatibilty reasons. See
|
||||
# https://bugs.chromium.org/p/webrtc/issues/detail?id=7847
|
||||
|
@ -16,14 +53,259 @@ specific_include_rules = {
|
|||
"+modules/audio_coding/codecs/opus/audio_encoder_opus.h",
|
||||
],
|
||||
|
||||
"asyncresolverfactory\.h": [
|
||||
"+rtc_base/asyncresolverinterface.h",
|
||||
],
|
||||
|
||||
"candidate\.h": [
|
||||
"+rtc_base/network_constants.h",
|
||||
"+rtc_base/socketaddress.h",
|
||||
],
|
||||
|
||||
"datachannelinterface\.h": [
|
||||
"+rtc_base/copyonwritebuffer.h",
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"dtmfsenderinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"fec_controller\.h": [
|
||||
"+modules/include/module_fec_types.h",
|
||||
],
|
||||
|
||||
"jsep\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"jsepicecandidate\.h": [
|
||||
"+rtc_base/constructormagic.h",
|
||||
],
|
||||
|
||||
"jsepsessiondescription\.h": [
|
||||
"+rtc_base/constructormagic.h",
|
||||
],
|
||||
|
||||
"mediastreaminterface\.h": [
|
||||
"+modules/audio_processing/include/audio_processing_statistics.h",
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"peerconnectionfactoryproxy\.h": [
|
||||
"+rtc_base/bind.h",
|
||||
],
|
||||
|
||||
"refcountedbase\.h": [
|
||||
"+rtc_base/constructormagic.h",
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/refcounter.h",
|
||||
],
|
||||
|
||||
"rtcerror\.h": [
|
||||
"+rtc_base/logging.h",
|
||||
],
|
||||
|
||||
"rtpreceiverinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"rtpsenderinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"rtptransceiverinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"setremotedescriptionobserverinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"statstypes\.h": [
|
||||
"+rtc_base/constructormagic.h",
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
"+rtc_base/stringencode.h",
|
||||
"+rtc_base/thread_checker.h",
|
||||
],
|
||||
|
||||
"umametrics\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"audio_frame\.h": [
|
||||
"+rtc_base/constructormagic.h",
|
||||
],
|
||||
|
||||
"audio_mixer\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"audio_decoder\.h": [
|
||||
"+rtc_base/buffer.h",
|
||||
"+rtc_base/constructormagic.h",
|
||||
],
|
||||
|
||||
"audio_decoder_factory\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"audio_decoder_factory_template\.h": [
|
||||
"+rtc_base/refcountedobject.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"audio_encoder\.h": [
|
||||
"+rtc_base/buffer.h",
|
||||
"+rtc_base/deprecation.h",
|
||||
],
|
||||
|
||||
"audio_encoder_factory\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"audio_encoder_factory_template\.h": [
|
||||
"+rtc_base/refcountedobject.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"builtin_audio_decoder_factory\.h": [
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"builtin_audio_encoder_factory\.h": [
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"framedecryptorinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"frameencryptorinterface\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
],
|
||||
|
||||
"ortcfactoryinterface\.h": [
|
||||
"+rtc_base/network.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
"+rtc_base/thread.h",
|
||||
],
|
||||
|
||||
"udptransportinterface\.h": [
|
||||
"+rtc_base/socketaddress.h",
|
||||
],
|
||||
|
||||
"rtcstatscollectorcallback\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"rtcstatsreport\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/refcountedobject.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"audioproc_float\.h": [
|
||||
"+modules/audio_processing/include/audio_processing.h",
|
||||
],
|
||||
|
||||
"fake_frame_decryptor\.h": [
|
||||
"+rtc_base/refcountedobject.h",
|
||||
],
|
||||
|
||||
"fake_frame_encryptor\.h": [
|
||||
"+rtc_base/refcountedobject.h",
|
||||
],
|
||||
|
||||
"fakeconstraints\.h": [
|
||||
"+rtc_base/stringencode.h",
|
||||
],
|
||||
|
||||
"mock.*\.h": [
|
||||
"+test/gmock.h",
|
||||
],
|
||||
|
||||
"simulated_network\.h": [
|
||||
"+rtc_base/criticalsection.h",
|
||||
"+rtc_base/random.h",
|
||||
"+rtc_base/thread_annotations.h",
|
||||
],
|
||||
|
||||
"test_dependency_factory\.h": [
|
||||
"+rtc_base/thread_checker.h",
|
||||
],
|
||||
|
||||
"videocodec_test_fixture\.h": [
|
||||
"+modules/video_coding/include/video_codec_interface.h"
|
||||
],
|
||||
|
||||
"data_rate\.h": [
|
||||
"+rtc_base/numerics/safe_conversions.h",
|
||||
],
|
||||
|
||||
"data_size\.h": [
|
||||
"+rtc_base/numerics/safe_conversions.h",
|
||||
],
|
||||
|
||||
"time_delta\.h": [
|
||||
"+rtc_base/numerics/safe_conversions.h",
|
||||
],
|
||||
|
||||
"timestamp\.h": [
|
||||
"+rtc_base/numerics/safe_conversions.h",
|
||||
],
|
||||
|
||||
"i010_buffer\.h": [
|
||||
"+rtc_base/memory/aligned_malloc.h"
|
||||
],
|
||||
|
||||
"i420_buffer\.h": [
|
||||
"+rtc_base/memory/aligned_malloc.h",
|
||||
],
|
||||
|
||||
"video_frame_buffer\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
"video_timing\.h": [
|
||||
"+rtc_base/numerics/safe_conversions.h",
|
||||
],
|
||||
|
||||
"video_encoder_config\.h": [
|
||||
"+rtc_base/refcount.h",
|
||||
"+rtc_base/scoped_ref_ptr.h",
|
||||
],
|
||||
|
||||
# We allow .cc files in webrtc/api/ to #include a bunch of stuff
|
||||
# that's off-limits for the .h files. That's because .h files leak
|
||||
# their #includes to whoever's #including them, but .cc files do not
|
||||
# since no one #includes them.
|
||||
".*\.cc": [
|
||||
"+modules/audio_coding",
|
||||
"+modules/audio_processing",
|
||||
"+modules/video_coding",
|
||||
"+modules/congestion_controller",
|
||||
"+audio",
|
||||
"+call",
|
||||
"+common_audio",
|
||||
"+common_video",
|
||||
"+examples",
|
||||
"+logging",
|
||||
"+media",
|
||||
"+modules",
|
||||
"+p2p",
|
||||
"+pc",
|
||||
"+rtc_base",
|
||||
"+rtc_tools",
|
||||
"+sdk",
|
||||
"+stats",
|
||||
"+system_wrappers",
|
||||
"+test",
|
||||
"+tools",
|
||||
"+tools_webrtc",
|
||||
"+video",
|
||||
"+third_party",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -13,3 +13,6 @@ per-file peerconnection*=hbos@webrtc.org
|
|||
|
||||
per-file *.gn=phoglund@webrtc.org
|
||||
per-file *.gni=phoglund@webrtc.org
|
||||
|
||||
per-file DEPS=mbonadei@webrtc.org
|
||||
per-file DEPS=kwiberg@webrtc.org
|
||||
|
|
Loading…
Reference in a new issue