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

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

Issue 1828693002: Reland of Android: Run lint using a cache in the output directory (fix-up) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 9 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 | « build/android/android_lint_cache.gyp ('k') | 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 argparse 10 import argparse
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 src_dir = NewSourceDir() 123 src_dir = NewSourceDir()
124 os.symlink(os.path.abspath(src), PathInDir(src_dir, src)) 124 os.symlink(os.path.abspath(src), PathInDir(src_dir, src))
125 125
126 if manifest_path: 126 if manifest_path:
127 cmd.append(_RelativizePath(os.path.join(manifest_path, os.pardir))) 127 cmd.append(_RelativizePath(os.path.join(manifest_path, os.pardir)))
128 128
129 if os.path.exists(result_path): 129 if os.path.exists(result_path):
130 os.remove(result_path) 130 os.remove(result_path)
131 131
132 env = {} 132 env = {}
133 stderr_filter = None
133 if cache_dir: 134 if cache_dir:
135 # When _JAVA_OPTIONS is set, java prints to stderr:
136 # Picked up _JAVA_OPTIONS: ...
134 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) 137 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir)
138 stderr_filter = lambda l: '' if '_JAVA_OPTIONS' in l else l
mlopatkin 2016/04/06 22:03:11 Sorry for posting in this closed review but I supp
agrieve 2016/04/06 23:55:33 ooo, nice catch! the intention was to just hide th
135 139
136 try: 140 try:
137 build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None) 141 build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None,
142 stderr_filter=stderr_filter)
138 except build_utils.CalledProcessError: 143 except build_utils.CalledProcessError:
139 if can_fail_build: 144 if can_fail_build:
140 traceback.print_exc() 145 traceback.print_exc()
141 146
142 # There is a problem with lint usage 147 # There is a problem with lint usage
143 if not os.path.exists(result_path): 148 if not os.path.exists(result_path):
144 raise 149 raise
145 150
146 # There are actual lint issues 151 # There are actual lint issues
147 else: 152 else:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 def main(): 184 def main():
180 parser = argparse.ArgumentParser() 185 parser = argparse.ArgumentParser()
181 build_utils.AddDepfileOption(parser) 186 build_utils.AddDepfileOption(parser)
182 187
183 parser.add_argument('--lint-path', required=True, 188 parser.add_argument('--lint-path', required=True,
184 help='Path to lint executable.') 189 help='Path to lint executable.')
185 parser.add_argument('--product-dir', required=True, 190 parser.add_argument('--product-dir', required=True,
186 help='Path to product dir.') 191 help='Path to product dir.')
187 parser.add_argument('--result-path', required=True, 192 parser.add_argument('--result-path', required=True,
188 help='Path to XML lint result file.') 193 help='Path to XML lint result file.')
189 194 parser.add_argument('--cache-dir', required=True,
190 parser.add_argument('--build-tools-version',
191 help='Version of the build tools in the Android SDK.')
192 parser.add_argument('--cache-dir',
193 help='Path to the directory in which the android cache ' 195 help='Path to the directory in which the android cache '
194 'directory tree should be stored.') 196 'directory tree should be stored.')
197 parser.add_argument('--platform-xml-path', required=True,
198 help='Path to api-platforms.xml')
199 parser.add_argument('--create-cache', action='store_true',
200 help='Mark the lint cache file as an output rather than '
201 'an input.')
195 parser.add_argument('--can-fail-build', action='store_true', 202 parser.add_argument('--can-fail-build', action='store_true',
196 help='If set, script will exit with nonzero exit status' 203 help='If set, script will exit with nonzero exit status'
197 ' if lint errors are present') 204 ' if lint errors are present')
198 parser.add_argument('--config-path', 205 parser.add_argument('--config-path',
199 help='Path to lint suppressions file.') 206 help='Path to lint suppressions file.')
200 parser.add_argument('--enable', action='store_true', 207 parser.add_argument('--enable', action='store_true',
201 help='Run lint instead of just touching stamp.') 208 help='Run lint instead of just touching stamp.')
202 parser.add_argument('--jar-path', 209 parser.add_argument('--jar-path',
203 help='Jar file containing class files.') 210 help='Jar file containing class files.')
204 parser.add_argument('--java-files', 211 parser.add_argument('--java-files',
205 help='Paths to java files.') 212 help='Paths to java files.')
206 parser.add_argument('--manifest-path', 213 parser.add_argument('--manifest-path',
207 help='Path to AndroidManifest.xml') 214 help='Path to AndroidManifest.xml')
208 parser.add_argument('--platform-xml-path',
209 help='Path to api-platforms.xml')
210 parser.add_argument('--processed-config-path', 215 parser.add_argument('--processed-config-path',
211 help='Path to processed lint suppressions file.') 216 help='Path to processed lint suppressions file.')
212 parser.add_argument('--resource-dir', 217 parser.add_argument('--resource-dir',
213 help='Path to resource dir.') 218 help='Path to resource dir.')
214 parser.add_argument('--silent', action='store_true', 219 parser.add_argument('--silent', action='store_true',
215 help='If set, script will not log anything.') 220 help='If set, script will not log anything.')
216 parser.add_argument('--src-dirs', 221 parser.add_argument('--src-dirs',
217 help='Directories containing java files.') 222 help='Directories containing java files.')
218 parser.add_argument('--stamp', 223 parser.add_argument('--stamp',
219 help='Path to touch on success.') 224 help='Path to touch on success.')
220 225
221 args = parser.parse_args() 226 args = parser.parse_args()
222 227
223 if args.enable: 228 if args.enable:
224 sources = [] 229 sources = []
225 if args.src_dirs: 230 if args.src_dirs:
226 src_dirs = build_utils.ParseGypList(args.src_dirs) 231 src_dirs = build_utils.ParseGypList(args.src_dirs)
227 sources = build_utils.FindInDirectories(src_dirs, '*.java') 232 sources = build_utils.FindInDirectories(src_dirs, '*.java')
228 elif args.java_files: 233 elif args.java_files:
229 sources = build_utils.ParseGypList(args.java_files) 234 sources = build_utils.ParseGypList(args.java_files)
230 235
231 if args.config_path and not args.processed_config_path: 236 if args.config_path and not args.processed_config_path:
232 parser.error('--config-path specified without --processed-config-path') 237 parser.error('--config-path specified without --processed-config-path')
233 elif args.processed_config_path and not args.config_path: 238 elif args.processed_config_path and not args.config_path:
234 parser.error('--processed-config-path specified without --config-path') 239 parser.error('--processed-config-path specified without --config-path')
235 240
236 input_paths = [ 241 input_paths = [
237 args.lint_path, 242 args.lint_path,
243 args.platform_xml_path,
238 ] 244 ]
239 if args.config_path: 245 if args.config_path:
240 input_paths.append(args.config_path) 246 input_paths.append(args.config_path)
241 if args.jar_path: 247 if args.jar_path:
242 input_paths.append(args.jar_path) 248 input_paths.append(args.jar_path)
243 if args.manifest_path: 249 if args.manifest_path:
244 input_paths.append(args.manifest_path) 250 input_paths.append(args.manifest_path)
245 if args.platform_xml_path:
246 input_paths.append(args.platform_xml_path)
247 if args.resource_dir: 251 if args.resource_dir:
248 input_paths.extend(build_utils.FindInDirectory(args.resource_dir, '*')) 252 input_paths.extend(build_utils.FindInDirectory(args.resource_dir, '*'))
249 if sources: 253 if sources:
250 input_paths.extend(sources) 254 input_paths.extend(sources)
251 255
252 input_strings = [] 256 input_strings = []
253 if args.processed_config_path: 257 if args.processed_config_path:
254 input_strings.append(args.processed_config_path) 258 input_strings.append(args.processed_config_path)
255 259
256 output_paths = [ args.result_path ] 260 output_paths = [ args.result_path ]
257 if args.cache_dir:
258 if not args.build_tools_version:
259 parser.error('--cache-dir specified without --build-tools-version')
260 output_paths.append(os.path.join(
261 args.cache_dir, '.android', 'cache',
262 'api-versions-6-%s.bin' % args.build_tools_version))
263 261
264 build_utils.CallAndWriteDepfileIfStale( 262 build_utils.CallAndWriteDepfileIfStale(
265 lambda changes: _OnStaleMd5(changes, args.lint_path, 263 lambda changes: _OnStaleMd5(changes, args.lint_path,
266 args.config_path, 264 args.config_path,
267 args.processed_config_path, 265 args.processed_config_path,
268 args.manifest_path, args.result_path, 266 args.manifest_path, args.result_path,
269 args.product_dir, sources, 267 args.product_dir, sources,
270 args.jar_path, 268 args.jar_path,
271 args.cache_dir, 269 args.cache_dir,
272 resource_dir=args.resource_dir, 270 resource_dir=args.resource_dir,
273 can_fail_build=args.can_fail_build, 271 can_fail_build=args.can_fail_build,
274 silent=args.silent), 272 silent=args.silent),
275 args, 273 args,
276 input_paths=input_paths, 274 input_paths=input_paths,
277 input_strings=input_strings, 275 input_strings=input_strings,
278 output_paths=output_paths, 276 output_paths=output_paths,
279 pass_changes=True) 277 pass_changes=True)
280 278
281 279
282 if __name__ == '__main__': 280 if __name__ == '__main__':
283 sys.exit(main()) 281 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/android_lint_cache.gyp ('k') | build/android/lint_action.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698