OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 """Process Android resources to generate R.java, and prepare for packaging. | 7 """Process Android resources to generate R.java, and prepare for packaging. |
8 | 8 |
9 This will crunch images and generate v14 compatible resources | 9 This will crunch images and generate v14 compatible resources |
10 (see generate_v14_compatible_resources.py). | 10 (see generate_v14_compatible_resources.py). |
11 """ | 11 """ |
12 | 12 |
13 import codecs | 13 import codecs |
14 import collections | 14 import collections |
15 import optparse | 15 import optparse |
16 import os | 16 import os |
17 import re | 17 import re |
18 import shutil | 18 import shutil |
19 import sys | 19 import sys |
| 20 import xml.etree.ElementTree |
20 | 21 |
21 import generate_v14_compatible_resources | 22 import generate_v14_compatible_resources |
22 | 23 |
23 from util import build_utils | 24 from util import build_utils |
24 | 25 |
25 # Import jinja2 from third_party/jinja2 | 26 # Import jinja2 from third_party/jinja2 |
26 sys.path.insert(1, | 27 sys.path.insert(1, |
27 os.path.join(os.path.dirname(__file__), '../../../third_party')) | 28 os.path.join(os.path.dirname(__file__), '../../../third_party')) |
28 from jinja2 import Template # pylint: disable=F0401 | 29 from jinja2 import Template # pylint: disable=F0401 |
29 | 30 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 137 |
137 if options.extra_r_text_files: | 138 if options.extra_r_text_files: |
138 options.extra_r_text_files = ( | 139 options.extra_r_text_files = ( |
139 build_utils.ParseGypList(options.extra_r_text_files)) | 140 build_utils.ParseGypList(options.extra_r_text_files)) |
140 else: | 141 else: |
141 options.extra_r_text_files = [] | 142 options.extra_r_text_files = [] |
142 | 143 |
143 return options | 144 return options |
144 | 145 |
145 | 146 |
146 def CreateExtraRJavaFiles( | 147 def CreateRJavaFiles(srcjar_dir, main_r_txt_file, packages, r_txt_files, |
147 r_dir, extra_packages, extra_r_text_files, shared_resources, include_all): | 148 shared_resources): |
148 if include_all: | 149 assert len(packages) == len(r_txt_files), 'Need one R.txt file per package' |
149 java_files = build_utils.FindInDirectory(r_dir, "R.java") | |
150 if len(java_files) != 1: | |
151 return | |
152 r_java_file = java_files[0] | |
153 r_java_contents = codecs.open(r_java_file, encoding='utf-8').read() | |
154 | 150 |
155 for package in extra_packages: | 151 # Map of (resource_type, name) -> Entry. |
156 package_r_java_dir = os.path.join(r_dir, *package.split('.')) | 152 # Contains the correct values for resources. |
157 build_utils.MakeDirectory(package_r_java_dir) | 153 all_resources = {} |
158 package_r_java_path = os.path.join(package_r_java_dir, 'R.java') | 154 for entry in _ParseTextSymbolsFile(main_r_txt_file): |
159 new_r_java = re.sub(r'package [.\w]*;', u'package %s;' % package, | 155 all_resources[(entry.resource_type, entry.name)] = entry |
160 r_java_contents) | |
161 codecs.open(package_r_java_path, 'w', encoding='utf-8').write(new_r_java) | |
162 else: | |
163 if len(extra_packages) != len(extra_r_text_files): | |
164 raise Exception('Need one R.txt file per extra package') | |
165 | 156 |
166 r_txt_file = os.path.join(r_dir, 'R.txt') | 157 # Map of package_name->resource_type->entry |
167 if not os.path.exists(r_txt_file): | 158 resources_by_package = ( |
168 return | 159 collections.defaultdict(lambda: collections.defaultdict(list))) |
| 160 # Build the R.java files using each package's R.txt file, but replacing |
| 161 # each entry's placeholder value with correct values from all_resources. |
| 162 for package, r_txt_file in zip(packages, r_txt_files): |
| 163 if package in resources_by_package: |
| 164 raise Exception(('Package name "%s" appeared twice. All ' |
| 165 'android_resources() targets must use unique package ' |
| 166 'names, or no package name at all.') % package) |
| 167 resources_by_type = resources_by_package[package] |
| 168 # The sub-R.txt files have the wrong values at this point. Read them to |
| 169 # figure out which entries belong to them, but use the values from the |
| 170 # main R.txt file. |
| 171 for entry in _ParseTextSymbolsFile(r_txt_file): |
| 172 entry = all_resources[(entry.resource_type, entry.name)] |
| 173 resources_by_type[entry.resource_type].append(entry) |
169 | 174 |
170 # Map of (resource_type, name) -> Entry. | 175 for package, resources_by_type in resources_by_package.iteritems(): |
171 # Contains the correct values for resources. | 176 package_r_java_dir = os.path.join(srcjar_dir, *package.split('.')) |
172 all_resources = {} | 177 build_utils.MakeDirectory(package_r_java_dir) |
173 for entry in _ParseTextSymbolsFile(r_txt_file): | 178 package_r_java_path = os.path.join(package_r_java_dir, 'R.java') |
174 all_resources[(entry.resource_type, entry.name)] = entry | 179 java_file_contents = _CreateRJavaFile( |
175 | 180 package, resources_by_type, shared_resources) |
176 # Map of package_name->resource_type->entry | 181 with open(package_r_java_path, 'w') as f: |
177 resources_by_package = ( | 182 f.write(java_file_contents) |
178 collections.defaultdict(lambda: collections.defaultdict(list))) | |
179 # Build the R.java files using each package's R.txt file, but replacing | |
180 # each entry's placeholder value with correct values from all_resources. | |
181 for package, r_text_file in zip(extra_packages, extra_r_text_files): | |
182 if not os.path.exists(r_text_file): | |
183 continue | |
184 if package in resources_by_package: | |
185 raise Exception(('Package name "%s" appeared twice. All ' | |
186 'android_resources() targets must use unique package ' | |
187 'names, or no package name at all.') % package) | |
188 resources_by_type = resources_by_package[package] | |
189 # The sub-R.txt files have the wrong values at this point. Read them to | |
190 # figure out which entries belong to them, but use the values from the | |
191 # main R.txt file. | |
192 for entry in _ParseTextSymbolsFile(r_text_file): | |
193 entry = all_resources[(entry.resource_type, entry.name)] | |
194 resources_by_type[entry.resource_type].append(entry) | |
195 | |
196 for package, resources_by_type in resources_by_package.iteritems(): | |
197 package_r_java_dir = os.path.join(r_dir, *package.split('.')) | |
198 build_utils.MakeDirectory(package_r_java_dir) | |
199 package_r_java_path = os.path.join(package_r_java_dir, 'R.java') | |
200 java_file_contents = _CreateExtraRJavaFile( | |
201 package, resources_by_type, shared_resources) | |
202 with open(package_r_java_path, 'w') as f: | |
203 f.write(java_file_contents) | |
204 | 183 |
205 | 184 |
206 def _ParseTextSymbolsFile(path): | 185 def _ParseTextSymbolsFile(path): |
207 """Given an R.txt file, returns a list of TextSymbolsEntry.""" | 186 """Given an R.txt file, returns a list of TextSymbolsEntry.""" |
208 ret = [] | 187 ret = [] |
209 with open(path) as f: | 188 with open(path) as f: |
210 for line in f: | 189 for line in f: |
211 m = re.match(r'(int(?:\[\])?) (\w+) (\w+) (.+)$', line) | 190 m = re.match(r'(int(?:\[\])?) (\w+) (\w+) (.+)$', line) |
212 if not m: | 191 if not m: |
213 raise Exception('Unexpected line in R.txt: %s' % line) | 192 raise Exception('Unexpected line in R.txt: %s' % line) |
214 java_type, resource_type, name, value = m.groups() | 193 java_type, resource_type, name, value = m.groups() |
215 ret.append(TextSymbolsEntry(java_type, resource_type, name, value)) | 194 ret.append(TextSymbolsEntry(java_type, resource_type, name, value)) |
216 return ret | 195 return ret |
217 | 196 |
218 | 197 |
219 def _CreateExtraRJavaFile(package, resources_by_type, shared_resources): | 198 def _CreateRJavaFile(package, resources_by_type, shared_resources): |
220 """Generates the contents of a R.java file.""" | 199 """Generates the contents of a R.java file.""" |
| 200 # Keep these assignments all on one line to make diffing against regular |
| 201 # aapt-generated files easier. |
| 202 create_id = ('{{ e.resource_type }}.{{ e.name }} = ' |
| 203 '({{ e.resource_type }}.{{ e.name }} & 0x00ffffff) |' |
| 204 ' (packageId << 24);') |
| 205 create_id_arr = ('{{ e.resource_type }}.{{ e.name }}[i] = ' |
| 206 '({{ e.resource_type }}.{{ e.name }}[i] & 0x00ffffff) |' |
| 207 ' (packageId << 24);') |
221 template = Template("""/* AUTO-GENERATED FILE. DO NOT MODIFY. */ | 208 template = Template("""/* AUTO-GENERATED FILE. DO NOT MODIFY. */ |
222 | 209 |
223 package {{ package }}; | 210 package {{ package }}; |
224 | 211 |
225 public final class R { | 212 public final class R { |
226 {% for resource_type in resources %} | 213 {% for resource_type in resource_types %} |
227 public static final class {{ resource_type }} { | 214 public static final class {{ resource_type }} { |
228 {% for e in resources[resource_type] %} | 215 {% for e in resources[resource_type] %} |
229 {% if shared_resources %} | 216 {% if shared_resources %} |
230 public static {{ e.java_type }} {{ e.name }} = {{ e.value }}; | 217 public static {{ e.java_type }} {{ e.name }} = {{ e.value }}; |
231 {% else %} | 218 {% else %} |
232 public static final {{ e.java_type }} {{ e.name }} = {{ e.value }}; | 219 public static final {{ e.java_type }} {{ e.name }} = {{ e.value }}; |
233 {% endif %} | 220 {% endif %} |
234 {% endfor %} | 221 {% endfor %} |
235 } | 222 } |
236 {% endfor %} | 223 {% endfor %} |
237 {% if shared_resources %} | 224 {% if shared_resources %} |
238 public static void onResourcesLoaded(int packageId) { | 225 public static void onResourcesLoaded(int packageId) { |
239 {% for resource_type in resources %} | 226 {% for resource_type in resource_types %} |
| 227 {% for e in resources[resource_type] %} |
| 228 {% if resource_type != 'styleable' and e.java_type != 'int[]' %} |
| 229 """ + create_id + """ |
| 230 {% endif %} |
| 231 {% endfor %} |
240 {% for e in resources[resource_type] %} | 232 {% for e in resources[resource_type] %} |
241 {% if e.java_type == 'int[]' %} | 233 {% if e.java_type == 'int[]' %} |
242 for(int i = 0; i < {{ e.resource_type }}.{{ e.name }}.length; ++i) { | 234 for(int i = 0; i < {{ e.resource_type }}.{{ e.name }}.length; ++i) { |
243 {{ e.resource_type }}.{{ e.name }}[i] = | 235 """ + create_id_arr + """ |
244 ({{ e.resource_type }}.{{ e.name }}[i] & 0x00ffffff) | |
245 | (packageId << 24); | |
246 } | 236 } |
247 {% else %} | |
248 {{ e.resource_type }}.{{ e.name }} = | |
249 ({{ e.resource_type }}.{{ e.name }} & 0x00ffffff) | |
250 | (packageId << 24); | |
251 {% endif %} | 237 {% endif %} |
252 {% endfor %} | 238 {% endfor %} |
253 {% endfor %} | 239 {% endfor %} |
254 } | 240 } |
255 {% endif %} | 241 {% endif %} |
256 } | 242 } |
257 """, trim_blocks=True, lstrip_blocks=True) | 243 """, trim_blocks=True, lstrip_blocks=True) |
258 | 244 |
259 return template.render(package=package, resources=resources_by_type, | 245 return template.render(package=package, |
| 246 resources=resources_by_type, |
| 247 resource_types=sorted(resources_by_type), |
260 shared_resources=shared_resources) | 248 shared_resources=shared_resources) |
261 | 249 |
262 | 250 |
263 def CrunchDirectory(aapt, input_dir, output_dir): | 251 def CrunchDirectory(aapt, input_dir, output_dir): |
264 """Crunches the images in input_dir and its subdirectories into output_dir. | 252 """Crunches the images in input_dir and its subdirectories into output_dir. |
265 | 253 |
266 If an image is already optimized, crunching often increases image size. In | 254 If an image is already optimized, crunching often increases image size. In |
267 this case, the crunched image is overwritten with the original image. | 255 this case, the crunched image is overwritten with the original image. |
268 """ | 256 """ |
269 aapt_cmd = [aapt, | 257 aapt_cmd = [aapt, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 # of the form 0, 1, ..., then each subdirectory will be passed to aapt as a | 322 # of the form 0, 1, ..., then each subdirectory will be passed to aapt as a |
335 # resources directory. While some resources just clobber others (image files, | 323 # resources directory. While some resources just clobber others (image files, |
336 # etc), other resources (particularly .xml files) need to be more | 324 # etc), other resources (particularly .xml files) need to be more |
337 # intelligently merged. That merging is left up to aapt. | 325 # intelligently merged. That merging is left up to aapt. |
338 def path_transform(name, src_zip): | 326 def path_transform(name, src_zip): |
339 return '%d/%s' % (zip_files.index(src_zip), name) | 327 return '%d/%s' % (zip_files.index(src_zip), name) |
340 | 328 |
341 build_utils.MergeZips(output_path, zip_files, path_transform=path_transform) | 329 build_utils.MergeZips(output_path, zip_files, path_transform=path_transform) |
342 | 330 |
343 | 331 |
| 332 def _ExtractPackageFromManifest(manifest_path): |
| 333 doc = xml.etree.ElementTree.parse(manifest_path) |
| 334 return doc.getroot().get('package') |
| 335 |
| 336 |
344 def _OnStaleMd5(options): | 337 def _OnStaleMd5(options): |
345 aapt = options.aapt_path | 338 aapt = options.aapt_path |
346 with build_utils.TempDir() as temp_dir: | 339 with build_utils.TempDir() as temp_dir: |
347 deps_dir = os.path.join(temp_dir, 'deps') | 340 deps_dir = os.path.join(temp_dir, 'deps') |
348 build_utils.MakeDirectory(deps_dir) | 341 build_utils.MakeDirectory(deps_dir) |
349 v14_dir = os.path.join(temp_dir, 'v14') | 342 v14_dir = os.path.join(temp_dir, 'v14') |
350 build_utils.MakeDirectory(v14_dir) | 343 build_utils.MakeDirectory(v14_dir) |
351 | 344 |
352 gen_dir = os.path.join(temp_dir, 'gen') | 345 gen_dir = os.path.join(temp_dir, 'gen') |
353 build_utils.MakeDirectory(gen_dir) | 346 build_utils.MakeDirectory(gen_dir) |
| 347 r_txt_path = os.path.join(gen_dir, 'R.txt') |
| 348 srcjar_dir = os.path.join(temp_dir, 'java') |
354 | 349 |
355 input_resource_dirs = options.resource_dirs | 350 input_resource_dirs = options.resource_dirs |
356 | 351 |
357 if not options.v14_skip: | 352 if not options.v14_skip: |
358 for resource_dir in input_resource_dirs: | 353 for resource_dir in input_resource_dirs: |
359 generate_v14_compatible_resources.GenerateV14Resources( | 354 generate_v14_compatible_resources.GenerateV14Resources( |
360 resource_dir, | 355 resource_dir, |
361 v14_dir) | 356 v14_dir) |
362 | 357 |
363 dep_zips = options.dependencies_res_zips | 358 dep_zips = options.dependencies_res_zips |
(...skipping 11 matching lines...) Expand all Loading... |
375 # generated by merging the resources from all libraries and the main apk | 370 # generated by merging the resources from all libraries and the main apk |
376 # project. | 371 # project. |
377 package_command = [aapt, | 372 package_command = [aapt, |
378 'package', | 373 'package', |
379 '-m', | 374 '-m', |
380 '-M', options.android_manifest, | 375 '-M', options.android_manifest, |
381 '--auto-add-overlay', | 376 '--auto-add-overlay', |
382 '--no-version-vectors', | 377 '--no-version-vectors', |
383 '-I', options.android_sdk_jar, | 378 '-I', options.android_sdk_jar, |
384 '--output-text-symbols', gen_dir, | 379 '--output-text-symbols', gen_dir, |
385 '-J', gen_dir, | 380 '-J', gen_dir, # Required for R.txt generation. |
386 '--ignore-assets', build_utils.AAPT_IGNORE_PATTERN] | 381 '--ignore-assets', build_utils.AAPT_IGNORE_PATTERN] |
387 | 382 |
| 383 # aapt supports only the "--include-all-resources" mode, where each R.java |
| 384 # file ends up with all symbols, rather than only those that it had at the |
| 385 # time it was originally generated. This subtle difference makes no |
| 386 # difference when compiling, but can lead to increased unused symbols in the |
| 387 # resulting R.class files. |
| 388 # TODO(agrieve): See if proguard makes this difference actually translate |
| 389 # into a size difference. If not, we can delete all of our custom R.java |
| 390 # template code above (and make include_all_resources the default). |
| 391 if options.include_all_resources: |
| 392 srcjar_dir = gen_dir |
| 393 if options.extra_res_packages: |
| 394 colon_separated = ':'.join(options.extra_res_packages) |
| 395 package_command += ['--extra-packages', colon_separated] |
| 396 if options.non_constant_id: |
| 397 package_command.append('--non-constant-id') |
| 398 if options.custom_package: |
| 399 package_command += ['--custom-package', options.custom_package] |
| 400 if options.shared_resources: |
| 401 package_command.append('--shared-lib') |
| 402 if options.app_as_shared_lib: |
| 403 package_command.append('--app-as-shared-lib') |
| 404 |
388 for d in input_resource_dirs: | 405 for d in input_resource_dirs: |
389 package_command += ['-S', d] | 406 package_command += ['-S', d] |
390 | 407 |
| 408 # Adding all dependencies as sources is necessary for @type/foo references |
| 409 # to symbols within dependencies to resolve. However, it has the side-effect |
| 410 # that all Java symbols from dependencies are copied into the new R.java. |
| 411 # E.g.: It enables an arguably incorrect usage of |
| 412 # "mypackage.R.id.lib_symbol" where "libpackage.R.id.lib_symbol" would be |
| 413 # more correct. This is just how Android works. |
391 for d in dep_subdirs: | 414 for d in dep_subdirs: |
392 package_command += ['-S', d] | 415 package_command += ['-S', d] |
393 | 416 |
394 if options.non_constant_id: | |
395 package_command.append('--non-constant-id') | |
396 if options.custom_package: | |
397 package_command += ['--custom-package', options.custom_package] | |
398 if options.proguard_file: | 417 if options.proguard_file: |
399 package_command += ['-G', options.proguard_file] | 418 package_command += ['-G', options.proguard_file] |
400 if options.shared_resources: | |
401 package_command.append('--shared-lib') | |
402 if options.app_as_shared_lib: | |
403 package_command.append('--app-as-shared-lib') | |
404 build_utils.CheckOutput(package_command, print_stderr=False) | 419 build_utils.CheckOutput(package_command, print_stderr=False) |
405 | 420 |
406 if options.extra_res_packages: | 421 # When an empty res/ directory is passed, aapt does not write an R.txt. |
407 CreateExtraRJavaFiles( | 422 if not os.path.exists(r_txt_path): |
408 gen_dir, | 423 build_utils.Touch(r_txt_path) |
409 options.extra_res_packages, | 424 |
410 options.extra_r_text_files, | 425 if not options.include_all_resources: |
411 options.shared_resources or options.app_as_shared_lib, | 426 packages = list(options.extra_res_packages) |
412 options.include_all_resources) | 427 r_txt_files = list(options.extra_r_text_files) |
| 428 |
| 429 cur_package = options.custom_package |
| 430 if not options.custom_package: |
| 431 cur_package = _ExtractPackageFromManifest(options.android_manifest) |
| 432 |
| 433 # Don't create a .java file for the current resource target when: |
| 434 # - no package name was provided (either by manifest or build rules), |
| 435 # - there was already a dependent android_resources() with the same |
| 436 # package (occurs mostly when an apk target and resources target share |
| 437 # an AndroidManifest.xml) |
| 438 if cur_package != 'dummy.package' and cur_package not in packages: |
| 439 packages.append(cur_package) |
| 440 r_txt_files.append(r_txt_path) |
| 441 |
| 442 if packages: |
| 443 shared_resources = options.shared_resources or options.app_as_shared_lib |
| 444 CreateRJavaFiles(srcjar_dir, r_txt_path, packages, r_txt_files, |
| 445 shared_resources) |
413 | 446 |
414 # This is the list of directories with resources to put in the final .zip | 447 # This is the list of directories with resources to put in the final .zip |
415 # file. The order of these is important so that crunched/v14 resources | 448 # file. The order of these is important so that crunched/v14 resources |
416 # override the normal ones. | 449 # override the normal ones. |
417 zip_resource_dirs = input_resource_dirs + [v14_dir] | 450 zip_resource_dirs = input_resource_dirs + [v14_dir] |
418 | 451 |
419 base_crunch_dir = os.path.join(temp_dir, 'crunch') | 452 base_crunch_dir = os.path.join(temp_dir, 'crunch') |
420 | 453 |
421 # Crunch image resources. This shrinks png files and is necessary for | 454 # Crunch image resources. This shrinks png files and is necessary for |
422 # 9-patch images to display correctly. 'aapt crunch' accepts only a single | 455 # 9-patch images to display correctly. 'aapt crunch' accepts only a single |
423 # directory at a time and deletes everything in the output directory. | 456 # directory at a time and deletes everything in the output directory. |
424 for idx, input_dir in enumerate(input_resource_dirs): | 457 for idx, input_dir in enumerate(input_resource_dirs): |
425 crunch_dir = os.path.join(base_crunch_dir, str(idx)) | 458 crunch_dir = os.path.join(base_crunch_dir, str(idx)) |
426 build_utils.MakeDirectory(crunch_dir) | 459 build_utils.MakeDirectory(crunch_dir) |
427 zip_resource_dirs.append(crunch_dir) | 460 zip_resource_dirs.append(crunch_dir) |
428 CrunchDirectory(aapt, input_dir, crunch_dir) | 461 CrunchDirectory(aapt, input_dir, crunch_dir) |
429 | 462 |
430 ZipResources(zip_resource_dirs, options.resource_zip_out) | 463 ZipResources(zip_resource_dirs, options.resource_zip_out) |
431 | 464 |
432 if options.all_resources_zip_out: | 465 if options.all_resources_zip_out: |
433 CombineZips([options.resource_zip_out] + dep_zips, | 466 CombineZips([options.resource_zip_out] + dep_zips, |
434 options.all_resources_zip_out) | 467 options.all_resources_zip_out) |
435 | 468 |
436 if options.R_dir: | 469 if options.R_dir: |
437 build_utils.DeleteDirectory(options.R_dir) | 470 build_utils.DeleteDirectory(options.R_dir) |
438 shutil.copytree(gen_dir, options.R_dir) | 471 shutil.copytree(srcjar_dir, options.R_dir) |
439 else: | 472 else: |
440 build_utils.ZipDir(options.srcjar_out, gen_dir) | 473 build_utils.ZipDir(options.srcjar_out, srcjar_dir) |
441 | 474 |
442 if options.r_text_out: | 475 if options.r_text_out: |
443 r_text_path = os.path.join(gen_dir, 'R.txt') | 476 shutil.copyfile(r_txt_path, options.r_text_out) |
444 if os.path.exists(r_text_path): | |
445 shutil.copyfile(r_text_path, options.r_text_out) | |
446 else: | |
447 open(options.r_text_out, 'w').close() | |
448 | 477 |
449 | 478 |
450 def main(args): | 479 def main(args): |
451 args = build_utils.ExpandFileArgs(args) | 480 args = build_utils.ExpandFileArgs(args) |
452 options = _ParseArgs(args) | 481 options = _ParseArgs(args) |
453 | 482 |
454 possible_output_paths = [ | 483 possible_output_paths = [ |
455 options.resource_zip_out, | 484 options.resource_zip_out, |
456 options.all_resources_zip_out, | 485 options.all_resources_zip_out, |
457 options.proguard_file, | 486 options.proguard_file, |
(...skipping 12 matching lines...) Expand all Loading... |
470 options.shared_resources, | 499 options.shared_resources, |
471 options.v14_skip, | 500 options.v14_skip, |
472 ] | 501 ] |
473 | 502 |
474 input_paths = [ | 503 input_paths = [ |
475 options.aapt_path, | 504 options.aapt_path, |
476 options.android_manifest, | 505 options.android_manifest, |
477 options.android_sdk_jar, | 506 options.android_sdk_jar, |
478 ] | 507 ] |
479 input_paths.extend(options.dependencies_res_zips) | 508 input_paths.extend(options.dependencies_res_zips) |
480 input_paths.extend(p for p in options.extra_r_text_files if os.path.exists(p)) | 509 input_paths.extend(options.extra_r_text_files) |
481 | 510 |
482 resource_names = [] | 511 resource_names = [] |
483 for resource_dir in options.resource_dirs: | 512 for resource_dir in options.resource_dirs: |
484 for resource_file in build_utils.FindInDirectory(resource_dir, '*'): | 513 for resource_file in build_utils.FindInDirectory(resource_dir, '*'): |
485 input_paths.append(resource_file) | 514 input_paths.append(resource_file) |
486 resource_names.append(os.path.relpath(resource_file, resource_dir)) | 515 resource_names.append(os.path.relpath(resource_file, resource_dir)) |
487 | 516 |
488 # Resource filenames matter to the output, so add them to strings as well. | 517 # Resource filenames matter to the output, so add them to strings as well. |
489 # This matters if a file is renamed but not changed (http://crbug.com/597126). | 518 # This matters if a file is renamed but not changed (http://crbug.com/597126). |
490 input_strings.extend(sorted(resource_names)) | 519 input_strings.extend(sorted(resource_names)) |
491 | 520 |
492 build_utils.CallAndWriteDepfileIfStale( | 521 build_utils.CallAndWriteDepfileIfStale( |
493 lambda: _OnStaleMd5(options), | 522 lambda: _OnStaleMd5(options), |
494 options, | 523 options, |
495 input_paths=input_paths, | 524 input_paths=input_paths, |
496 input_strings=input_strings, | 525 input_strings=input_strings, |
497 output_paths=output_paths, | 526 output_paths=output_paths, |
498 # TODO(agrieve): Remove R_dir when it's no longer used (used only by GYP). | 527 # TODO(agrieve): Remove R_dir when it's no longer used (used only by GYP). |
499 force=options.R_dir) | 528 force=options.R_dir) |
500 | 529 |
501 | 530 |
502 if __name__ == '__main__': | 531 if __name__ == '__main__': |
503 main(sys.argv[1:]) | 532 main(sys.argv[1:]) |
OLD | NEW |