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 """Chromium presubmit script for src/base. | 5 """Chromium presubmit script for src/base. |
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 on the presubmit API built into gcl. | 8 for more details on the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
| 11 def _CheckNoInterfacesInBase(input_api, output_api): |
| 12 """Checks to make sure no files in libbase.a have |@interface|.""" |
| 13 pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE) |
| 14 files = [] |
| 15 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
| 16 if (f.LocalPath().startswith('base/') and |
| 17 not f.LocalPath().endswith('_unittest.mm')): |
| 18 contents = input_api.ReadFile(f) |
| 19 if pattern.search(contents): |
| 20 files.append(f) |
| 21 |
| 22 if len(files): |
| 23 return [ output_api.PresubmitError( |
| 24 'Objective-C interfaces or categories are forbidden in libbase. ' + |
| 25 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' + |
| 26 'browse_thread/thread/efb28c10435987fd', |
| 27 files) ] |
| 28 return [] |
| 29 |
| 30 |
| 31 def _CommonChecks(input_api, output_api): |
| 32 """Checks common to both upload and commit.""" |
| 33 results = [] |
| 34 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) |
| 35 return results |
| 36 |
| 37 def CheckChangeOnUpload(input_api, output_api): |
| 38 results = [] |
| 39 results.extend(_CommonChecks(input_api, output_api)) |
| 40 return results |
| 41 |
| 42 |
| 43 def CheckChangeOnCommit(input_api, output_api): |
| 44 results = [] |
| 45 results.extend(_CommonChecks(input_api, output_api)) |
| 46 return results |
| 47 |
| 48 |
11 def GetPreferredTrySlaves(): | 49 def GetPreferredTrySlaves(): |
12 return [ | 50 return [ |
13 'linux_rel:sync_integration_tests', | 51 'linux_rel:sync_integration_tests', |
14 'mac_rel:sync_integration_tests', | 52 'mac_rel:sync_integration_tests', |
15 'win_rel:sync_integration_tests', | 53 'win_rel:sync_integration_tests', |
16 ] | 54 ] |
OLD | NEW |