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 """ | 5 """ |
6 This module contains classes that help to emulate xcodebuild behavior on top of | 6 This module contains classes that help to emulate xcodebuild behavior on top of |
7 other build systems, such as make and ninja. | 7 other build systems, such as make and ninja. |
8 """ | 8 """ |
9 | 9 |
| 10 import copy |
10 import gyp.common | 11 import gyp.common |
11 import os.path | 12 import os.path |
12 import re | 13 import re |
13 import shlex | 14 import shlex |
14 import subprocess | 15 import subprocess |
15 import sys | 16 import sys |
16 from gyp.common import GypError | 17 from gyp.common import GypError |
17 | 18 |
18 class XcodeSettings(object): | 19 class XcodeSettings(object): |
19 """A class that understands the gyp 'xcode_settings' object.""" | 20 """A class that understands the gyp 'xcode_settings' object.""" |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 def GetSpecPostbuildCommands(spec, quiet=False): | 1184 def GetSpecPostbuildCommands(spec, quiet=False): |
1184 """Returns the list of postbuilds explicitly defined on |spec|, in a form | 1185 """Returns the list of postbuilds explicitly defined on |spec|, in a form |
1185 executable by a shell.""" | 1186 executable by a shell.""" |
1186 postbuilds = [] | 1187 postbuilds = [] |
1187 for postbuild in spec.get('postbuilds', []): | 1188 for postbuild in spec.get('postbuilds', []): |
1188 if not quiet: | 1189 if not quiet: |
1189 postbuilds.append('echo POSTBUILD\\(%s\\) %s' % ( | 1190 postbuilds.append('echo POSTBUILD\\(%s\\) %s' % ( |
1190 spec['target_name'], postbuild['postbuild_name'])) | 1191 spec['target_name'], postbuild['postbuild_name'])) |
1191 postbuilds.append(gyp.common.EncodePOSIXShellList(postbuild['action'])) | 1192 postbuilds.append(gyp.common.EncodePOSIXShellList(postbuild['action'])) |
1192 return postbuilds | 1193 return postbuilds |
| 1194 |
| 1195 |
| 1196 def _HasIOSTarget(targets): |
| 1197 """Returns true if any target contains the iOS specific key |
| 1198 IPHONEOS_DEPLOYMENT_TARGET.""" |
| 1199 for target_dict in targets.values(): |
| 1200 for config in target_dict['configurations'].values(): |
| 1201 if config.get('xcode_settings', {}).get('IPHONEOS_DEPLOYMENT_TARGET'): |
| 1202 return True |
| 1203 return False |
| 1204 |
| 1205 |
| 1206 def _AddIOSDeviceConfigurations(targets): |
| 1207 """Clone all targets and append -iphoneos to the name. Configure these targets |
| 1208 to build for iOS devices.""" |
| 1209 for target_dict in targets.values(): |
| 1210 for config_name in target_dict['configurations'].keys(): |
| 1211 config = target_dict['configurations'][config_name] |
| 1212 new_config_name = config_name + '-iphoneos' |
| 1213 new_config_dict = copy.deepcopy(config) |
| 1214 if target_dict['toolset'] == 'target': |
| 1215 new_config_dict['xcode_settings']['ARCHS'] = ['armv7'] |
| 1216 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
| 1217 target_dict['configurations'][new_config_name] = new_config_dict |
| 1218 return targets |
| 1219 |
| 1220 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
| 1221 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
| 1222 targets for iOS device builds.""" |
| 1223 if _HasIOSTarget(target_dicts): |
| 1224 return _AddIOSDeviceConfigurations(target_dicts) |
| 1225 return target_dicts |
OLD | NEW |