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 """ | 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 copy |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1411 def _HasIOSTarget(targets): | 1411 def _HasIOSTarget(targets): |
| 1412 """Returns true if any target contains the iOS specific key | 1412 """Returns true if any target contains the iOS specific key |
| 1413 IPHONEOS_DEPLOYMENT_TARGET.""" | 1413 IPHONEOS_DEPLOYMENT_TARGET.""" |
| 1414 for target_dict in targets.values(): | 1414 for target_dict in targets.values(): |
| 1415 for config in target_dict['configurations'].values(): | 1415 for config in target_dict['configurations'].values(): |
| 1416 if config.get('xcode_settings', {}).get('IPHONEOS_DEPLOYMENT_TARGET'): | 1416 if config.get('xcode_settings', {}).get('IPHONEOS_DEPLOYMENT_TARGET'): |
| 1417 return True | 1417 return True |
| 1418 return False | 1418 return False |
| 1419 | 1419 |
| 1420 | 1420 |
| 1421 def _IOSIsDeviceSDKROOT(sdkroot): | |
| 1422 """Tests if |sdkroot| is a SDK for building for device.""" | |
| 1423 return sdkroot == 'iphoneos' | |
|
Mark Mentovai
2014/02/05 21:51:46
Shouldn’t this test be a little more comprehensive
sdefresne
2014/02/06 09:53:19
Done.
| |
| 1424 | |
| 1425 | |
| 1426 def _FilterIOSArchitectureForSDKROOT(xcode_settings): | |
| 1427 """Filter the ARCHS value from the |xcode_settings| dictionary to only | |
| 1428 contains architectures valid for the sdk configured in SDKROOT value.""" | |
| 1429 allowed_archs = ('i386', 'x86_64') | |
| 1430 if _IOSIsDeviceSDKROOT(xcode_settings.get('SDKROOT', '')): | |
| 1431 allowed_archs = ('armv7', 'armv7s', 'arm64') | |
| 1432 archs = set() | |
| 1433 for arch in (xcode_settings.get('ARCHS', []) or ['$(ARCHS_STANDARD)']): | |
| 1434 if arch == '$(ARCHS_STANDARD)': | |
| 1435 archs.update(allowed_archs[:-1]) | |
| 1436 elif arch == '$(ARCHS_STANDARD_INCLUDING_64_BIT)': | |
| 1437 archs.update(allowed_archs) | |
| 1438 elif arch in allowed_archs: | |
| 1439 archs.add(arch) | |
| 1440 valid_archs = set(xcode_settings.get('VALID_ARCHS', [])) | |
| 1441 if valid_archs: | |
| 1442 archs = archs & valid_archs | |
| 1443 xcode_settings['ARCHS'] = list(archs) | |
| 1444 | |
| 1445 | |
| 1421 def _AddIOSDeviceConfigurations(targets): | 1446 def _AddIOSDeviceConfigurations(targets): |
| 1422 """Clone all targets and append -iphoneos to the name. Configure these targets | 1447 """Clone all targets and append -iphoneos to the name. Configure these targets |
| 1423 to build for iOS devices.""" | 1448 to build for iOS devices and use correct architectures for those builds.""" |
| 1424 for target_dict in targets.values(): | 1449 for target_dict in targets.itervalues(): |
| 1425 for config_name in target_dict['configurations'].keys(): | 1450 for config_name in target_dict['configurations'].keys(): |
| 1426 config = target_dict['configurations'][config_name] | 1451 config = target_dict['configurations'][config_name] |
| 1427 new_config_name = config_name + '-iphoneos' | 1452 new_config_name = config_name + '-iphoneos' |
| 1428 new_config_dict = copy.deepcopy(config) | 1453 new_config_dict = copy.deepcopy(config) |
| 1429 if target_dict['toolset'] == 'target': | 1454 if target_dict['toolset'] == 'target': |
| 1430 new_config_dict['xcode_settings']['ARCHS'] = ['armv7'] | |
| 1431 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1455 new_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
| 1456 _FilterIOSArchitectureForSDKROOT(new_config_dict['xcode_settings']) | |
| 1457 _FilterIOSArchitectureForSDKROOT(config['xcode_settings']) | |
| 1432 target_dict['configurations'][new_config_name] = new_config_dict | 1458 target_dict['configurations'][new_config_name] = new_config_dict |
| 1433 return targets | 1459 return targets |
| 1434 | 1460 |
| 1435 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1461 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
| 1436 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1462 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
| 1437 targets for iOS device builds.""" | 1463 targets for iOS device builds.""" |
| 1438 if _HasIOSTarget(target_dicts): | 1464 if _HasIOSTarget(target_dicts): |
| 1439 return _AddIOSDeviceConfigurations(target_dicts) | 1465 return _AddIOSDeviceConfigurations(target_dicts) |
| 1440 return target_dicts | 1466 return target_dicts |
| OLD | NEW |