Changed mft_h264_decoder's API to match with video_decode_engine.h. Also changed...
[chromium-blink-merge.git] / PRESUBMIT.py
blob4c0aff1fbbdeef2a5443041f53c99210d0d15866
1 # Copyright (c) 2010 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[\\\/].*",
18 _TEXT_FILES = (
19 r".*\.txt",
20 r".*\.json",
23 _LICENSE_HEADER = (
24 r".*? Copyright \(c\) 20[0-9\-]{2,7} The Chromium Authors\. All rights "
25 r"reserved\." "\n"
26 r".*? Use of this source code is governed by a BSD-style license that can "
27 "be\n"
28 r".*? found in the LICENSE file\."
29 "\n"
33 def _CheckConstNSObject(input_api, output_api, source_file_filter):
34 """Checks to make sure no objective-c files have |const NSSomeClass*|."""
35 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*')
36 files = []
37 for f in input_api.AffectedSourceFiles(source_file_filter):
38 if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'):
39 contents = input_api.ReadFile(f)
40 if pattern.search(contents):
41 files.append(f)
43 if len(files):
44 if input_api.is_committing:
45 res_type = output_api.PresubmitPromptWarning
46 else:
47 res_type = output_api.PresubmitNotifyResult
48 return [ res_type('|const NSClass*| is wrong, see ' +
49 'http://dev.chromium.org/developers/clang-mac',
50 files) ]
51 return []
54 def _CommonChecks(input_api, output_api):
55 results = []
56 # What does this code do?
57 # It loads the default black list (e.g. third_party, experimental, etc) and
58 # add our black list (breakpad, skia and v8 are still not following
59 # google style and are not really living this repository).
60 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage.
61 black_list = input_api.DEFAULT_BLACK_LIST + _EXCLUDED_PATHS
62 white_list = input_api.DEFAULT_WHITE_LIST + _TEXT_FILES
63 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list)
64 text_files = lambda x: input_api.FilterSourceFile(x, black_list=black_list,
65 white_list=white_list)
66 results.extend(input_api.canned_checks.CheckLongLines(
67 input_api, output_api, source_file_filter=sources))
68 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
69 input_api, output_api, source_file_filter=sources))
70 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
71 input_api, output_api, source_file_filter=sources))
72 results.extend(input_api.canned_checks.CheckChangeHasBugField(
73 input_api, output_api))
74 results.extend(input_api.canned_checks.CheckChangeHasTestField(
75 input_api, output_api))
76 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
77 input_api, output_api, source_file_filter=text_files))
78 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
79 input_api, output_api))
80 results.extend(input_api.canned_checks.CheckLicense(
81 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources))
82 results.extend(_CheckConstNSObject(
83 input_api, output_api, source_file_filter=sources))
84 return results
87 def CheckChangeOnUpload(input_api, output_api):
88 results = []
89 results.extend(_CommonChecks(input_api, output_api))
90 return results
93 def CheckChangeOnCommit(input_api, output_api):
94 results = []
95 if not input_api.json:
96 results.append(output_api.PresubmitNotifyResult(
97 'You don\'t have json nor simplejson installed.\n'
98 ' This is a warning that you will need to upgrade your python '
99 'installation.\n'
100 ' This is no big deal but you\'ll eventually need to '
101 'upgrade.\n'
102 ' How? Easy! You can do it right now and shut me off! Just:\n'
103 ' del depot_tools\\python.bat\n'
104 ' gclient\n'
105 ' Thanks for your patience.'))
106 results.extend(_CommonChecks(input_api, output_api))
107 # TODO(thestig) temporarily disabled, doesn't work in third_party/
108 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
109 # input_api, output_api, sources))
110 # Make sure the tree is 'open'.
111 results.extend(input_api.canned_checks.CheckTreeIsOpen(
112 input_api,
113 output_api,
114 'http://chromium-status.appspot.com/current?format=raw',
115 '(?i).*closed.*'))
116 results.extend(input_api.canned_checks.CheckRietveldTryJobExecution(input_api,
117 output_api, 'http://codereview.chromium.org', ('win', 'linux', 'mac'),
118 'tryserver@chromium.org'))
120 # These builders are just too slow.
121 IGNORED_BUILDERS = [
122 'Chromium XP',
123 'Chromium Mac',
124 'Chromium Arm (dbg)',
125 'Chromium Linux',
126 'Chromium Linux x64',
128 results.extend(input_api.canned_checks.CheckBuildbotPendingBuilds(
129 input_api,
130 output_api,
131 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1',
133 IGNORED_BUILDERS))
134 return results
137 def GetPreferredTrySlaves():
138 return ['win', 'linux', 'mac']