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

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

Issue 2295363002: 🔔 Allow android_* targets to specify proguard flags for apks (Closed)
Patch Set: Created 4 years, 3 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/gyp/proguard.py ('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 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 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 """Writes a build_config file. 7 """Writes a build_config file.
8 8
9 The build_config file for a target is a json file containing information about 9 The build_config file for a target is a json file containing information about
10 how to build that target based on the target's dependencies. This includes 10 how to build that target based on the target's dependencies. This includes
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 help="Path to the target's incremental apk output.") 271 help="Path to the target's incremental apk output.")
272 parser.add_option('--incremental-install-script-path', 272 parser.add_option('--incremental-install-script-path',
273 help="Path to the target's generated incremental install " 273 help="Path to the target's generated incremental install "
274 "script.") 274 "script.")
275 275
276 parser.add_option('--tested-apk-config', 276 parser.add_option('--tested-apk-config',
277 help='Path to the build config of the tested apk (for an instrumentation ' 277 help='Path to the build config of the tested apk (for an instrumentation '
278 'test apk).') 278 'test apk).')
279 parser.add_option('--proguard-enabled', action='store_true', 279 parser.add_option('--proguard-enabled', action='store_true',
280 help='Whether proguard is enabled for this apk.') 280 help='Whether proguard is enabled for this apk.')
281 parser.add_option('--proguard-configs',
282 help='GYP-list of proguard flag files to use in final apk.')
Ian Wen 2016/09/01 01:31:55 Q: do we have plans to rename GYP-list to GN-list
agrieve 2016/09/01 14:07:08 We definitely should :)
281 parser.add_option('--proguard-info', 283 parser.add_option('--proguard-info',
282 help='Path to the proguard .info output for this apk.') 284 help='Path to the proguard .info output for this apk.')
283 parser.add_option('--has-alternative-locale-resource', action='store_true', 285 parser.add_option('--has-alternative-locale-resource', action='store_true',
284 help='Whether there is alternative-locale-resource in direct deps') 286 help='Whether there is alternative-locale-resource in direct deps')
285 parser.add_option('--fail', 287 parser.add_option('--fail',
286 help='GYP-list of error message lines to fail with.') 288 help='GYP-list of error message lines to fail with.')
287 289
288 options, args = parser.parse_args(argv) 290 options, args = parser.parse_args(argv)
289 291
290 if args: 292 if args:
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 569
568 # Exclude dex files from the test apk that exist within the apk under test. 570 # Exclude dex files from the test apk that exist within the apk under test.
569 # TODO(agrieve): When proguard is enabled, this filtering logic happens 571 # TODO(agrieve): When proguard is enabled, this filtering logic happens
570 # within proguard_util.py. Move the logic for the proguard case into 572 # within proguard_util.py. Move the logic for the proguard case into
571 # here as well. 573 # here as well.
572 tested_apk_library_deps = tested_apk_deps.All('java_library') 574 tested_apk_library_deps = tested_apk_deps.All('java_library')
573 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] 575 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
574 deps_dex_files = [ 576 deps_dex_files = [
575 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] 577 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
576 578
579 if options.proguard_configs:
580 assert options.type == 'java_library'
581 deps_info['proguard_configs'] = (
582 build_utils.ParseGnList(options.proguard_configs))
583
577 if options.type == 'android_apk': 584 if options.type == 'android_apk':
578 deps_info['proguard_enabled'] = options.proguard_enabled 585 deps_info['proguard_enabled'] = options.proguard_enabled
579 deps_info['proguard_info'] = options.proguard_info 586 deps_info['proguard_info'] = options.proguard_info
580 config['proguard'] = {} 587 config['proguard'] = {}
581 proguard_config = config['proguard'] 588 proguard_config = config['proguard']
582 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath 589 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath
583 extra_jars = set() 590 extra_jars = set()
591 lib_configs = set()
584 for c in all_library_deps: 592 for c in all_library_deps:
585 extra_jars.update(c.get('extra_classpath_jars', ())) 593 extra_jars.update(c.get('extra_classpath_jars', ()))
594 lib_configs.update(c.get('proguard_configs', ()))
586 proguard_config['lib_paths'] = list(extra_jars) 595 proguard_config['lib_paths'] = list(extra_jars)
596 proguard_config['lib_configs'] = list(lib_configs)
587 597
588 # Dependencies for the final dex file of an apk or a 'deps_dex'. 598 # Dependencies for the final dex file of an apk or a 'deps_dex'.
589 if options.type in ['android_apk', 'deps_dex']: 599 if options.type in ['android_apk', 'deps_dex']:
590 config['final_dex'] = {} 600 config['final_dex'] = {}
591 dex_config = config['final_dex'] 601 dex_config = config['final_dex']
592 dex_config['dependency_dex_files'] = deps_dex_files 602 dex_config['dependency_dex_files'] = deps_dex_files
593 603
594 if options.type in ('java_binary', 'java_library', 'android_apk'): 604 if options.type in ('java_binary', 'java_library', 'android_apk'):
595 config['javac']['classpath'] = javac_classpath 605 config['javac']['classpath'] = javac_classpath
596 config['javac']['interface_classpath'] = [ 606 config['javac']['interface_classpath'] = [
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 _MergeAssets(deps.All('android_assets'))) 643 _MergeAssets(deps.All('android_assets')))
634 644
635 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 645 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
636 646
637 if options.depfile: 647 if options.depfile:
638 build_utils.WriteDepfile(options.depfile, all_inputs) 648 build_utils.WriteDepfile(options.depfile, all_inputs)
639 649
640 650
641 if __name__ == '__main__': 651 if __name__ == '__main__':
642 sys.exit(main(sys.argv[1:])) 652 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/proguard.py ('k') | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698