Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: ppapi/PRESUBMIT.py

Issue 23620032: PPAPI: Make API changes w/o IDL changes Warnings if generators have changed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove debug print() Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 results.extend(CheckTODO(input_api, output_api)) 152 results.extend(CheckTODO(input_api, output_api))
153 153
154 results.extend(CheckUnversionedPPB(input_api, output_api)) 154 results.extend(CheckUnversionedPPB(input_api, output_api))
155 155
156 results.extend(CheckUpdatedNaClSDK(input_api, output_api)) 156 results.extend(CheckUpdatedNaClSDK(input_api, output_api))
157 157
158 # Verify all modified *.idl have a matching *.h 158 # Verify all modified *.idl have a matching *.h
159 files = input_api.LocalPaths() 159 files = input_api.LocalPaths()
160 h_files = [] 160 h_files = []
161 idl_files = [] 161 idl_files = []
162 generators_changed = False
162 163
163 # Find all relevant .h and .idl files. 164 # Find all relevant .h and .idl files.
164 for filename in files: 165 for filename in files:
165 name, ext = os.path.splitext(filename) 166 name, ext = os.path.splitext(filename)
166 name_parts = name.split(os.sep) 167 name_parts = name.split(os.sep)
167 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h': 168 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h':
168 h_files.append('/'.join(name_parts[2:])) 169 h_files.append('/'.join(name_parts[2:]))
169 if name_parts[0:2] == ['ppapi', 'api'] and ext == '.idl': 170 elif name_parts[0:2] == ['ppapi', 'api'] and ext == '.idl':
170 idl_files.append('/'.join(name_parts[2:])) 171 idl_files.append('/'.join(name_parts[2:]))
172 elif name_parts[0:2] == ['ppapi', 'generators']:
173 generators_changed = True
171 174
172 # Generate a list of all appropriate *.h and *.idl changes in this CL. 175 # Generate a list of all appropriate *.h and *.idl changes in this CL.
173 both = h_files + idl_files 176 both = h_files + idl_files
174 177
175 # If there aren't any, we are done checking. 178 # If there aren't any, we are done checking.
176 if not both: return results 179 if not both: return results
177 180
178 missing = [] 181 missing = []
179 for filename in idl_files: 182 for filename in idl_files:
180 if filename not in set(h_files): 183 if filename not in set(h_files):
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 'Missing PPAPI IDL for private interface, please generate IDL:', 243 'Missing PPAPI IDL for private interface, please generate IDL:',
241 long_text='\n'.join(missing_priv))) 244 long_text='\n'.join(missing_priv)))
242 245
243 if missing_dev: 246 if missing_dev:
244 results.append( 247 results.append(
245 output_api.PresubmitPromptWarning( 248 output_api.PresubmitPromptWarning(
246 'Missing PPAPI IDL for DEV, required before moving to stable:', 249 'Missing PPAPI IDL for DEV, required before moving to stable:',
247 long_text='\n'.join(missing_dev))) 250 long_text='\n'.join(missing_dev)))
248 251
249 if missing_stable: 252 if missing_stable:
250 results.append( 253 # It might be okay that the header changed without a corresponding IDL
251 output_api.PresubmitError( 254 # change. E.g., comment indenting may have been changed. Treat this as a
252 'Missing PPAPI IDL for stable interface:', 255 # warning.
253 long_text='\n'.join(missing_stable))) 256 if generators_changed:
257 results.append(
258 output_api.PresubmitPromptWarning(
259 'Missing PPAPI IDL for stable interface (due to change in ' +
260 'generators?):',
261 long_text='\n'.join(missing_stable)))
262 else:
263 results.append(
264 output_api.PresubmitError(
265 'Missing PPAPI IDL for stable interface:',
266 long_text='\n'.join(missing_stable)))
254 267
255 # Verify all *.h files match *.idl definitions, use: 268 # Verify all *.h files match *.idl definitions, use:
256 # --test to prevent output to disk 269 # --test to prevent output to disk
257 # --diff to generate a unified diff 270 # --diff to generate a unified diff
258 # --out to pick which files to examine (only the ones in the CL) 271 # --out to pick which files to examine (only the ones in the CL)
259 ppapi_dir = input_api.PresubmitLocalPath() 272 ppapi_dir = input_api.PresubmitLocalPath()
260 cmd = [sys.executable, 'generator.py', 273 cmd = [sys.executable, 'generator.py',
261 '--wnone', '--diff', '--test','--cgen', '--range=start,end'] 274 '--wnone', '--diff', '--test','--cgen', '--range=start,end']
262 275
263 # Only generate output for IDL files references (as *.h or *.idl) in this CL 276 # Only generate output for IDL files references (as *.h or *.idl) in this CL
264 cmd.append('--out=' + ','.join([name + '.idl' for name in both])) 277 cmd.append('--out=' + ','.join([name + '.idl' for name in both]))
265 cmd_results = RunCmdAndCheck(cmd, 278 cmd_results = RunCmdAndCheck(cmd,
266 'PPAPI IDL Diff detected: Run the generator.', 279 'PPAPI IDL Diff detected: Run the generator.',
267 output_api, 280 output_api,
268 os.path.join(ppapi_dir, 'generators')) 281 os.path.join(ppapi_dir, 'generators'))
269 if cmd_results: 282 if cmd_results:
270 results.extend(cmd_results) 283 results.extend(cmd_results)
271 284
272 return results 285 return results
273 286
274 287
275 def CheckChangeOnUpload(input_api, output_api): 288 def CheckChangeOnUpload(input_api, output_api):
276 return CheckChange(input_api, output_api) 289 return CheckChange(input_api, output_api)
277 290
278 291
279 def CheckChangeOnCommit(input_api, output_api): 292 def CheckChangeOnCommit(input_api, output_api):
280 return CheckChange(input_api, output_api) 293 return CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698