Chromium Code Reviews| Index: ppapi/PRESUBMIT.py |
| diff --git a/ppapi/PRESUBMIT.py b/ppapi/PRESUBMIT.py |
| index 20d9e6c27fe41c5ab685ed64d767405f42336c0a..2d6cac829cd742d8ac1167926074477e10f7be10 100644 |
| --- a/ppapi/PRESUBMIT.py |
| +++ b/ppapi/PRESUBMIT.py |
| @@ -91,6 +91,37 @@ def CheckTODO(input_api, output_api): |
| long_text='\n'.join(todo))] |
| return [] |
| +# Verify that no CPP wrappers use un-versioned PPB interface name macros. |
| +RE_UNVERSIONED_PPB = re.compile(r'\WPPB_\w+_INTERFACE\W') |
|
dmichael (off chromium)
2012/06/01 14:28:34
I think technically "\b" would be more appropriate
Wez
2012/06/01 18:32:16
Done re "\W" -> "\b".
"\w" matches [a-zA-Z0-9_] a
|
| +def CheckUnversionedPPB(input_api, output_api): |
| + files = input_api.LocalPaths() |
| + todo = [] |
| + |
| + for filename in files: |
| + name, ext = os.path.splitext(filename) |
| + name_parts = name.split(os.sep) |
| + |
| + # Only check C++ sources. |
| + if ext not in ['.cc']: |
| + continue |
| + |
| + # Only examine the public plugin facing ppapi/cpp directory. |
| + if name_parts[0:2] != ['ppapi', 'cpp']: |
| + continue |
| + |
| + # Only examine public stable and trusted interfaces. |
| + if name_parts[2] in ['dev', 'private']: |
| + continue |
| + |
| + filepath = os.path.join('..', filename) |
| + if RE_UNVERSIONED_PPB.search(open(filepath, 'rb').read()): |
| + todo.append(filename) |
| + |
| + if todo: |
| + return [output_api.PresubmitError( |
| + 'Unversioned PPB interface references found in PPAPI C++ wrappers:', |
| + long_text='\n'.join(todo))] |
| + return [] |
| def CheckChange(input_api, output_api): |
| results = [] |
| @@ -100,6 +131,9 @@ def CheckChange(input_api, output_api): |
| results.extend(RunUnittests(input_api, output_api)) |
| results.extend(CheckTODO(input_api, output_api)) |
| + |
| + results.extend(CheckUnversionedPPB(input_api, output_api)) |
| + |
| # Verify all modified *.idl have a matching *.h |
| files = input_api.LocalPaths() |
| h_files = [] |