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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 # There may be multiple source files with the same basename (but in | 100 # There may be multiple source files with the same basename (but in |
101 # different directories). It is difficult to determine what part of the path | 101 # different directories). It is difficult to determine what part of the path |
102 # corresponds to the java package, and so instead just link the source files | 102 # corresponds to the java package, and so instead just link the source files |
103 # into temporary directories (creating a new one whenever there is a name | 103 # into temporary directories (creating a new one whenever there is a name |
104 # conflict). | 104 # conflict). |
105 src_dirs = [] | 105 src_dirs = [] |
106 def NewSourceDir(): | 106 def NewSourceDir(): |
107 new_dir = os.path.join(temp_dir, str(len(src_dirs))) | 107 new_dir = os.path.join(temp_dir, str(len(src_dirs))) |
108 os.mkdir(new_dir) | 108 os.mkdir(new_dir) |
109 src_dirs.append(new_dir) | 109 src_dirs.append(new_dir) |
110 cmd.extend(['--sources', _RelativizePath(new_dir)]) | |
111 return new_dir | 110 return new_dir |
112 | 111 |
113 def PathInDir(d, src): | 112 def PathInDir(d, src): |
114 return os.path.join(d, os.path.basename(src)) | 113 return os.path.join(d, os.path.basename(src)) |
115 | 114 |
116 for src in sources: | 115 for src in sources: |
117 src_dir = None | 116 src_dir = None |
118 for d in src_dirs: | 117 for d in src_dirs: |
119 if not os.path.exists(PathInDir(d, src)): | 118 if not os.path.exists(PathInDir(d, src)): |
120 src_dir = d | 119 src_dir = d |
121 break | 120 break |
122 if not src_dir: | 121 if not src_dir: |
123 src_dir = NewSourceDir() | 122 src_dir = NewSourceDir() |
| 123 cmd.extend(['--sources', _RelativizePath(src_dir)]) |
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 # Put the manifest in a temporary directory in order to avoid lint detecting |
| 127 # sibling res/ and src/ directories (which should be pass explicitly if they |
| 128 # are to be included). |
126 if manifest_path: | 129 if manifest_path: |
127 cmd.append(_RelativizePath(os.path.join(manifest_path, os.pardir))) | 130 src_dir = NewSourceDir() |
| 131 os.symlink(os.path.abspath(manifest_path), |
| 132 PathInDir(src_dir, manifest_path)) |
| 133 cmd.append(src_dir) |
128 | 134 |
129 if os.path.exists(result_path): | 135 if os.path.exists(result_path): |
130 os.remove(result_path) | 136 os.remove(result_path) |
131 | 137 |
132 env = {} | 138 env = {} |
133 stderr_filter = None | 139 stderr_filter = None |
134 if cache_dir: | 140 if cache_dir: |
135 # When _JAVA_OPTIONS is set, java prints to stderr: | 141 # When _JAVA_OPTIONS is set, java prints to stderr: |
136 # Picked up _JAVA_OPTIONS: ... | 142 # Picked up _JAVA_OPTIONS: ... |
137 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) | 143 env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 silent=args.silent), | 290 silent=args.silent), |
285 args, | 291 args, |
286 input_paths=input_paths, | 292 input_paths=input_paths, |
287 input_strings=input_strings, | 293 input_strings=input_strings, |
288 output_paths=output_paths, | 294 output_paths=output_paths, |
289 pass_changes=True) | 295 pass_changes=True) |
290 | 296 |
291 | 297 |
292 if __name__ == '__main__': | 298 if __name__ == '__main__': |
293 sys.exit(main()) | 299 sys.exit(main()) |
OLD | NEW |