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: ios/build/tools/convert_gn_xcodeproj.py

Issue 2473103006: Rename XCTests test main target and output. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 | « ios/build/bots/scripts/test_runner.py ('k') | ios/web/shell/test/BUILD.gn » ('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/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if 'name' in value: 105 if 'name' in value:
106 del value['name'] 106 del value['name']
107 value['path'] = os.path.basename(value['path']) 107 value['path'] = os.path.basename(value['path'])
108 108
109 # Teach build shell script to look for the configuration and platform. 109 # Teach build shell script to look for the configuration and platform.
110 if isa == 'PBXShellScriptBuildPhase': 110 if isa == 'PBXShellScriptBuildPhase':
111 value['shellScript'] = value['shellScript'].replace( 111 value['shellScript'] = value['shellScript'].replace(
112 'ninja -C .', 112 'ninja -C .',
113 'ninja -C "../${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}"') 113 'ninja -C "../${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}"')
114 114
115 # Configure BUNDLE_LOADER and TEST_HOST for xctest target (assuming that 115 # Configure BUNDLE_LOADER and TEST_HOST for xctest targets (if not yet
116 # the host is named "${target}_host") unless gn has already configured 116 # configured by gn). Old convention was to name the test dynamic module
117 # them. 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
119 # by inspecting the target name.
118 if isa == 'PBXNativeTarget' and value['productType'] == XCTEST_PRODUCT_TYPE: 120 if isa == 'PBXNativeTarget' and value['productType'] == XCTEST_PRODUCT_TYPE:
119 configuration_list = project.objects[value['buildConfigurationList']] 121 configuration_list = project.objects[value['buildConfigurationList']]
120 for config_name in configuration_list['buildConfigurations']: 122 for config_name in configuration_list['buildConfigurations']:
121 config = project.objects[config_name] 123 config = project.objects[config_name]
122 if not config['buildSettings'].get('BUNDLE_LOADER'): 124 if not config['buildSettings'].get('BUNDLE_LOADER'):
125 if value['name'].endswith('_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'
123 config['buildSettings']['BUNDLE_LOADER'] = '$(TEST_HOST)' 131 config['buildSettings']['BUNDLE_LOADER'] = '$(TEST_HOST)'
124 config['buildSettings']['TEST_HOST'] = \ 132 config['buildSettings']['TEST_HOST'] = \
125 '${BUILT_PRODUCTS_DIR}/%(name)s_host.app/%(name)s' % value 133 '${BUILT_PRODUCTS_DIR}/%s.app/%s' % (host_name, host_name)
126 134
127 # Add new configuration, using the first one as default. 135 # Add new configuration, using the first one as default.
128 if isa == 'XCConfigurationList': 136 if isa == 'XCConfigurationList':
129 value['defaultConfigurationName'] = configurations[0] 137 value['defaultConfigurationName'] = configurations[0]
130 objects_to_remove.extend(value['buildConfigurations']) 138 objects_to_remove.extend(value['buildConfigurations'])
131 139
132 build_config_template = project.objects[value['buildConfigurations'][0]] 140 build_config_template = project.objects[value['buildConfigurations'][0]]
133 build_config_template['buildSettings']['CONFIGURATION_BUILD_DIR'] = \ 141 build_config_template['buildSettings']['CONFIGURATION_BUILD_DIR'] = \
134 '../$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)' 142 '../$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
135 143
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if not args.configurations: 213 if not args.configurations:
206 sys.stderr.write('At least one configuration required, see --add-config.\n') 214 sys.stderr.write('At least one configuration required, see --add-config.\n')
207 return 1 215 return 1
208 216
209 ConvertGnXcodeProject(args.input, args.output, args.configurations) 217 ConvertGnXcodeProject(args.input, args.output, args.configurations)
210 218
211 if __name__ == '__main__': 219 if __name__ == '__main__':
212 sys.exit(Main(sys.argv[1:])) 220 sys.exit(Main(sys.argv[1:]))
213 221
214 222
OLDNEW
« no previous file with comments | « ios/build/bots/scripts/test_runner.py ('k') | ios/web/shell/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698