| OLD | NEW |
| 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 Loading... |
| 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 | |
| 134 if cache_dir: | 133 if cache_dir: |
| 135 # When _JAVA_OPTIONS is set, java prints to stderr: | |
| 136 # Picked up _JAVA_OPTIONS: ... | |
| 137 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) | 134 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) |
| 138 stderr_filter = lambda l: '' if '_JAVA_OPTIONS' in l else l | |
| 139 | 135 |
| 140 try: | 136 try: |
| 141 build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None, | 137 build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None) |
| 142 stderr_filter=stderr_filter) | |
| 143 except build_utils.CalledProcessError: | 138 except build_utils.CalledProcessError: |
| 144 if can_fail_build: | 139 if can_fail_build: |
| 145 traceback.print_exc() | 140 traceback.print_exc() |
| 146 | 141 |
| 147 # There is a problem with lint usage | 142 # There is a problem with lint usage |
| 148 if not os.path.exists(result_path): | 143 if not os.path.exists(result_path): |
| 149 raise | 144 raise |
| 150 | 145 |
| 151 # There are actual lint issues | 146 # There are actual lint issues |
| 152 else: | 147 else: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 parser.add_argument('--product-dir', required=True, | 183 parser.add_argument('--product-dir', required=True, |
| 189 help='Path to product dir.') | 184 help='Path to product dir.') |
| 190 parser.add_argument('--result-path', required=True, | 185 parser.add_argument('--result-path', required=True, |
| 191 help='Path to XML lint result file.') | 186 help='Path to XML lint result file.') |
| 192 | 187 |
| 193 parser.add_argument('--build-tools-version', | 188 parser.add_argument('--build-tools-version', |
| 194 help='Version of the build tools in the Android SDK.') | 189 help='Version of the build tools in the Android SDK.') |
| 195 parser.add_argument('--cache-dir', | 190 parser.add_argument('--cache-dir', |
| 196 help='Path to the directory in which the android cache ' | 191 help='Path to the directory in which the android cache ' |
| 197 'directory tree should be stored.') | 192 '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.') | |
| 201 parser.add_argument('--can-fail-build', action='store_true', | 193 parser.add_argument('--can-fail-build', action='store_true', |
| 202 help='If set, script will exit with nonzero exit status' | 194 help='If set, script will exit with nonzero exit status' |
| 203 ' if lint errors are present') | 195 ' if lint errors are present') |
| 204 parser.add_argument('--config-path', | 196 parser.add_argument('--config-path', |
| 205 help='Path to lint suppressions file.') | 197 help='Path to lint suppressions file.') |
| 206 parser.add_argument('--enable', action='store_true', | 198 parser.add_argument('--enable', action='store_true', |
| 207 help='Run lint instead of just touching stamp.') | 199 help='Run lint instead of just touching stamp.') |
| 208 parser.add_argument('--jar-path', | 200 parser.add_argument('--jar-path', |
| 209 help='Jar file containing class files.') | 201 help='Jar file containing class files.') |
| 210 parser.add_argument('--java-files', | 202 parser.add_argument('--java-files', |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 input_paths.extend(sources) | 248 input_paths.extend(sources) |
| 257 | 249 |
| 258 input_strings = [] | 250 input_strings = [] |
| 259 if args.processed_config_path: | 251 if args.processed_config_path: |
| 260 input_strings.append(args.processed_config_path) | 252 input_strings.append(args.processed_config_path) |
| 261 | 253 |
| 262 output_paths = [ args.result_path ] | 254 output_paths = [ args.result_path ] |
| 263 if args.cache_dir: | 255 if args.cache_dir: |
| 264 if not args.build_tools_version: | 256 if not args.build_tools_version: |
| 265 parser.error('--cache-dir specified without --build-tools-version') | 257 parser.error('--cache-dir specified without --build-tools-version') |
| 266 _cache_file = os.path.join( | 258 output_paths.append(os.path.join( |
| 267 args.cache_dir, '.android', 'cache', | 259 args.cache_dir, '.android', 'cache', |
| 268 'api-versions-6-%s.bin' % args.build_tools_version) | 260 '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) | |
| 273 | 261 |
| 274 build_utils.CallAndWriteDepfileIfStale( | 262 build_utils.CallAndWriteDepfileIfStale( |
| 275 lambda changes: _OnStaleMd5(changes, args.lint_path, | 263 lambda changes: _OnStaleMd5(changes, args.lint_path, |
| 276 args.config_path, | 264 args.config_path, |
| 277 args.processed_config_path, | 265 args.processed_config_path, |
| 278 args.manifest_path, args.result_path, | 266 args.manifest_path, args.result_path, |
| 279 args.product_dir, sources, | 267 args.product_dir, sources, |
| 280 args.jar_path, | 268 args.jar_path, |
| 281 args.cache_dir, | 269 args.cache_dir, |
| 282 resource_dir=args.resource_dir, | 270 resource_dir=args.resource_dir, |
| 283 can_fail_build=args.can_fail_build, | 271 can_fail_build=args.can_fail_build, |
| 284 silent=args.silent), | 272 silent=args.silent), |
| 285 args, | 273 args, |
| 286 input_paths=input_paths, | 274 input_paths=input_paths, |
| 287 input_strings=input_strings, | 275 input_strings=input_strings, |
| 288 output_paths=output_paths, | 276 output_paths=output_paths, |
| 289 pass_changes=True) | 277 pass_changes=True) |
| 290 | 278 |
| 291 | 279 |
| 292 if __name__ == '__main__': | 280 if __name__ == '__main__': |
| 293 sys.exit(main()) | 281 sys.exit(main()) |
| OLD | NEW |