Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 import filecmp | 5 import filecmp | 
| 6 import gyp.common | 6 import gyp.common | 
| 7 import gyp.xcodeproj_file | 7 import gyp.xcodeproj_file | 
| 8 import errno | 8 import errno | 
| 9 import os | 9 import os | 
| 10 import sys | 10 import sys | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 ] | 66 ] | 
| 67 | 67 | 
| 68 # The Xcode-specific keys that exist on targets and aren't moved down to | 68 # The Xcode-specific keys that exist on targets and aren't moved down to | 
| 69 # configurations. | 69 # configurations. | 
| 70 generator_additional_non_configuration_keys = [ | 70 generator_additional_non_configuration_keys = [ | 
| 71 'mac_bundle', | 71 'mac_bundle', | 
| 72 'mac_bundle_resources', | 72 'mac_bundle_resources', | 
| 73 'mac_framework_headers', | 73 'mac_framework_headers', | 
| 74 'mac_framework_private_headers', | 74 'mac_framework_private_headers', | 
| 75 'xcode_create_dependents_test_runner', | 75 'xcode_create_dependents_test_runner', | 
| 76 'xctest_bundle', | |
| 77 'xctest_host', | |
| 76 ] | 78 ] | 
| 77 | 79 | 
| 78 # We want to let any rules apply to files that are resources also. | 80 # We want to let any rules apply to files that are resources also. | 
| 79 generator_extra_sources_for_rules = [ | 81 generator_extra_sources_for_rules = [ | 
| 80 'mac_bundle_resources', | 82 'mac_bundle_resources', | 
| 81 'mac_framework_headers', | 83 'mac_framework_headers', | 
| 82 'mac_framework_private_headers', | 84 'mac_framework_private_headers', | 
| 83 ] | 85 ] | 
| 84 | 86 | 
| 85 # Xcode's standard set of library directories, which don't need to be duplicated | 87 # Xcode's standard set of library directories, which don't need to be duplicated | 
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 # loadable_modules not in a mac_bundle are mapped to | 637 # loadable_modules not in a mac_bundle are mapped to | 
| 636 # com.googlecode.gyp.xcode.bundle, a pseudo-type that xcode.py interprets | 638 # com.googlecode.gyp.xcode.bundle, a pseudo-type that xcode.py interprets | 
| 637 # to create a single-file mh_bundle. | 639 # to create a single-file mh_bundle. | 
| 638 _types = { | 640 _types = { | 
| 639 'executable': 'com.apple.product-type.tool', | 641 'executable': 'com.apple.product-type.tool', | 
| 640 'loadable_module': 'com.googlecode.gyp.xcode.bundle', | 642 'loadable_module': 'com.googlecode.gyp.xcode.bundle', | 
| 641 'shared_library': 'com.apple.product-type.library.dynamic', | 643 'shared_library': 'com.apple.product-type.library.dynamic', | 
| 642 'static_library': 'com.apple.product-type.library.static', | 644 'static_library': 'com.apple.product-type.library.static', | 
| 643 'executable+bundle': 'com.apple.product-type.application', | 645 'executable+bundle': 'com.apple.product-type.application', | 
| 644 'loadable_module+bundle': 'com.apple.product-type.bundle', | 646 'loadable_module+bundle': 'com.apple.product-type.bundle', | 
| 647 'loadable_module+xctest': 'com.apple.product-type.bundle.unit-test', | |
| 645 'shared_library+bundle': 'com.apple.product-type.framework', | 648 'shared_library+bundle': 'com.apple.product-type.framework', | 
| 646 } | 649 } | 
| 647 | 650 | 
| 648 target_properties = { | 651 target_properties = { | 
| 649 'buildConfigurationList': xccl, | 652 'buildConfigurationList': xccl, | 
| 650 'name': target_name, | 653 'name': target_name, | 
| 651 } | 654 } | 
| 652 | 655 | 
| 653 type = spec['type'] | 656 type = spec['type'] | 
| 654 is_bundle = int(spec.get('mac_bundle', 0)) | 657 is_bundle = int(spec.get('mac_bundle', 0)) | 
| 658 is_xctest = int(spec.get('xctest_bundle', 0)) | |
| 655 if type != 'none': | 659 if type != 'none': | 
| 656 type_bundle_key = type | 660 type_bundle_key = type | 
| 657 if is_bundle: | 661 if is_bundle: | 
| 658 type_bundle_key += '+bundle' | 662 type_bundle_key += '+bundle' | 
| 663 if is_xctest: | |
| 664 type_bundle_key += '+xctest' | |
| 
 
Mark Mentovai
2013/10/30 16:40:27
This code snippet seems to say that loadable_modul
 
jonwall
2013/10/30 19:07:38
Done.
 
 | |
| 665 assert type == 'loadable_module', ( | |
| 666 'xctest_bundle targets must have type loadable_module (target %s)' % | |
| 667 target_name) | |
| 668 | |
| 659 xctarget_type = gyp.xcodeproj_file.PBXNativeTarget | 669 xctarget_type = gyp.xcodeproj_file.PBXNativeTarget | 
| 660 try: | 670 try: | 
| 661 target_properties['productType'] = _types[type_bundle_key] | 671 target_properties['productType'] = _types[type_bundle_key] | 
| 662 except KeyError, e: | 672 except KeyError, e: | 
| 663 gyp.common.ExceptionAppend(e, "-- unknown product type while " | 673 gyp.common.ExceptionAppend(e, "-- unknown product type while " | 
| 664 "writing target %s" % target_name) | 674 "writing target %s" % target_name) | 
| 665 raise | 675 raise | 
| 666 else: | 676 else: | 
| 667 xctarget_type = gyp.xcodeproj_file.PBXAggregateTarget | 677 xctarget_type = gyp.xcodeproj_file.PBXAggregateTarget | 
| 668 assert not is_bundle, ( | 678 assert not is_bundle, ( | 
| 669 'mac_bundle targets cannot have type none (target "%s")' % | 679 'mac_bundle targets cannot have type none (target "%s")' % | 
| 670 target_name) | 680 target_name) | 
| 681 assert not is_xctest, ( | |
| 682 'xctest_bundle targets cannot have type none (target "%s")' % | |
| 683 target_name) | |
| 671 | 684 | 
| 672 target_product_name = spec.get('product_name') | 685 target_product_name = spec.get('product_name') | 
| 673 if target_product_name is not None: | 686 if target_product_name is not None: | 
| 674 target_properties['productName'] = target_product_name | 687 target_properties['productName'] = target_product_name | 
| 675 | 688 | 
| 676 xct = xctarget_type(target_properties, parent=pbxp, | 689 xct = xctarget_type(target_properties, parent=pbxp, | 
| 677 force_outdir=spec.get('product_dir'), | 690 force_outdir=spec.get('product_dir'), | 
| 678 force_prefix=spec.get('product_prefix'), | 691 force_prefix=spec.get('product_prefix'), | 
| 679 force_extension=spec.get('product_extension')) | 692 force_extension=spec.get('product_extension')) | 
| 680 pbxp.AppendProperty('targets', xct) | 693 pbxp.AppendProperty('targets', xct) | 
| (...skipping 21 matching lines...) Expand all Loading... | |
| 702 target_product_name + ' Support' | 715 target_product_name + ' Support' | 
| 703 support_xct = \ | 716 support_xct = \ | 
| 704 gyp.xcodeproj_file.PBXAggregateTarget(support_target_properties, | 717 gyp.xcodeproj_file.PBXAggregateTarget(support_target_properties, | 
| 705 parent=pbxp) | 718 parent=pbxp) | 
| 706 pbxp.AppendProperty('targets', support_xct) | 719 pbxp.AppendProperty('targets', support_xct) | 
| 707 xct.AddDependency(support_xct) | 720 xct.AddDependency(support_xct) | 
| 708 # Hang the support target off the main target so it can be tested/found | 721 # Hang the support target off the main target so it can be tested/found | 
| 709 # by the generator during Finalize. | 722 # by the generator during Finalize. | 
| 710 xct.support_target = support_xct | 723 xct.support_target = support_xct | 
| 711 | 724 | 
| 725 if is_xctest and 'xctest_host' in spec: | |
| 726 test_host = spec['xctest_host'] | |
| 727 test_host_qualified_target = gyp.common.QualifiedTarget( | |
| 728 build_file, test_host, toolset) | |
| 729 assert test_host_qualified_target in spec['dependencies'], ( | |
| 730 'xctest_host (%s) must be listed as a dependency. (target %s)' % | |
| 
 
Mark Mentovai
2013/10/30 16:40:27
Why? Can’t it be an indirect dependency?
 
jonwall
2013/10/30 19:07:38
It looks like spec['dependencies'] includes indire
 
Mark Mentovai
2013/10/30 19:57:31
jonwall wrote:
 
jonwall
2013/10/30 21:04:57
Yes.
 
 | |
| 731 (test_host, target_name)) | |
| 732 test_host_target = target_dicts[test_host_qualified_target] | |
| 733 assert test_host_target['type'] == 'executable', ( | |
| 734 'xctest_host must have type executable (target %s)' % target_name) | |
| 735 # Prune any duplicated dependencies. | |
| 
 
Mark Mentovai
2013/10/30 16:40:27
Why?
 
jonwall
2013/10/30 19:07:38
If you comment out this line, you'll see the test
 
Mark Mentovai
2013/10/30 19:57:31
This sounds like a generic problem with making any
 
jonwall
2013/10/30 21:04:57
Okay. It looks like I can get this to work by clon
 
 | |
| 736 spec['dependencies'] = [dep for dep in spec['dependencies'] | |
| 737 if dep not in test_host_target['dependencies']] | |
| 738 | |
| 712 prebuild_index = 0 | 739 prebuild_index = 0 | 
| 713 | 740 | 
| 714 # Add custom shell script phases for "actions" sections. | 741 # Add custom shell script phases for "actions" sections. | 
| 715 for action in spec_actions: | 742 for action in spec_actions: | 
| 716 # There's no need to write anything into the script to ensure that the | 743 # There's no need to write anything into the script to ensure that the | 
| 717 # output directories already exist, because Xcode will look at the | 744 # output directories already exist, because Xcode will look at the | 
| 718 # declared outputs and automatically ensure that they exist for us. | 745 # declared outputs and automatically ensure that they exist for us. | 
| 719 | 746 | 
| 720 # Do we have a message to print when this action runs? | 747 # Do we have a message to print when this action runs? | 
| 721 message = action.get('message') | 748 message = action.get('message') | 
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 | 1230 | 
| 1204 for build_file in build_files: | 1231 for build_file in build_files: | 
| 1205 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) | 1232 xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) | 
| 1206 | 1233 | 
| 1207 for build_file in build_files: | 1234 for build_file in build_files: | 
| 1208 xcode_projects[build_file].Finalize2(xcode_targets, | 1235 xcode_projects[build_file].Finalize2(xcode_targets, | 
| 1209 xcode_target_to_target_dict) | 1236 xcode_target_to_target_dict) | 
| 1210 | 1237 | 
| 1211 for build_file in build_files: | 1238 for build_file in build_files: | 
| 1212 xcode_projects[build_file].Write() | 1239 xcode_projects[build_file].Write() | 
| OLD | NEW |