OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/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 """Convert GN Xcode projects to platform and configuration independent targets. | 6 """Convert GN Xcode projects to platform and configuration independent targets. |
7 | 7 |
8 GN generates Xcode projects that build one configuration only. However, typical | 8 GN generates Xcode projects that build one configuration only. However, typical |
9 iOS development involves using the Xcode IDE to toggle the platform and | 9 iOS development involves using the Xcode IDE to toggle the platform and |
10 configuration. This script replaces the 'gn' configuration with 'Debug', | 10 configuration. This script replaces the 'gn' configuration with 'Debug', |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 # Configure BUNDLE_LOADER and TEST_HOST for xctest targets (if not yet | 115 # Configure BUNDLE_LOADER and TEST_HOST for xctest targets (if not yet |
116 # configured by gn). Old convention was to name the test dynamic module | 116 # configured by gn). Old convention was to name the test dynamic module |
117 # "foo" and the host "foo_host" while the new convention is to name the | 117 # "foo" and the host "foo_host" while the new convention is to name the |
118 # test "foo_module" and the host "foo". Decide which convention to use | 118 # test "foo_module" and the host "foo". Decide which convention to use |
119 # by inspecting the target name. | 119 # by inspecting the target name. |
120 if isa == 'PBXNativeTarget' and value['productType'] == XCTEST_PRODUCT_TYPE: | 120 if isa == 'PBXNativeTarget' and value['productType'] == XCTEST_PRODUCT_TYPE: |
121 configuration_list = project.objects[value['buildConfigurationList']] | 121 configuration_list = project.objects[value['buildConfigurationList']] |
122 for config_name in configuration_list['buildConfigurations']: | 122 for config_name in configuration_list['buildConfigurations']: |
123 config = project.objects[config_name] | 123 config = project.objects[config_name] |
124 if not config['buildSettings'].get('BUNDLE_LOADER'): | 124 if not config['buildSettings'].get('BUNDLE_LOADER'): |
125 if value['name'].endswith('_module'): | 125 assert value['name'].endswith('_module') |
126 host_name = value['name'][:-len('_module')] | 126 host_name = value['name'][:-len('_module')] |
127 else: | |
128 # TODO(crbug.com/662404): remove once the targets have been renamed | |
129 # to use the new naming convention. | |
130 host_name = value['name'] + '_host' | |
131 config['buildSettings']['BUNDLE_LOADER'] = '$(TEST_HOST)' | 127 config['buildSettings']['BUNDLE_LOADER'] = '$(TEST_HOST)' |
132 config['buildSettings']['TEST_HOST'] = \ | 128 config['buildSettings']['TEST_HOST'] = \ |
133 '${BUILT_PRODUCTS_DIR}/%s.app/%s' % (host_name, host_name) | 129 '${BUILT_PRODUCTS_DIR}/%s.app/%s' % (host_name, host_name) |
134 | 130 |
135 # Add new configuration, using the first one as default. | 131 # Add new configuration, using the first one as default. |
136 if isa == 'XCConfigurationList': | 132 if isa == 'XCConfigurationList': |
137 value['defaultConfigurationName'] = configurations[0] | 133 value['defaultConfigurationName'] = configurations[0] |
138 objects_to_remove.extend(value['buildConfigurations']) | 134 objects_to_remove.extend(value['buildConfigurations']) |
139 | 135 |
140 build_config_template = project.objects[value['buildConfigurations'][0]] | 136 build_config_template = project.objects[value['buildConfigurations'][0]] |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if not args.configurations: | 209 if not args.configurations: |
214 sys.stderr.write('At least one configuration required, see --add-config.\n') | 210 sys.stderr.write('At least one configuration required, see --add-config.\n') |
215 return 1 | 211 return 1 |
216 | 212 |
217 ConvertGnXcodeProject(args.input, args.output, args.configurations) | 213 ConvertGnXcodeProject(args.input, args.output, args.configurations) |
218 | 214 |
219 if __name__ == '__main__': | 215 if __name__ == '__main__': |
220 sys.exit(Main(sys.argv[1:])) | 216 sys.exit(Main(sys.argv[1:])) |
221 | 217 |
222 | 218 |
OLD | NEW |