Added presubmit protecting against inclusion of rtc_base, while allowing rtc_base_approved.

BUG=N/A
R=andrew@webrtc.org, kjellander@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/29609004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7349 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrike@webrtc.org 2014-09-30 21:54:26 +00:00
parent 3037bc3447
commit 83fe69da95

View File

@ -96,6 +96,20 @@ def _CheckApprovedFilesLintClean(input_api, output_api,
return result
def _CheckNoRtcBaseDeps(input_api, gyp_files, output_api):
pattern = input_api.re.compile(r"base.gyp:rtc_base\s*'")
violating_files = []
for f in gyp_files:
contents = input_api.ReadFile(f)
if pattern.search(contents):
violating_files.append(f)
if violating_files:
return [output_api.PresubmitError(
'Depending on rtc_base is not allowed. Change your dependency to '
'rtc_base_approved and possibly sanitize and move the desired source '
'file(s) to rtc_base_approved.\nChanged GYP files:',
items=violating_files)]
return []
def _CheckGypChanges(input_api, output_api):
source_file_filter = lambda x: input_api.FilterSourceFile(
@ -103,7 +117,7 @@ def _CheckGypChanges(input_api, output_api):
gyp_files = []
for f in input_api.AffectedSourceFiles(source_file_filter):
gyp_files.append(f.LocalPath())
gyp_files.append(f)
result = []
if gyp_files:
@ -111,6 +125,7 @@ def _CheckGypChanges(input_api, output_api):
'As you\'re changing GYP files: please make sure corresponding '
'BUILD.gn files are also updated.\nChanged GYP files:',
items=gyp_files))
result.extend(_CheckNoRtcBaseDeps(input_api, gyp_files, output_api))
return result
def _CheckUnwantedDependencies(input_api, output_api):