Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: PRESUBMIT.py

Issue 312763002: Add DEPS files and run checkdeps in presubmit check (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « DEPS ('k') | src/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2012 the V8 project authors. All rights reserved. 1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 """Top-level presubmit script for V8. 28 """Top-level presubmit script for V8.
29 29
30 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 30 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
31 for more details about the presubmit API built into gcl. 31 for more details about the presubmit API built into gcl.
32 """ 32 """
33 33
34 import sys
35
36
34 def _V8PresubmitChecks(input_api, output_api): 37 def _V8PresubmitChecks(input_api, output_api):
35 """Runs the V8 presubmit checks.""" 38 """Runs the V8 presubmit checks."""
36 import sys 39 import sys
37 sys.path.append(input_api.os_path.join( 40 sys.path.append(input_api.os_path.join(
38 input_api.PresubmitLocalPath(), 'tools')) 41 input_api.PresubmitLocalPath(), 'tools'))
39 from presubmit import CppLintProcessor 42 from presubmit import CppLintProcessor
40 from presubmit import SourceProcessor 43 from presubmit import SourceProcessor
41 44
42 results = [] 45 results = []
43 if not CppLintProcessor().Run(input_api.PresubmitLocalPath()): 46 if not CppLintProcessor().Run(input_api.PresubmitLocalPath()):
44 results.append(output_api.PresubmitError("C++ lint check failed")) 47 results.append(output_api.PresubmitError("C++ lint check failed"))
45 if not SourceProcessor().Run(input_api.PresubmitLocalPath()): 48 if not SourceProcessor().Run(input_api.PresubmitLocalPath()):
46 results.append(output_api.PresubmitError( 49 results.append(output_api.PresubmitError(
47 "Copyright header, trailing whitespaces and two empty lines " \ 50 "Copyright header, trailing whitespaces and two empty lines " \
48 "between declarations check failed")) 51 "between declarations check failed"))
49 return results 52 return results
50 53
51 54
55 def _CheckUnwantedDependencies(input_api, output_api):
56 """Runs checkdeps on #include statements added in this
57 change. Breaking - rules is an error, breaking ! rules is a
58 warning.
59 """
60 # We need to wait until we have an input_api object and use this
61 # roundabout construct to import checkdeps because this file is
62 # eval-ed and thus doesn't have __file__.
63 original_sys_path = sys.path
64 try:
65 sys.path = sys.path + [input_api.os_path.join(
66 input_api.PresubmitLocalPath(), 'buildtools', 'checkdeps')]
67 import checkdeps
68 from cpp_checker import CppChecker
69 from rules import Rule
70 finally:
71 # Restore sys.path to what it was before.
72 sys.path = original_sys_path
73
74 added_includes = []
75 for f in input_api.AffectedFiles():
76 if not CppChecker.IsCppFile(f.LocalPath()):
77 continue
78
79 changed_lines = [line for line_num, line in f.ChangedContents()]
80 added_includes.append([f.LocalPath(), changed_lines])
81
82 deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath())
83
84 error_descriptions = []
85 warning_descriptions = []
86 for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes(
87 added_includes):
88 description_with_path = '%s\n %s' % (path, rule_description)
89 if rule_type == Rule.DISALLOW:
90 error_descriptions.append(description_with_path)
91 else:
92 warning_descriptions.append(description_with_path)
93
94 results = []
95 if error_descriptions:
96 results.append(output_api.PresubmitError(
97 'You added one or more #includes that violate checkdeps rules.',
98 error_descriptions))
99 if warning_descriptions:
100 results.append(output_api.PresubmitPromptOrNotify(
101 'You added one or more #includes of files that are temporarily\n'
102 'allowed but being removed. Can you avoid introducing the\n'
103 '#include? See relevant DEPS file(s) for details and contacts.',
104 warning_descriptions))
105 return results
106
107
52 def _CommonChecks(input_api, output_api): 108 def _CommonChecks(input_api, output_api):
53 """Checks common to both upload and commit.""" 109 """Checks common to both upload and commit."""
54 results = [] 110 results = []
55 results.extend(input_api.canned_checks.CheckOwners( 111 results.extend(input_api.canned_checks.CheckOwners(
56 input_api, output_api, source_file_filter=None)) 112 input_api, output_api, source_file_filter=None))
57 results.extend(_V8PresubmitChecks(input_api, output_api)) 113 results.extend(_V8PresubmitChecks(input_api, output_api))
114 results.extend(_CheckUnwantedDependencies(input_api, output_api))
58 return results 115 return results
59 116
60 117
61 def _SkipTreeCheck(input_api, output_api): 118 def _SkipTreeCheck(input_api, output_api):
62 """Check the env var whether we want to skip tree check. 119 """Check the env var whether we want to skip tree check.
63 Only skip if src/version.cc has been updated.""" 120 Only skip if src/version.cc has been updated."""
64 src_version = 'src/version.cc' 121 src_version = 'src/version.cc'
65 FilterFile = lambda file: file.LocalPath() == src_version 122 FilterFile = lambda file: file.LocalPath() == src_version
66 if not input_api.AffectedSourceFiles( 123 if not input_api.AffectedSourceFiles(
67 lambda file: file.LocalPath() == src_version): 124 lambda file: file.LocalPath() == src_version):
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 'v8_linux_nosnap_rel': set(['defaulttests']), 165 'v8_linux_nosnap_rel': set(['defaulttests']),
109 'v8_linux_nosnap_dbg': set(['defaulttests']), 166 'v8_linux_nosnap_dbg': set(['defaulttests']),
110 'v8_linux64_rel': set(['defaulttests']), 167 'v8_linux64_rel': set(['defaulttests']),
111 'v8_linux_arm_dbg': set(['defaulttests']), 168 'v8_linux_arm_dbg': set(['defaulttests']),
112 'v8_linux_arm64_rel': set(['defaulttests']), 169 'v8_linux_arm64_rel': set(['defaulttests']),
113 'v8_linux_layout_dbg': set(['defaulttests']), 170 'v8_linux_layout_dbg': set(['defaulttests']),
114 'v8_mac_rel': set(['defaulttests']), 171 'v8_mac_rel': set(['defaulttests']),
115 'v8_win_rel': set(['defaulttests']), 172 'v8_win_rel': set(['defaulttests']),
116 }, 173 },
117 } 174 }
OLDNEW
« no previous file with comments | « DEPS ('k') | src/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698