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

Side by Side Diff: build/android/gyp/lint.py

Issue 458653002: Update lint and findbugs to use jars instead of class files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a landmine Created 6 years, 4 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
« no previous file with comments | « no previous file | build/android/lint_action.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Runs Android's lint tool.""" 7 """Runs Android's lint tool."""
8 8
9 9
10 import optparse 10 import optparse
11 import os 11 import os
12 import sys 12 import sys
13 from xml.dom import minidom 13 from xml.dom import minidom
14 14
15 from util import build_utils 15 from util import build_utils
16 16
17 17
18 _SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 18 _SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),
19 '..', '..', '..')) 19 '..', '..', '..'))
20 20
21 21
22 def _RunLint(lint_path, config_path, processed_config_path, manifest_path, 22 def _RunLint(lint_path, config_path, processed_config_path, manifest_path,
23 result_path, product_dir, src_dirs, classes_dir): 23 result_path, product_dir, src_dirs, jar_path):
24 24
25 def _RelativizePath(path): 25 def _RelativizePath(path):
26 """Returns relative path to top-level src dir. 26 """Returns relative path to top-level src dir.
27 27
28 Args: 28 Args:
29 path: A path relative to cwd. 29 path: A path relative to cwd.
30 """ 30 """
31 return os.path.relpath(os.path.abspath(path), _SRC_ROOT) 31 return os.path.relpath(os.path.abspath(path), _SRC_ROOT)
32 32
33 def _ProcessConfigFile(): 33 def _ProcessConfigFile():
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 error_line = issue.getAttribute(attr) 69 error_line = issue.getAttribute(attr)
70 if error_line: 70 if error_line:
71 print >> sys.stderr, error_line 71 print >> sys.stderr, error_line
72 return len(issues) 72 return len(issues)
73 73
74 _ProcessConfigFile() 74 _ProcessConfigFile()
75 75
76 cmd = [ 76 cmd = [
77 lint_path, '-Werror', '--exitcode', '--showall', 77 lint_path, '-Werror', '--exitcode', '--showall',
78 '--config', _RelativizePath(processed_config_path), 78 '--config', _RelativizePath(processed_config_path),
79 '--classpath', _RelativizePath(classes_dir), 79 '--classpath', _RelativizePath(jar_path),
80 '--xml', _RelativizePath(result_path), 80 '--xml', _RelativizePath(result_path),
81 ] 81 ]
82 for src in src_dirs: 82 for src in src_dirs:
83 cmd.extend(['--sources', _RelativizePath(src)]) 83 cmd.extend(['--sources', _RelativizePath(src)])
84 cmd.append(_RelativizePath(os.path.join(manifest_path, os.pardir))) 84 cmd.append(_RelativizePath(os.path.join(manifest_path, os.pardir)))
85 85
86 if os.path.exists(result_path): 86 if os.path.exists(result_path):
87 os.remove(result_path) 87 os.remove(result_path)
88 88
89 try: 89 try:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 def main(): 128 def main():
129 parser = optparse.OptionParser() 129 parser = optparse.OptionParser()
130 parser.add_option('--lint-path', help='Path to lint executable.') 130 parser.add_option('--lint-path', help='Path to lint executable.')
131 parser.add_option('--config-path', help='Path to lint suppressions file.') 131 parser.add_option('--config-path', help='Path to lint suppressions file.')
132 parser.add_option('--processed-config-path', 132 parser.add_option('--processed-config-path',
133 help='Path to processed lint suppressions file.') 133 help='Path to processed lint suppressions file.')
134 parser.add_option('--manifest-path', help='Path to AndroidManifest.xml') 134 parser.add_option('--manifest-path', help='Path to AndroidManifest.xml')
135 parser.add_option('--result-path', help='Path to XML lint result file.') 135 parser.add_option('--result-path', help='Path to XML lint result file.')
136 parser.add_option('--product-dir', help='Path to product dir.') 136 parser.add_option('--product-dir', help='Path to product dir.')
137 parser.add_option('--src-dirs', help='Directories containing java files.') 137 parser.add_option('--src-dirs', help='Directories containing java files.')
138 parser.add_option('--classes-dir', help='Directory containing class files.') 138 parser.add_option('--jar-path', help='Jar file containing class files.')
139 parser.add_option('--stamp', help='Path to touch on success.') 139 parser.add_option('--stamp', help='Path to touch on success.')
140 parser.add_option('--enable', action='store_true', 140 parser.add_option('--enable', action='store_true',
141 help='Run lint instead of just touching stamp.') 141 help='Run lint instead of just touching stamp.')
142 142
143 options, _ = parser.parse_args() 143 options, _ = parser.parse_args()
144 144
145 build_utils.CheckOptions( 145 build_utils.CheckOptions(
146 options, parser, required=['lint_path', 'config_path', 146 options, parser, required=['lint_path', 'config_path',
147 'processed_config_path', 'manifest_path', 147 'processed_config_path', 'manifest_path',
148 'result_path', 'product_dir', 'src_dirs', 148 'result_path', 'product_dir', 'src_dirs',
149 'classes_dir']) 149 'jar_path'])
150 150
151 src_dirs = build_utils.ParseGypList(options.src_dirs) 151 src_dirs = build_utils.ParseGypList(options.src_dirs)
152 152
153 rc = 0 153 rc = 0
154 154
155 if options.enable: 155 if options.enable:
156 rc = _RunLint(options.lint_path, options.config_path, 156 rc = _RunLint(options.lint_path, options.config_path,
157 options.processed_config_path, 157 options.processed_config_path,
158 options.manifest_path, options.result_path, 158 options.manifest_path, options.result_path,
159 options.product_dir, src_dirs, options.classes_dir) 159 options.product_dir, src_dirs, options.jar_path)
160 160
161 if options.stamp and not rc: 161 if options.stamp and not rc:
162 build_utils.Touch(options.stamp) 162 build_utils.Touch(options.stamp)
163 163
164 return rc 164 return rc
165 165
166 166
167 if __name__ == '__main__': 167 if __name__ == '__main__':
168 sys.exit(main()) 168 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/lint_action.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698