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

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

Issue 2632463004: Android: Hook up aapt's main dex proguard rules (Closed)
Patch Set: add as input Created 3 years, 11 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 | « no previous file | 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) 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).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 help='Path to srcjar to contain generated R.java.') 75 help='Path to srcjar to contain generated R.java.')
76 parser.add_option('--r-text-out', 76 parser.add_option('--r-text-out',
77 help='Path to store the generated R.txt file.') 77 help='Path to store the generated R.txt file.')
78 parser.add_option('--r-text-in', 78 parser.add_option('--r-text-in',
79 help='Path to pre-existing R.txt for these resources. ' 79 help='Path to pre-existing R.txt for these resources. '
80 'Resource names from it will be used to generate R.java ' 80 'Resource names from it will be used to generate R.java '
81 'instead of aapt-generated R.txt.') 81 'instead of aapt-generated R.txt.')
82 82
83 parser.add_option('--proguard-file', 83 parser.add_option('--proguard-file',
84 help='Path to proguard.txt generated file') 84 help='Path to proguard.txt generated file')
85 parser.add_option('--proguard-file-main-dex',
86 help='Path to proguard.txt generated file for main dex')
85 87
86 parser.add_option( 88 parser.add_option(
87 '--v14-skip', 89 '--v14-skip',
88 action="store_true", 90 action="store_true",
89 help='Do not generate nor verify v14 resources') 91 help='Do not generate nor verify v14 resources')
90 92
91 parser.add_option( 93 parser.add_option(
92 '--extra-res-packages', 94 '--extra-res-packages',
93 help='Additional package names to generate R.java files for') 95 help='Additional package names to generate R.java files for')
94 parser.add_option( 96 parser.add_option(
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 # to symbols within dependencies to resolve. However, it has the side-effect 442 # to symbols within dependencies to resolve. However, it has the side-effect
441 # that all Java symbols from dependencies are copied into the new R.java. 443 # that all Java symbols from dependencies are copied into the new R.java.
442 # E.g.: It enables an arguably incorrect usage of 444 # E.g.: It enables an arguably incorrect usage of
443 # "mypackage.R.id.lib_symbol" where "libpackage.R.id.lib_symbol" would be 445 # "mypackage.R.id.lib_symbol" where "libpackage.R.id.lib_symbol" would be
444 # more correct. This is just how Android works. 446 # more correct. This is just how Android works.
445 for d in dep_subdirs: 447 for d in dep_subdirs:
446 package_command += ['-S', d] 448 package_command += ['-S', d]
447 449
448 if options.proguard_file: 450 if options.proguard_file:
449 package_command += ['-G', options.proguard_file] 451 package_command += ['-G', options.proguard_file]
452 if options.proguard_file_main_dex:
453 package_command += ['-D', options.proguard_file_main_dex]
450 build_utils.CheckOutput(package_command, print_stderr=False) 454 build_utils.CheckOutput(package_command, print_stderr=False)
451 455
452 # When an empty res/ directory is passed, aapt does not write an R.txt. 456 # When an empty res/ directory is passed, aapt does not write an R.txt.
453 if not os.path.exists(r_txt_path): 457 if not os.path.exists(r_txt_path):
454 build_utils.Touch(r_txt_path) 458 build_utils.Touch(r_txt_path)
455 459
456 if not options.include_all_resources: 460 if not options.include_all_resources:
457 # --include-all-resources can only be specified for generating final R 461 # --include-all-resources can only be specified for generating final R
458 # classes for APK. It makes no sense for APK to have pre-generated R.txt 462 # classes for APK. It makes no sense for APK to have pre-generated R.txt
459 # though, because aapt-generated already lists all available resources. 463 # though, because aapt-generated already lists all available resources.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 518
515 519
516 def main(args): 520 def main(args):
517 args = build_utils.ExpandFileArgs(args) 521 args = build_utils.ExpandFileArgs(args)
518 options = _ParseArgs(args) 522 options = _ParseArgs(args)
519 523
520 possible_output_paths = [ 524 possible_output_paths = [
521 options.resource_zip_out, 525 options.resource_zip_out,
522 options.all_resources_zip_out, 526 options.all_resources_zip_out,
523 options.proguard_file, 527 options.proguard_file,
528 options.proguard_file_main_dex,
524 options.r_text_out, 529 options.r_text_out,
525 options.srcjar_out, 530 options.srcjar_out,
526 ] 531 ]
527 output_paths = [x for x in possible_output_paths if x] 532 output_paths = [x for x in possible_output_paths if x]
528 533
529 # List python deps in input_strings rather than input_paths since the contents 534 # List python deps in input_strings rather than input_paths since the contents
530 # of them does not change what gets written to the depsfile. 535 # of them does not change what gets written to the depsfile.
531 input_strings = options.extra_res_packages + [ 536 input_strings = options.extra_res_packages + [
532 options.app_as_shared_lib, 537 options.app_as_shared_lib,
533 options.custom_package, 538 options.custom_package,
(...skipping 26 matching lines...) Expand all
560 options, 565 options,
561 input_paths=input_paths, 566 input_paths=input_paths,
562 input_strings=input_strings, 567 input_strings=input_strings,
563 output_paths=output_paths, 568 output_paths=output_paths,
564 # TODO(agrieve): Remove R_dir when it's no longer used (used only by GYP). 569 # TODO(agrieve): Remove R_dir when it's no longer used (used only by GYP).
565 force=options.R_dir) 570 force=options.R_dir)
566 571
567 572
568 if __name__ == '__main__': 573 if __name__ == '__main__':
569 main(sys.argv[1:]) 574 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698