OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Presubmit script for mojo | 5 """Presubmit script for mojo |
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 about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
11 import os.path | 11 import os.path |
12 import re | 12 import re |
13 | 13 |
14 _SDK_WHITELISTED_EXTERNAL_PATHS = [ | 14 _SDK_WHITELISTED_EXTERNAL_PATHS = [ |
15 "//testing/gtest", | 15 "//testing/gtest", |
16 "//third_party/cython", | 16 "//third_party/cython", |
17 "//third_party/khronos", | 17 "//third_party/khronos", |
18 ] | 18 ] |
19 | 19 |
20 _PACKAGE_PATH_PREFIXES = {"SDK": "mojo/public/", | 20 _PACKAGE_PATH_PREFIXES = {"SDK": "mojo/public/", |
21 "EDK": "mojo/edk/"} | 21 "EDK": "mojo/edk/"} |
22 | 22 |
23 _PACKAGE_SOURCE_SET_TYPES = {"SDK": "mojo_sdk_source_set", | 23 _PACKAGE_SOURCE_SET_TYPES = {"SDK": ["mojo_sdk_source_set", |
24 "EDK": "mojo_edk_source_set"} | 24 # python_binary_source_set added due to crbug.com/443147 |
qsr
2014/12/17 13:02:51
Please move this comment on the previous line. And
etiennej
2014/12/17 13:04:31
Done.
| |
25 "python_binary_source_set"], | |
26 "EDK": ["mojo_edk_source_set"]} | |
25 | 27 |
26 _ILLEGAL_EXTERNAL_PATH_WARNING_MESSAGE = \ | 28 _ILLEGAL_EXTERNAL_PATH_WARNING_MESSAGE = \ |
27 "Found disallowed external paths within SDK buildfiles." | 29 "Found disallowed external paths within SDK buildfiles." |
28 | 30 |
29 _ILLEGAL_EDK_ABSOLUTE_PATH_WARNING_MESSAGE = \ | 31 _ILLEGAL_EDK_ABSOLUTE_PATH_WARNING_MESSAGE = \ |
30 "Found references to the EDK via absolute paths within EDK buildfiles.", | 32 "Found references to the EDK via absolute paths within EDK buildfiles.", |
31 | 33 |
32 _ILLEGAL_SDK_ABSOLUTE_PATH_WARNING_MESSAGE_TEMPLATE = \ | 34 _ILLEGAL_SDK_ABSOLUTE_PATH_WARNING_MESSAGE_TEMPLATE = \ |
33 "Found references to the SDK via absolute paths within %s buildfiles." | 35 "Found references to the SDK via absolute paths within %s buildfiles." |
34 | 36 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 assert package in _PACKAGE_SOURCE_SET_TYPES | 156 assert package in _PACKAGE_SOURCE_SET_TYPES |
155 required_source_set_type = _PACKAGE_SOURCE_SET_TYPES[package] | 157 required_source_set_type = _PACKAGE_SOURCE_SET_TYPES[package] |
156 | 158 |
157 problems = [] | 159 problems = [] |
158 for f in _AffectedBuildFilesWithinPackage(input_api, package): | 160 for f in _AffectedBuildFilesWithinPackage(input_api, package): |
159 for line_num, line in f.ChangedContents(): | 161 for line_num, line in f.ChangedContents(): |
160 m = re.search(r"[a-z_]*source_set\(", line) | 162 m = re.search(r"[a-z_]*source_set\(", line) |
161 if not m: | 163 if not m: |
162 continue | 164 continue |
163 source_set_type = m.group(0)[:-1] | 165 source_set_type = m.group(0)[:-1] |
164 if source_set_type == required_source_set_type: | 166 if source_set_type in required_source_set_type: |
165 continue | 167 continue |
166 problems.append(_IncorrectSourceSetTypeWarningItem(f.LocalPath(), | 168 problems.append(_IncorrectSourceSetTypeWarningItem(f.LocalPath(), |
167 line_num)) | 169 line_num)) |
168 | 170 |
169 if not problems: | 171 if not problems: |
170 return [] | 172 return [] |
171 return [output_api.PresubmitError( | 173 return [output_api.PresubmitError( |
172 _INCORRECT_SOURCE_SET_TYPE_WARNING_MESSAGES[package], | 174 _INCORRECT_SOURCE_SET_TYPE_WARNING_MESSAGES[package], |
173 items=problems)] | 175 items=problems)] |
174 | 176 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 def CheckChangeOnUpload(input_api, output_api): | 237 def CheckChangeOnUpload(input_api, output_api): |
236 results = [] | 238 results = [] |
237 results.extend(_CommonChecks(input_api, output_api)) | 239 results.extend(_CommonChecks(input_api, output_api)) |
238 results.extend(_CheckChangePylintsClean(input_api, output_api)) | 240 results.extend(_CheckChangePylintsClean(input_api, output_api)) |
239 return results | 241 return results |
240 | 242 |
241 def CheckChangeOnCommit(input_api, output_api): | 243 def CheckChangeOnCommit(input_api, output_api): |
242 results = [] | 244 results = [] |
243 results.extend(_CommonChecks(input_api, output_api)) | 245 results.extend(_CommonChecks(input_api, output_api)) |
244 return results | 246 return results |
OLD | NEW |