From 83fe69da95bde17a8a80c4e9f8aaa1fe1439be85 Mon Sep 17 00:00:00 2001 From: "henrike@webrtc.org" Date: Tue, 30 Sep 2014 21:54:26 +0000 Subject: [PATCH] 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 --- PRESUBMIT.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 1d823184f..2cefb3613 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -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):