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

Side by Side Diff: PRESUBMIT.py

Issue 3038036: Add a PRESUBMIT check for header files that are missing the |#pragma once| directive. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
« 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) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 input_api, output_api)) 53 input_api, output_api))
54 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( 54 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
55 input_api, output_api, source_file_filter=text_files)) 55 input_api, output_api, source_file_filter=text_files))
56 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 56 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
57 input_api, output_api)) 57 input_api, output_api))
58 results.extend(input_api.canned_checks.CheckLicense( 58 results.extend(input_api.canned_checks.CheckLicense(
59 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) 59 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources))
60 return results 60 return results
61 61
62 62
63 def _CheckPragmaOnce(input_api, output_api):
64 """Checks to make sure all new headers have |#pragma once|."""
65 files = []
66 for f in input_api.change.AffectedTextFiles():
67 if f.LocalPath().endswith('.h'):
68 contents = input_api.ReadFile(f)
69 if not '#pragma once' in contents.splitlines(False):
70 files.append(f)
71
72 if len(files):
73 if input_api.is_committing:
74 res_type = output_api.PresubmitPromptWarning
75 else:
76 res_type = output_api.PresubmitNotifyResult
77 return [ res_type('Missing |#pragma once| directive:', files) ]
78 return []
79
80
63 def CheckChangeOnUpload(input_api, output_api): 81 def CheckChangeOnUpload(input_api, output_api):
64 results = [] 82 results = []
65 results.extend(_CommonChecks(input_api, output_api)) 83 results.extend(_CommonChecks(input_api, output_api))
84 results.extend(_CheckPragmaOnce(input_api, output_api))
66 return results 85 return results
67 86
68 87
69 def CheckChangeOnCommit(input_api, output_api): 88 def CheckChangeOnCommit(input_api, output_api):
70 results = [] 89 results = []
71 if not input_api.json: 90 if not input_api.json:
72 results.append(output_api.PresubmitNotifyResult( 91 results.append(output_api.PresubmitNotifyResult(
73 'You don\'t have json nor simplejson installed.\n' 92 'You don\'t have json nor simplejson installed.\n'
74 ' This is a warning that you will need to upgrade your python ' 93 ' This is a warning that you will need to upgrade your python '
75 'installation.\n' 94 'installation.\n'
(...skipping 29 matching lines...) Expand all
105 input_api, 124 input_api,
106 output_api, 125 output_api,
107 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1', 126 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1',
108 6, 127 6,
109 IGNORED_BUILDERS)) 128 IGNORED_BUILDERS))
110 return results 129 return results
111 130
112 131
113 def GetPreferredTrySlaves(): 132 def GetPreferredTrySlaves():
114 return ['win', 'linux', 'mac'] 133 return ['win', 'linux', 'mac']
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