Add presubmit warning about deprecated compiled_resources.gyp

Just use v2 instead ;) (compiled_resources2.gyp)

[email protected],[email protected]
BUG=585553

Review URL: https://codereview.chromium.org/1686663002

Cr-Commit-Position: refs/heads/master@{#374762}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index f7d2047..e680575 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1545,6 +1545,24 @@
   return []
 
 
+def _CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api):
+  """Checks for old style compiled_resources.gyp files."""
+  is_compiled_resource = lambda fp: fp.endswith('compiled_resources.gyp')
+
+  added_compiled_resources = filter(is_compiled_resource, [
+    f.LocalPath() for f in input_api.AffectedFiles() if f.Action() == 'A'
+  ])
+
+  if not added_compiled_resources:
+    return []
+
+  return [output_api.PresubmitError(
+      "Found new compiled_resources.gyp files:\n%s\n\n"
+      "compiled_resources.gyp files are deprecated,\n"
+      "please use compiled_resources2.gyp instead" %
+      "\n".join(added_compiled_resources))]
+
+
 _DEPRECATED_CSS = [
   # Values
   ( "-webkit-box", "flex" ),
@@ -1676,6 +1694,7 @@
   results.extend(_CheckForCopyrightedCode(input_api, output_api))
   results.extend(_CheckForWindowsLineEndings(input_api, output_api))
   results.extend(_CheckSingletonInHeaders(input_api, output_api))
+  results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api))
 
   if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
     results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 6b83350..90a8daf 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -416,6 +416,20 @@
     self.assertEqual(0, len(warnings))
 
 
+class CheckNoDeprecatedCompiledResourcesGYPTest(unittest.TestCase):
+  def testNoDeprecatedCompiledResourcsGYP(self):
+    mock_input_api = MockInputApi()
+    mock_input_api.files = [MockFile('some/js/compiled_resources.gyp', [])]
+    errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api,
+                                                              MockOutputApi())
+    self.assertEquals(1, len(errors))
+
+    mock_input_api.files = [MockFile('some/js/compiled_resources2.gyp', [])]
+    errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api,
+                                                              MockOutputApi())
+    self.assertEquals(0, len(errors))
+
+
 class InvalidOSMacroNamesTest(unittest.TestCase):
   def testInvalidOSMacroNames(self):
     lines = ['#if defined(OS_WINDOWS)',
diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py
index 8e15d8c..f68c134 100644
--- a/PRESUBMIT_test_mocks.py
+++ b/PRESUBMIT_test_mocks.py
@@ -97,6 +97,9 @@
     self._new_contents = new_contents
     self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
 
+  def Action(self):
+    return 'A'  # TODO(dbeam): feel free to change if your test actually uses.
+
   def ChangedContents(self):
     return self._changed_contents