OLD | NEW |
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 parser.add_option('--jar-path', help='Path to target\'s jar output.') | 246 parser.add_option('--jar-path', help='Path to target\'s jar output.') |
247 parser.add_option('--java-sources-file', help='Path to .sources file') | 247 parser.add_option('--java-sources-file', help='Path to .sources file') |
248 parser.add_option('--bundled-srcjars', | 248 parser.add_option('--bundled-srcjars', |
249 help='GYP-list of .srcjars that have been included in this java_library.') | 249 help='GYP-list of .srcjars that have been included in this java_library.') |
250 parser.add_option('--supports-android', action='store_true', | 250 parser.add_option('--supports-android', action='store_true', |
251 help='Whether this library supports running on the Android platform.') | 251 help='Whether this library supports running on the Android platform.') |
252 parser.add_option('--requires-android', action='store_true', | 252 parser.add_option('--requires-android', action='store_true', |
253 help='Whether this library requires running on the Android platform.') | 253 help='Whether this library requires running on the Android platform.') |
254 parser.add_option('--bypass-platform-checks', action='store_true', | 254 parser.add_option('--bypass-platform-checks', action='store_true', |
255 help='Bypass checks for support/require Android platform.') | 255 help='Bypass checks for support/require Android platform.') |
| 256 parser.add_option('--extra-classpath-jars', |
| 257 help='GYP-list of .jar files to include on the classpath when compiling, ' |
| 258 'but not to include in the final binary.') |
256 | 259 |
257 # android library options | 260 # android library options |
258 parser.add_option('--dex-path', help='Path to target\'s dex output.') | 261 parser.add_option('--dex-path', help='Path to target\'s dex output.') |
259 | 262 |
260 # native library options | 263 # native library options |
261 parser.add_option('--shared-libraries-runtime-deps', | 264 parser.add_option('--shared-libraries-runtime-deps', |
262 help='Path to file containing runtime deps for shared ' | 265 help='Path to file containing runtime deps for shared ' |
263 'libraries.') | 266 'libraries.') |
264 | 267 |
265 # apk options | 268 # apk options |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 config['resources']['extra_r_text_files'] = [ | 517 config['resources']['extra_r_text_files'] = [ |
515 c['r_text'] for c in all_resources_deps if 'r_text' in c] | 518 c['r_text'] for c in all_resources_deps if 'r_text' in c] |
516 | 519 |
517 if options.type in ['android_apk', 'deps_dex']: | 520 if options.type in ['android_apk', 'deps_dex']: |
518 deps_dex_files = [c['dex_path'] for c in all_library_deps] | 521 deps_dex_files = [c['dex_path'] for c in all_library_deps] |
519 | 522 |
520 if options.type in ('java_binary', 'java_library', 'android_apk'): | 523 if options.type in ('java_binary', 'java_library', 'android_apk'): |
521 javac_classpath = [c['jar_path'] for c in direct_library_deps] | 524 javac_classpath = [c['jar_path'] for c in direct_library_deps] |
522 java_full_classpath = [c['jar_path'] for c in all_library_deps] | 525 java_full_classpath = [c['jar_path'] for c in all_library_deps] |
523 | 526 |
| 527 if options.extra_classpath_jars: |
| 528 extra_jars = build_utils.ParseGypList(options.extra_classpath_jars) |
| 529 deps_info['extra_classpath_jars'] = extra_jars |
| 530 javac_classpath += extra_jars |
| 531 |
524 # The java code for an instrumentation test apk is assembled differently for | 532 # The java code for an instrumentation test apk is assembled differently for |
525 # ProGuard vs. non-ProGuard. | 533 # ProGuard vs. non-ProGuard. |
526 # | 534 # |
527 # Without ProGuard: Each library's jar is dexed separately and then combined | 535 # Without ProGuard: Each library's jar is dexed separately and then combined |
528 # into a single classes.dex. A test apk will include all dex files not already | 536 # into a single classes.dex. A test apk will include all dex files not already |
529 # present in the apk-under-test. At runtime all test code lives in the test | 537 # present in the apk-under-test. At runtime all test code lives in the test |
530 # apk, and the program code lives in the apk-under-test. | 538 # apk, and the program code lives in the apk-under-test. |
531 # | 539 # |
532 # With ProGuard: Each library's .jar file is fed into ProGuard, which outputs | 540 # With ProGuard: Each library's .jar file is fed into ProGuard, which outputs |
533 # a single .jar, which is then dexed into a classes.dex. A test apk includes | 541 # a single .jar, which is then dexed into a classes.dex. A test apk includes |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] | 573 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] |
566 deps_dex_files = [ | 574 deps_dex_files = [ |
567 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] | 575 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] |
568 | 576 |
569 if options.type == 'android_apk': | 577 if options.type == 'android_apk': |
570 deps_info['proguard_enabled'] = options.proguard_enabled | 578 deps_info['proguard_enabled'] = options.proguard_enabled |
571 deps_info['proguard_info'] = options.proguard_info | 579 deps_info['proguard_info'] = options.proguard_info |
572 config['proguard'] = {} | 580 config['proguard'] = {} |
573 proguard_config = config['proguard'] | 581 proguard_config = config['proguard'] |
574 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath | 582 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath |
| 583 extra_jars = set() |
| 584 for c in all_library_deps: |
| 585 extra_jars.update(c.get('extra_classpath_jars', ())) |
| 586 proguard_config['lib_paths'] = list(extra_jars) |
575 | 587 |
576 # Dependencies for the final dex file of an apk or a 'deps_dex'. | 588 # Dependencies for the final dex file of an apk or a 'deps_dex'. |
577 if options.type in ['android_apk', 'deps_dex']: | 589 if options.type in ['android_apk', 'deps_dex']: |
578 config['final_dex'] = {} | 590 config['final_dex'] = {} |
579 dex_config = config['final_dex'] | 591 dex_config = config['final_dex'] |
580 dex_config['dependency_dex_files'] = deps_dex_files | 592 dex_config['dependency_dex_files'] = deps_dex_files |
581 | 593 |
582 if options.type in ('java_binary', 'java_library', 'android_apk'): | 594 if options.type in ('java_binary', 'java_library', 'android_apk'): |
583 config['javac']['classpath'] = javac_classpath | 595 config['javac']['classpath'] = javac_classpath |
584 config['javac']['interface_classpath'] = [ | 596 config['javac']['interface_classpath'] = [ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 _MergeAssets(deps.All('android_assets'))) | 633 _MergeAssets(deps.All('android_assets'))) |
622 | 634 |
623 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 635 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
624 | 636 |
625 if options.depfile: | 637 if options.depfile: |
626 build_utils.WriteDepfile(options.depfile, all_inputs) | 638 build_utils.WriteDepfile(options.depfile, all_inputs) |
627 | 639 |
628 | 640 |
629 if __name__ == '__main__': | 641 if __name__ == '__main__': |
630 sys.exit(main(sys.argv[1:])) | 642 sys.exit(main(sys.argv[1:])) |
OLD | NEW |