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

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

Issue 1824093002: 🌈 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: review 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/config/android/internal_rules.gni » ('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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 parser.add_argument('--product-dir', required=True, 188 parser.add_argument('--product-dir', required=True,
184 help='Path to product dir.') 189 help='Path to product dir.')
185 parser.add_argument('--result-path', required=True, 190 parser.add_argument('--result-path', required=True,
186 help='Path to XML lint result file.') 191 help='Path to XML lint result file.')
187 192
188 parser.add_argument('--build-tools-version', 193 parser.add_argument('--build-tools-version',
189 help='Version of the build tools in the Android SDK.') 194 help='Version of the build tools in the Android SDK.')
190 parser.add_argument('--cache-dir', 195 parser.add_argument('--cache-dir',
191 help='Path to the directory in which the android cache ' 196 help='Path to the directory in which the android cache '
192 'directory tree should be stored.') 197 'directory tree should be stored.')
198 parser.add_argument('--create-cache', action='store_true',
199 help='Mark the lint cache file as an output rather than '
200 'an input.')
193 parser.add_argument('--can-fail-build', action='store_true', 201 parser.add_argument('--can-fail-build', action='store_true',
194 help='If set, script will exit with nonzero exit status' 202 help='If set, script will exit with nonzero exit status'
195 ' if lint errors are present') 203 ' if lint errors are present')
196 parser.add_argument('--config-path', 204 parser.add_argument('--config-path',
197 help='Path to lint suppressions file.') 205 help='Path to lint suppressions file.')
198 parser.add_argument('--enable', action='store_true', 206 parser.add_argument('--enable', action='store_true',
199 help='Run lint instead of just touching stamp.') 207 help='Run lint instead of just touching stamp.')
200 parser.add_argument('--jar-path', 208 parser.add_argument('--jar-path',
201 help='Jar file containing class files.') 209 help='Jar file containing class files.')
202 parser.add_argument('--java-files', 210 parser.add_argument('--java-files',
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 input_paths.extend(sources) 256 input_paths.extend(sources)
249 257
250 input_strings = [] 258 input_strings = []
251 if args.processed_config_path: 259 if args.processed_config_path:
252 input_strings.append(args.processed_config_path) 260 input_strings.append(args.processed_config_path)
253 261
254 output_paths = [ args.result_path ] 262 output_paths = [ args.result_path ]
255 if args.cache_dir: 263 if args.cache_dir:
256 if not args.build_tools_version: 264 if not args.build_tools_version:
257 parser.error('--cache-dir specified without --build-tools-version') 265 parser.error('--cache-dir specified without --build-tools-version')
258 output_paths.append(os.path.join( 266 _cache_file = os.path.join(
259 args.cache_dir, '.android', 'cache', 267 args.cache_dir, '.android', 'cache',
260 'api-versions-6-%s.bin' % args.build_tools_version)) 268 'api-versions-6-%s.bin' % args.build_tools_version)
269 if args.create_cache:
270 output_paths.append(_cache_file)
271 else:
272 input_paths.append(_cache_file)
261 273
262 build_utils.CallAndWriteDepfileIfStale( 274 build_utils.CallAndWriteDepfileIfStale(
263 lambda changes: _OnStaleMd5(changes, args.lint_path, 275 lambda changes: _OnStaleMd5(changes, args.lint_path,
264 args.config_path, 276 args.config_path,
265 args.processed_config_path, 277 args.processed_config_path,
266 args.manifest_path, args.result_path, 278 args.manifest_path, args.result_path,
267 args.product_dir, sources, 279 args.product_dir, sources,
268 args.jar_path, 280 args.jar_path,
269 args.cache_dir, 281 args.cache_dir,
270 resource_dir=args.resource_dir, 282 resource_dir=args.resource_dir,
271 can_fail_build=args.can_fail_build, 283 can_fail_build=args.can_fail_build,
272 silent=args.silent), 284 silent=args.silent),
273 args, 285 args,
274 input_paths=input_paths, 286 input_paths=input_paths,
275 input_strings=input_strings, 287 input_strings=input_strings,
276 output_paths=output_paths, 288 output_paths=output_paths,
277 pass_changes=True) 289 pass_changes=True)
278 290
279 291
280 if __name__ == '__main__': 292 if __name__ == '__main__':
281 sys.exit(main()) 293 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/android_lint_cache.gyp ('k') | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698