| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Generates an Android Studio project from a GN target.""" | 6 """Generates an Android Studio project from a GN target.""" |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import codecs | 9 import codecs |
| 10 import glob | 10 import glob |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 help='Path to the root build directory.') | 626 help='Path to the root build directory.') |
| 627 parser.add_argument('-v', | 627 parser.add_argument('-v', |
| 628 '--verbose', | 628 '--verbose', |
| 629 dest='verbose_count', | 629 dest='verbose_count', |
| 630 default=0, | 630 default=0, |
| 631 action='count', | 631 action='count', |
| 632 help='Verbose level') | 632 help='Verbose level') |
| 633 parser.add_argument('--target', | 633 parser.add_argument('--target', |
| 634 dest='targets', | 634 dest='targets', |
| 635 action='append', | 635 action='append', |
| 636 help='GN target to generate project for. ' | 636 help='GN target to generate project for. Replaces set of ' |
| 637 'May be repeated.') | 637 'default targets. May be repeated.') |
| 638 parser.add_argument('--extra-target', |
| 639 dest='extra_targets', |
| 640 action='append', |
| 641 help='GN target to generate project for, in addition to ' |
| 642 'the default ones. May be repeated.') |
| 638 parser.add_argument('--project-dir', | 643 parser.add_argument('--project-dir', |
| 639 help='Root of the output project.', | 644 help='Root of the output project.', |
| 640 default=os.path.join('$CHROMIUM_OUTPUT_DIR', 'gradle')) | 645 default=os.path.join('$CHROMIUM_OUTPUT_DIR', 'gradle')) |
| 641 parser.add_argument('--all', | 646 parser.add_argument('--all', |
| 642 action='store_true', | 647 action='store_true', |
| 643 help='Generate all java targets (slows down IDE)') | 648 help='Generate all java targets (slows down IDE)') |
| 644 parser.add_argument('--use-gradle-process-resources', | 649 parser.add_argument('--use-gradle-process-resources', |
| 645 action='store_true', | 650 action='store_true', |
| 646 help='Have gradle generate R.java rather than ninja') | 651 help='Have gradle generate R.java rather than ninja') |
| 647 parser.add_argument('--split-projects', | 652 parser.add_argument('--split-projects', |
| (...skipping 21 matching lines...) Expand all Loading... |
| 669 args.use_gradle_process_resources, jinja_processor, args.split_projects) | 674 args.use_gradle_process_resources, jinja_processor, args.split_projects) |
| 670 logging.warning('Creating project at: %s', generator.project_dir) | 675 logging.warning('Creating project at: %s', generator.project_dir) |
| 671 | 676 |
| 672 if args.all: | 677 if args.all: |
| 673 # Run GN gen if necessary (faster than running "gn gen" in the no-op case). | 678 # Run GN gen if necessary (faster than running "gn gen" in the no-op case). |
| 674 _RunNinja(constants.GetOutDirectory(), ['build.ninja']) | 679 _RunNinja(constants.GetOutDirectory(), ['build.ninja']) |
| 675 # Query ninja for all __build_config targets. | 680 # Query ninja for all __build_config targets. |
| 676 targets = _QueryForAllGnTargets(output_dir) | 681 targets = _QueryForAllGnTargets(output_dir) |
| 677 else: | 682 else: |
| 678 targets = args.targets or _DEFAULT_TARGETS | 683 targets = args.targets or _DEFAULT_TARGETS |
| 684 if args.extra_targets: |
| 685 targets.extend(args.extra_targets) |
| 679 targets = [re.sub(r'_test_apk$', '_test_apk__apk', t) for t in targets] | 686 targets = [re.sub(r'_test_apk$', '_test_apk__apk', t) for t in targets] |
| 680 # TODO(wnwen): Utilize Gradle's test constructs for our junit tests? | 687 # TODO(wnwen): Utilize Gradle's test constructs for our junit tests? |
| 681 targets = [re.sub(r'_junit_tests$', '_junit_tests__java_binary', t) | 688 targets = [re.sub(r'_junit_tests$', '_junit_tests__java_binary', t) |
| 682 for t in targets] | 689 for t in targets] |
| 683 | 690 |
| 684 main_entries = [_ProjectEntry.FromGnTarget(t) for t in targets] | 691 main_entries = [_ProjectEntry.FromGnTarget(t) for t in targets] |
| 685 | 692 |
| 686 logging.warning('Building .build_config files...') | 693 logging.warning('Building .build_config files...') |
| 687 _RunNinja(output_dir, [e.NinjaBuildConfigTarget() for e in main_entries]) | 694 _RunNinja(output_dir, [e.NinjaBuildConfigTarget() for e in main_entries]) |
| 688 | 695 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 _ExtractZips(generator.project_dir, zip_tuples) | 745 _ExtractZips(generator.project_dir, zip_tuples) |
| 739 | 746 |
| 740 logging.warning('Project created! (%d subprojects)', len(project_entries)) | 747 logging.warning('Project created! (%d subprojects)', len(project_entries)) |
| 741 logging.warning('Generated projects work best with Android Studio 2.2') | 748 logging.warning('Generated projects work best with Android Studio 2.2') |
| 742 logging.warning('For more tips: https://chromium.googlesource.com/chromium' | 749 logging.warning('For more tips: https://chromium.googlesource.com/chromium' |
| 743 '/src.git/+/master/docs/android_studio.md') | 750 '/src.git/+/master/docs/android_studio.md') |
| 744 | 751 |
| 745 | 752 |
| 746 if __name__ == '__main__': | 753 if __name__ == '__main__': |
| 747 main() | 754 main() |
| OLD | NEW |