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"], |
qsr
2014/12/17 12:22:53
Did you write a bug to figure out what to do with
etiennej
2014/12/17 13:01:06
Done.
| |
25 "EDK": ["mojo_edk_source_set"]} | |
25 | 26 |
26 _ILLEGAL_EXTERNAL_PATH_WARNING_MESSAGE = \ | 27 _ILLEGAL_EXTERNAL_PATH_WARNING_MESSAGE = \ |
27 "Found disallowed external paths within SDK buildfiles." | 28 "Found disallowed external paths within SDK buildfiles." |
28 | 29 |
29 _ILLEGAL_EDK_ABSOLUTE_PATH_WARNING_MESSAGE = \ | 30 _ILLEGAL_EDK_ABSOLUTE_PATH_WARNING_MESSAGE = \ |
30 "Found references to the EDK via absolute paths within EDK buildfiles.", | 31 "Found references to the EDK via absolute paths within EDK buildfiles.", |
31 | 32 |
32 _ILLEGAL_SDK_ABSOLUTE_PATH_WARNING_MESSAGE_TEMPLATE = \ | 33 _ILLEGAL_SDK_ABSOLUTE_PATH_WARNING_MESSAGE_TEMPLATE = \ |
33 "Found references to the SDK via absolute paths within %s buildfiles." | 34 "Found references to the SDK via absolute paths within %s buildfiles." |
34 | 35 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 assert package in _PACKAGE_SOURCE_SET_TYPES | 155 assert package in _PACKAGE_SOURCE_SET_TYPES |
155 required_source_set_type = _PACKAGE_SOURCE_SET_TYPES[package] | 156 required_source_set_type = _PACKAGE_SOURCE_SET_TYPES[package] |
156 | 157 |
157 problems = [] | 158 problems = [] |
158 for f in _AffectedBuildFilesWithinPackage(input_api, package): | 159 for f in _AffectedBuildFilesWithinPackage(input_api, package): |
159 for line_num, line in f.ChangedContents(): | 160 for line_num, line in f.ChangedContents(): |
160 m = re.search(r"[a-z_]*source_set\(", line) | 161 m = re.search(r"[a-z_]*source_set\(", line) |
161 if not m: | 162 if not m: |
162 continue | 163 continue |
163 source_set_type = m.group(0)[:-1] | 164 source_set_type = m.group(0)[:-1] |
164 if source_set_type == required_source_set_type: | 165 if source_set_type in required_source_set_type: |
165 continue | 166 continue |
166 problems.append(_IncorrectSourceSetTypeWarningItem(f.LocalPath(), | 167 problems.append(_IncorrectSourceSetTypeWarningItem(f.LocalPath(), |
167 line_num)) | 168 line_num)) |
168 | 169 |
169 if not problems: | 170 if not problems: |
170 return [] | 171 return [] |
171 return [output_api.PresubmitError( | 172 return [output_api.PresubmitError( |
172 _INCORRECT_SOURCE_SET_TYPE_WARNING_MESSAGES[package], | 173 _INCORRECT_SOURCE_SET_TYPE_WARNING_MESSAGES[package], |
173 items=problems)] | 174 items=problems)] |
174 | 175 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 def CheckChangeOnUpload(input_api, output_api): | 236 def CheckChangeOnUpload(input_api, output_api): |
236 results = [] | 237 results = [] |
237 results.extend(_CommonChecks(input_api, output_api)) | 238 results.extend(_CommonChecks(input_api, output_api)) |
238 results.extend(_CheckChangePylintsClean(input_api, output_api)) | 239 results.extend(_CheckChangePylintsClean(input_api, output_api)) |
239 return results | 240 return results |
240 | 241 |
241 def CheckChangeOnCommit(input_api, output_api): | 242 def CheckChangeOnCommit(input_api, output_api): |
242 results = [] | 243 results = [] |
243 results.extend(_CommonChecks(input_api, output_api)) | 244 results.extend(_CommonChecks(input_api, output_api)) |
244 return results | 245 return results |
OLD | NEW |