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

Side by Side Diff: PRESUBMIT.py

Issue 10704150: Add presubmit check for #pragma once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 """Top-level presubmit script for Chromium. 5 """Top-level presubmit script for Chromium.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl. 8 for more details about the presubmit API built into gcl.
9 """ 9 """
10 10
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 result = [] 347 result = []
348 if (warnings): 348 if (warnings):
349 result.append(output_api.PresubmitPromptWarning( 349 result.append(output_api.PresubmitPromptWarning(
350 'Banned functions were used.\n' + '\n'.join(warnings))) 350 'Banned functions were used.\n' + '\n'.join(warnings)))
351 if (errors): 351 if (errors):
352 result.append(output_api.PresubmitError( 352 result.append(output_api.PresubmitError(
353 'Banned functions were used.\n' + '\n'.join(errors))) 353 'Banned functions were used.\n' + '\n'.join(errors)))
354 return result 354 return result
355 355
356 356
357 def _CheckNoPragmaOnce(input_api, output_api):
358 """Make sure that banned functions are not used."""
359 files = []
360 pattern = input_api.re.compile(r'^#pragma\s+once',
361 input_api.re.MULTILINE)
362 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
363 if not f.LocalPath().endswith('.h'):
364 continue
365 contents = input_api.ReadFile(f)
366 if pattern.search(contents):
367 files.append(f)
368
369 if files:
370 return [output_api.PresubmitError(
371 'Do not use #pragma once in header files.\n' +
awong 2012/07/11 05:41:06 I don't think you need this plus to concat these s
dcheng 2012/07/11 05:44:19 Oops, you're right. I copied this from the iostrea
372 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
373 files)]
374 return []
375
357 376
358 def _CommonChecks(input_api, output_api): 377 def _CommonChecks(input_api, output_api):
359 """Checks common to both upload and commit.""" 378 """Checks common to both upload and commit."""
360 results = [] 379 results = []
361 results.extend(input_api.canned_checks.PanProjectChecks( 380 results.extend(input_api.canned_checks.PanProjectChecks(
362 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) 381 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
363 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 382 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
364 results.extend( 383 results.extend(
365 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) 384 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
366 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 385 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
367 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) 386 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
368 results.extend(_CheckNoNewWStrings(input_api, output_api)) 387 results.extend(_CheckNoNewWStrings(input_api, output_api))
369 results.extend(_CheckNoDEPSGIT(input_api, output_api)) 388 results.extend(_CheckNoDEPSGIT(input_api, output_api))
370 results.extend(_CheckNoBannedFunctions(input_api, output_api)) 389 results.extend(_CheckNoBannedFunctions(input_api, output_api))
390 results.extend(_CheckNoPragmaOnce(input_api, output_api))
371 return results 391 return results
372 392
373 393
374 def _CheckSubversionConfig(input_api, output_api): 394 def _CheckSubversionConfig(input_api, output_api):
375 """Verifies the subversion config file is correctly setup. 395 """Verifies the subversion config file is correctly setup.
376 396
377 Checks that autoprops are enabled, returns an error otherwise. 397 Checks that autoprops are enabled, returns an error otherwise.
378 """ 398 """
379 join = input_api.os_path.join 399 join = input_api.os_path.join
380 if input_api.platform == 'win32': 400 if input_api.platform == 'win32':
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 512
493 trybots = ['win_rel', 'linux_rel', 'mac_rel', 'linux_clang:compile'] 513 trybots = ['win_rel', 'linux_rel', 'mac_rel', 'linux_clang:compile']
494 # match things like aurax11.cc or aura_oak.cc 514 # match things like aurax11.cc or aura_oak.cc
495 if any(re.search('[/_]aura', f) for f in files): 515 if any(re.search('[/_]aura', f) for f in files):
496 trybots.append('linux_chromeos') 516 trybots.append('linux_chromeos')
497 517
498 if not all(f.startswith('chrome/') for f in files): 518 if not all(f.startswith('chrome/') for f in files):
499 trybots.append('android') 519 trybots.append('android')
500 520
501 return trybots 521 return trybots
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