Skip to content

Commit

Permalink
Mojo C++ bindings: add a presubmit check to disallow adding new mojom…
Browse files Browse the repository at this point in the history
… targets with use_new_wrapper_types set to false.

BUG=624136

Review-Url: https://codereview.chromium.org/2179113002
Cr-Commit-Position: refs/heads/master@{#407595}
  • Loading branch information
yzshen authored and Commit bot committed Jul 25, 2016
1 parent 84c46fa commit d99f726
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,32 @@ def _CheckIpcOwners(input_api, output_api):
return results


def _CheckMojoUsesNewWrapperTypes(input_api, output_api):
"""Checks to make sure that all newly added mojom targets map array/map/string
to STL (for chromium) or WTF (for blink) types.
TODO(yzshen): remove this check once crbug.com/624136 is completed.
"""
files = []
pattern = input_api.re.compile(r'use_new_wrapper_types.*false',
input_api.re.MULTILINE)

for f in input_api.AffectedFiles():
if not f.LocalPath().endswith(('.gyp', '.gypi', 'gn', 'gni')):
continue

for _, line in f.ChangedContents():
if pattern.search(line):
files.append(f)
break

if len(files):
return [output_api.PresubmitError(
'Do not introduce new mojom targets with use_new_wrapper_types set to '
'false. The mode is deprecated and will be removed soon.',
files)]
return []


def _CheckAndroidToastUsage(input_api, output_api):
"""Checks that code uses org.chromium.ui.widget.Toast instead of
android.widget.Toast (Chromium Toast doesn't force hardware
Expand Down Expand Up @@ -1962,6 +1988,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckPydepsNeedsUpdating(input_api, output_api))
results.extend(_CheckJavaStyle(input_api, output_api))
results.extend(_CheckIpcOwners(input_api, output_api))
results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api))

if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
Expand Down

0 comments on commit d99f726

Please sign in to comment.