diff options
author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 14:33:44 +0000 |
---|---|---|
committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 14:33:44 +0000 |
commit | 650c908b1828a8ad8ff1c925106f18f65922fb06 (patch) | |
tree | 55e20114e95a5134692cbb8af4c584f694b7b5b6 /PRESUBMIT.py | |
parent | 70be9244de17229105b630834b6cffef69cc0d18 (diff) | |
download | chromium_src-650c908b1828a8ad8ff1c925106f18f65922fb06.zip chromium_src-650c908b1828a8ad8ff1c925106f18f65922fb06.tar.gz chromium_src-650c908b1828a8ad8ff1c925106f18f65922fb06.tar.bz2 |
Add a presubmit check to catch usage of Singleton<T> in header files.
BUG=65298
TEST=none
Review URL: http://codereview.chromium.org/5753006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 4a4f8579..311cb20 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -29,6 +29,24 @@ _LICENSE_HEADER = ( "\n" ) +def _CheckSingletonInHeaders(input_api, output_api, source_file_filter): + """Checks to make sure no header files have |Singleton<|.""" + pattern = input_api.re.compile(r'Singleton<') + files = [] + for f in input_api.AffectedSourceFiles(source_file_filter): + if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or + f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')): + contents = input_api.ReadFile(f) + if pattern.search(contents): + files.append(f) + + if len(files): + return [ output_api.PresubmitError( + 'Found Singleton<T> in the following header files.\n' + + 'Please move them to an appropriate source file so that the ' + + 'template gets instantiated in a single compilation unit.', + files) ] + return [] def _CheckConstNSObject(input_api, output_api, source_file_filter): """Checks to make sure no objective-c files have |const NSSomeClass*|.""" @@ -81,6 +99,8 @@ def _CommonChecks(input_api, output_api): input_api, output_api, _LICENSE_HEADER, source_file_filter=sources)) results.extend(_CheckConstNSObject( input_api, output_api, source_file_filter=sources)) + results.extend(_CheckSingletonInHeaders( + input_api, output_api, source_file_filter=sources)) return results |