blob: 7fc8107658c15a1c50fc633551b8618c958a5032 [file] [log] [blame]
[email protected]2c923532012-03-02 21:16:551# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0732a49d92011-03-08 03:37:282# 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
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
tfarina78bb92f42015-01-31 00:20:488for more details on the presubmit API built into depot_tools.
[email protected]0732a49d92011-03-08 03:37:289"""
10
[email protected]23e6cbc2012-06-16 18:51:2011def _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
droger114a60b2014-11-06 11:06:5117 not "/ios/" in f.LocalPath() and
[email protected]a35203a42012-07-12 15:12:5518 not "/test/" in f.LocalPath() and
[email protected]430166092013-05-30 16:09:1419 not f.LocalPath().endswith('_unittest.mm') and
20 not f.LocalPath().endswith('mac/sdk_forward_declarations.h')):
[email protected]23e6cbc2012-06-16 18:51:2021 contents = input_api.ReadFile(f)
22 if pattern.search(contents):
23 files.append(f)
24
25 if len(files):
26 return [ output_api.PresubmitError(
27 'Objective-C interfaces or categories are forbidden in libbase. ' +
28 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
29 'browse_thread/thread/efb28c10435987fd',
30 files) ]
31 return []
32
33
34def _CommonChecks(input_api, output_api):
35 """Checks common to both upload and commit."""
36 results = []
37 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
38 return results
39
40def CheckChangeOnUpload(input_api, output_api):
41 results = []
42 results.extend(_CommonChecks(input_api, output_api))
43 return results
44
45
46def CheckChangeOnCommit(input_api, output_api):
47 results = []
48 results.extend(_CommonChecks(input_api, output_api))
49 return results