Fixed a few styles issues in skia::PlatformDevice. Made function names consistent...
[chromium-blink-merge.git] / PRESUBMIT.py
blob6b086531fa7aade5601c0dc20381fdccaa0431c5
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Top-level presubmit script for Chromium.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
11 _EXCLUDED_PATHS = (
12 r"^breakpad[\\\/].*",
13 r"^net/tools/spdyshark/[\\\/].*",
14 r"^skia[\\\/].*",
15 r"^v8[\\\/].*",
16 r".*MakeFile$",
20 def _CheckNoInterfacesInBase(input_api, output_api):
21 """Checks to make sure no files in libbase.a have |@interface|."""
22 pattern = input_api.re.compile(r'@interface')
23 files = []
24 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
25 if (f.LocalPath().find('base/') != -1 and
26 f.LocalPath().find('base/test/') == -1):
27 contents = input_api.ReadFile(f)
28 if pattern.search(contents):
29 files.append(f)
31 if len(files):
32 return [ output_api.PresubmitError(
33 'Objective-C interfaces or categories are forbidden in libbase. ' +
34 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
35 'browse_thread/thread/efb28c10435987fd',
36 files) ]
37 return []
40 def _CommonChecks(input_api, output_api):
41 """Checks common to both upload and commit."""
42 results = []
43 results.extend(input_api.canned_checks.PanProjectChecks(
44 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
45 results.extend(_CheckNoInterfacesInBase(input_api, output_api))
46 return results
49 def _CheckSubversionConfig(input_api, output_api):
50 """Verifies the subversion config file is correctly setup.
52 Checks that autoprops are enabled, returns an error otherwise.
53 """
54 join = input_api.os_path.join
55 if input_api.platform == 'win32':
56 appdata = input_api.environ.get('APPDATA', '')
57 if not appdata:
58 return [output_api.PresubmitError('%APPDATA% is not configured.')]
59 path = join(appdata, 'Subversion', 'config')
60 else:
61 home = input_api.environ.get('HOME', '')
62 if not home:
63 return [output_api.PresubmitError('$HOME is not configured.')]
64 path = join(home, '.subversion', 'config')
66 error_msg = (
67 'Please look at http://dev.chromium.org/developers/coding-style to\n'
68 'configure your subversion configuration file. This enables automatic\n'
69 'properties to simplify the project maintenance.\n'
70 'Pro-tip: just download and install\n'
71 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
73 try:
74 lines = open(path, 'r').read().splitlines()
75 # Make sure auto-props is enabled and check for 2 Chromium standard
76 # auto-prop.
77 if (not '*.cc = svn:eol-style=LF' in lines or
78 not '*.pdf = svn:mime-type=application/pdf' in lines or
79 not 'enable-auto-props = yes' in lines):
80 return [
81 output_api.PresubmitNotifyResult(
82 'It looks like you have not configured your subversion config '
83 'file or it is not up-to-date.\n' + error_msg)
85 except (OSError, IOError):
86 return [
87 output_api.PresubmitNotifyResult(
88 'Can\'t find your subversion config file.\n' + error_msg)
90 return []
93 def CheckChangeOnUpload(input_api, output_api):
94 results = []
95 results.extend(_CommonChecks(input_api, output_api))
96 return results
99 def CheckChangeOnCommit(input_api, output_api):
100 results = []
101 if not input_api.json:
102 results.append(output_api.PresubmitNotifyResult(
103 'You don\'t have json nor simplejson installed.\n'
104 ' This is a warning that you will need to upgrade your python '
105 'installation.\n'
106 ' This is no big deal but you\'ll eventually need to '
107 'upgrade.\n'
108 ' How? Easy! You can do it right now and shut me off! Just:\n'
109 ' del depot_tools\\python.bat\n'
110 ' gclient\n'
111 ' Thanks for your patience.'))
112 results.extend(_CommonChecks(input_api, output_api))
113 # TODO(thestig) temporarily disabled, doesn't work in third_party/
114 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
115 # input_api, output_api, sources))
116 # Make sure the tree is 'open'.
117 results.extend(input_api.canned_checks.CheckTreeIsOpen(
118 input_api,
119 output_api,
120 json_url='http://chromium-status.appspot.com/current?format=json'))
121 results.extend(input_api.canned_checks.CheckRietveldTryJobExecution(input_api,
122 output_api, 'http://codereview.chromium.org', ('win', 'linux', 'mac'),
123 'tryserver@chromium.org'))
125 # These builders are just too slow.
126 IGNORED_BUILDERS = [
127 'Chromium XP',
128 'Chromium Mac',
129 'Chromium Arm (dbg)',
130 'Chromium Linux',
131 'Chromium Linux x64',
133 results.extend(input_api.canned_checks.CheckBuildbotPendingBuilds(
134 input_api,
135 output_api,
136 'http://build.chromium.org/p/chromium/json/builders?filter=1',
138 IGNORED_BUILDERS))
139 results.extend(input_api.canned_checks.CheckChangeHasBugField(
140 input_api, output_api))
141 results.extend(input_api.canned_checks.CheckChangeHasTestField(
142 input_api, output_api))
143 results.extend(_CheckSubversionConfig(input_api, output_api))
144 return results
147 def GetPreferredTrySlaves():
148 return ['win', 'linux', 'mac']