[email protected] | 2c92353 | 2012-03-02 21:16:55 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0732a49d9 | 2011-03-08 03:37:28 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Chromium presubmit script for src/base. |
| 6 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 | for more details on the presubmit API built into gcl. |
| 9 | """ |
| 10 | |
[email protected] | 23e6cbc | 2012-06-16 18:51:20 | [diff] [blame] | 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 |
[email protected] | a35203a4 | 2012-07-12 15:12:55 | [diff] [blame] | 17 | not "/test/" in f.LocalPath() and |
[email protected] | 43016609 | 2013-05-30 16:09:14 | [diff] [blame^] | 18 | not f.LocalPath().endswith('_unittest.mm') and |
| 19 | not f.LocalPath().endswith('mac/sdk_forward_declarations.h')): |
[email protected] | 23e6cbc | 2012-06-16 18:51:20 | [diff] [blame] | 20 | contents = input_api.ReadFile(f) |
| 21 | if pattern.search(contents): |
| 22 | files.append(f) |
| 23 | |
| 24 | if len(files): |
| 25 | return [ output_api.PresubmitError( |
| 26 | 'Objective-C interfaces or categories are forbidden in libbase. ' + |
| 27 | 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' + |
| 28 | 'browse_thread/thread/efb28c10435987fd', |
| 29 | files) ] |
| 30 | return [] |
| 31 | |
| 32 | |
| 33 | def _CommonChecks(input_api, output_api): |
| 34 | """Checks common to both upload and commit.""" |
| 35 | results = [] |
| 36 | results.extend(_CheckNoInterfacesInBase(input_api, output_api)) |
| 37 | return results |
| 38 | |
| 39 | def CheckChangeOnUpload(input_api, output_api): |
| 40 | results = [] |
| 41 | results.extend(_CommonChecks(input_api, output_api)) |
| 42 | return results |
| 43 | |
| 44 | |
| 45 | def CheckChangeOnCommit(input_api, output_api): |
| 46 | results = [] |
| 47 | results.extend(_CommonChecks(input_api, output_api)) |
| 48 | return results |
| 49 | |
| 50 | |
[email protected] | 0732a49d9 | 2011-03-08 03:37:28 | [diff] [blame] | 51 | def GetPreferredTrySlaves(): |
[email protected] | 2c92353 | 2012-03-02 21:16:55 | [diff] [blame] | 52 | return [ |
| 53 | 'linux_rel:sync_integration_tests', |
| 54 | 'mac_rel:sync_integration_tests', |
| 55 | 'win_rel:sync_integration_tests', |
| 56 | ] |