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
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 1d82318..2cefb36 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -96,6 +96,20 @@
 
   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 @@
 
   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 @@
         '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):