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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 return install_name | 706 return install_name |
707 | 707 |
708 def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path): | 708 def _MapLinkerFlagFilename(self, ldflag, gyp_to_build_path): |
709 """Checks if ldflag contains a filename and if so remaps it from | 709 """Checks if ldflag contains a filename and if so remaps it from |
710 gyp-directory-relative to build-directory-relative.""" | 710 gyp-directory-relative to build-directory-relative.""" |
711 # This list is expanded on demand. | 711 # This list is expanded on demand. |
712 # They get matched as: | 712 # They get matched as: |
713 # -exported_symbols_list file | 713 # -exported_symbols_list file |
714 # -Wl,exported_symbols_list file | 714 # -Wl,exported_symbols_list file |
715 # -Wl,exported_symbols_list,file | 715 # -Wl,exported_symbols_list,file |
716 LINKER_FILE = '(\S+)' | 716 LINKER_FILE = r'(\S+)' |
717 WORD = '\S+' | 717 WORD = r'\S+' |
718 linker_flags = [ | 718 linker_flags = [ |
719 ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl. | 719 ['-exported_symbols_list', LINKER_FILE], # Needed for NaCl. |
720 ['-unexported_symbols_list', LINKER_FILE], | 720 ['-unexported_symbols_list', LINKER_FILE], |
721 ['-reexported_symbols_list', LINKER_FILE], | 721 ['-reexported_symbols_list', LINKER_FILE], |
722 ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting. | 722 ['-sectcreate', WORD, WORD, LINKER_FILE], # Needed for remoting. |
723 ] | 723 ] |
724 for flag_pattern in linker_flags: | 724 for flag_pattern in linker_flags: |
725 regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern)) | 725 regex = re.compile('(?:-Wl,)?' + '[ ,]'.join(flag_pattern)) |
726 m = regex.match(ldflag) | 726 m = regex.match(ldflag) |
727 if m: | 727 if m: |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 if XCODE_VERSION_CACHE: | 1206 if XCODE_VERSION_CACHE: |
1207 return XCODE_VERSION_CACHE | 1207 return XCODE_VERSION_CACHE |
1208 try: | 1208 try: |
1209 version_list = GetStdout(['xcodebuild', '-version']).splitlines() | 1209 version_list = GetStdout(['xcodebuild', '-version']).splitlines() |
1210 # In some circumstances xcodebuild exits 0 but doesn't return | 1210 # In some circumstances xcodebuild exits 0 but doesn't return |
1211 # the right results; for example, a user on 10.7 or 10.8 with | 1211 # the right results; for example, a user on 10.7 or 10.8 with |
1212 # a bogus path set via xcode-select | 1212 # a bogus path set via xcode-select |
1213 # In that case this may be a CLT-only install so fall back to | 1213 # In that case this may be a CLT-only install so fall back to |
1214 # checking that version. | 1214 # checking that version. |
1215 if len(version_list) < 2: | 1215 if len(version_list) < 2: |
1216 raise GypError, "xcodebuild returned unexpected results" | 1216 raise GypError("xcodebuild returned unexpected results") |
1217 except: | 1217 except: |
1218 version = CLTVersion() | 1218 version = CLTVersion() |
1219 if version: | 1219 if version: |
1220 version = re.match('(\d\.\d\.?\d*)', version).groups()[0] | 1220 version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0] |
1221 else: | 1221 else: |
1222 raise GypError, "No Xcode or CLT version detected!" | 1222 raise GypError("No Xcode or CLT version detected!") |
1223 # The CLT has no build information, so we return an empty string. | 1223 # The CLT has no build information, so we return an empty string. |
1224 version_list = [version, ''] | 1224 version_list = [version, ''] |
1225 version = version_list[0] | 1225 version = version_list[0] |
1226 build = version_list[-1] | 1226 build = version_list[-1] |
1227 # Be careful to convert "4.2" to "0420": | 1227 # Be careful to convert "4.2" to "0420": |
1228 version = version.split()[-1].replace('.', '') | 1228 version = version.split()[-1].replace('.', '') |
1229 version = (version + '0' * (3 - len(version))).zfill(4) | 1229 version = (version + '0' * (3 - len(version))).zfill(4) |
1230 if build: | 1230 if build: |
1231 build = build.split()[-1] | 1231 build = build.split()[-1] |
1232 XCODE_VERSION_CACHE = (version, build) | 1232 XCODE_VERSION_CACHE = (version, build) |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 if toolset == 'target': | 1572 if toolset == 'target': |
1573 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1573 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
1574 return targets | 1574 return targets |
1575 | 1575 |
1576 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1576 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
1577 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1577 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
1578 targets for iOS device builds.""" | 1578 targets for iOS device builds.""" |
1579 if _HasIOSTarget(target_dicts): | 1579 if _HasIOSTarget(target_dicts): |
1580 return _AddIOSDeviceConfigurations(target_dicts) | 1580 return _AddIOSDeviceConfigurations(target_dicts) |
1581 return target_dicts | 1581 return target_dicts |
OLD | NEW |