| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import sys | 7 import sys |
| 8 import subprocess | 8 import subprocess |
| 9 | 9 |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 filepath = os.path.join('..', filename) | 84 filepath = os.path.join('..', filename) |
| 85 if RE_TODO.search(open(filepath, 'rb').read()): | 85 if RE_TODO.search(open(filepath, 'rb').read()): |
| 86 todo.append(filename) | 86 todo.append(filename) |
| 87 | 87 |
| 88 if todo: | 88 if todo: |
| 89 return [output_api.PresubmitError( | 89 return [output_api.PresubmitError( |
| 90 'TODOs found in stable public PPAPI files:', | 90 'TODOs found in stable public PPAPI files:', |
| 91 long_text='\n'.join(todo))] | 91 long_text='\n'.join(todo))] |
| 92 return [] | 92 return [] |
| 93 | 93 |
| 94 # Verify that no CPP wrappers use un-versioned PPB interface name macros. |
| 95 RE_UNVERSIONED_PPB = re.compile(r'\bPPB_\w+_INTERFACE\b') |
| 96 def CheckUnversionedPPB(input_api, output_api): |
| 97 files = input_api.LocalPaths() |
| 98 todo = [] |
| 99 |
| 100 for filename in files: |
| 101 name, ext = os.path.splitext(filename) |
| 102 name_parts = name.split(os.sep) |
| 103 |
| 104 # Only check C++ sources. |
| 105 if ext not in ['.cc']: |
| 106 continue |
| 107 |
| 108 # Only examine the public plugin facing ppapi/cpp directory. |
| 109 if name_parts[0:2] != ['ppapi', 'cpp']: |
| 110 continue |
| 111 |
| 112 # Only examine public stable and trusted interfaces. |
| 113 if name_parts[2] in ['dev', 'private']: |
| 114 continue |
| 115 |
| 116 filepath = os.path.join('..', filename) |
| 117 if RE_UNVERSIONED_PPB.search(open(filepath, 'rb').read()): |
| 118 todo.append(filename) |
| 119 |
| 120 if todo: |
| 121 return [output_api.PresubmitError( |
| 122 'Unversioned PPB interface references found in PPAPI C++ wrappers:', |
| 123 long_text='\n'.join(todo))] |
| 124 return [] |
| 94 | 125 |
| 95 def CheckChange(input_api, output_api): | 126 def CheckChange(input_api, output_api): |
| 96 results = [] | 127 results = [] |
| 97 | 128 |
| 98 results.extend(CheckSrpcChange(input_api, output_api)) | 129 results.extend(CheckSrpcChange(input_api, output_api)) |
| 99 | 130 |
| 100 results.extend(RunUnittests(input_api, output_api)) | 131 results.extend(RunUnittests(input_api, output_api)) |
| 101 | 132 |
| 102 results.extend(CheckTODO(input_api, output_api)) | 133 results.extend(CheckTODO(input_api, output_api)) |
| 134 |
| 135 results.extend(CheckUnversionedPPB(input_api, output_api)) |
| 136 |
| 103 # Verify all modified *.idl have a matching *.h | 137 # Verify all modified *.idl have a matching *.h |
| 104 files = input_api.LocalPaths() | 138 files = input_api.LocalPaths() |
| 105 h_files = [] | 139 h_files = [] |
| 106 idl_files = [] | 140 idl_files = [] |
| 107 | 141 |
| 108 # Find all relevant .h and .idl files. | 142 # Find all relevant .h and .idl files. |
| 109 for filename in files: | 143 for filename in files: |
| 110 name, ext = os.path.splitext(filename) | 144 name, ext = os.path.splitext(filename) |
| 111 name_parts = name.split(os.sep) | 145 name_parts = name.split(os.sep) |
| 112 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h': | 146 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h': |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 223 |
| 190 return results | 224 return results |
| 191 | 225 |
| 192 | 226 |
| 193 def CheckChangeOnUpload(input_api, output_api): | 227 def CheckChangeOnUpload(input_api, output_api): |
| 194 return CheckChange(input_api, output_api) | 228 return CheckChange(input_api, output_api) |
| 195 | 229 |
| 196 | 230 |
| 197 def CheckChangeOnCommit(input_api, output_api): | 231 def CheckChangeOnCommit(input_api, output_api): |
| 198 return CheckChange(input_api, output_api) | 232 return CheckChange(input_api, output_api) |
| OLD | NEW |