Chromium Code Reviews| Index: pylib/gyp/xcode_emulation.py |
| =================================================================== |
| --- pylib/gyp/xcode_emulation.py (revision 1754) |
| +++ pylib/gyp/xcode_emulation.py (working copy) |
| @@ -27,6 +27,10 @@ |
| # cached at class-level for efficiency. |
| _plist_cache = {} |
| + # Populated lazily by GetIOSPostbuilds. Shared by all XcodeSettings, so |
| + # cached at class-level for efficiency. |
| + _codesigning_key_cache = {} |
| + |
| def __init__(self, spec): |
| self.spec = spec |
| @@ -44,14 +48,17 @@ |
| None): |
| self.isIOS = True |
| - # If you need this, speak up at http://crbug.com/122592 |
| - conditional_keys = [key for key in self.xcode_settings[configname] |
| - if key.endswith(']')] |
| - if conditional_keys: |
| - print 'Warning: Conditional keys not implemented, ignoring:', \ |
| - ' '.join(conditional_keys) |
| - for key in conditional_keys: |
| - del self.xcode_settings[configname][key] |
| + if self.isIOS: |
| + self._ConvertConditionalKeys(configname) |
| + else: |
|
Nico
2013/10/14 16:54:55
Why else?
justincohen
2013/10/14 16:59:12
I wasn't sure what to do here. I thought it would
Nico
2013/10/14 17:00:07
Sure, but shouldn't you have it for ios builds too
justincohen
2013/10/14 17:01:49
I'll change it not warn for ios/sdk=iphoneos*, but
|
| + # If you need this, speak up at http://crbug.com/122592 |
| + conditional_keys = [key for key in self.xcode_settings[configname] |
| + if key.endswith(']')] |
| + if conditional_keys: |
| + print 'Warning: Conditional keys not implemented, ignoring:', \ |
| + ' '.join(conditional_keys) |
| + for key in conditional_keys: |
| + del self.xcode_settings[configname][key] |
| # This is only non-None temporarily during the execution of some methods. |
| self.configname = None |
| @@ -59,6 +66,15 @@ |
| # Used by _AdjustLibrary to match .a and .dylib entries in libraries. |
| self.library_re = re.compile(r'^lib([^/]+)\.(a|dylib)$') |
| + def _ConvertConditionalKeys(self, configname): |
| + settings = self.xcode_settings[configname] |
| + conditional_keys = [key for key in settings if key.endswith(']')] |
| + for key in conditional_keys: |
| + if key.endswith("[sdk=iphoneos*]") and configname.endswith("iphoneos"): |
| + new_key = key.split("[")[0] |
| + settings[new_key] = settings[key] |
| + del settings[key] |
| + |
| def _Settings(self): |
| assert self.configname |
| return self.xcode_settings[self.configname] |
| @@ -752,6 +768,30 @@ |
| self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) + |
| self._GetStripPostbuilds(configname, output_binary, quiet)) |
| + def GetIOSPostbuilds(self, configname, output_binary, postbuilds): |
| + if self.isIOS: |
| + self.configname = configname |
| + identity = self._Settings().get('CODE_SIGN_IDENTITY') |
| + if identity == None: |
| + return postbuilds |
| + |
| + if identity not in XcodeSettings._codesigning_key_cache: |
| + proc = subprocess.Popen(['security', 'find-identity', '-p', |
| + 'codesigning', '-v'], stdout=subprocess.PIPE) |
| + output = proc.communicate()[0].strip() |
| + key_id = None |
| + for item in output.split("\n"): |
| + if identity in item: |
| + assert key_id == None, ( |
| + "Multiple codesigning identities for identity: %s" % |
| + identity) |
| + key = item.split(' ')[1] |
| + XcodeSettings._codesigning_key_cache[identity] = key |
| + postbuilds.append( |
| + "/usr/bin/codesign -v --force --sign %s %s" % |
| + (XcodeSettings._codesigning_key_cache[identity], output_binary)) |
| + return postbuilds |
| + |
| def _AdjustLibrary(self, library, config_name=None): |
| if library.endswith('.framework'): |
| l = '-framework ' + os.path.splitext(os.path.basename(library))[0] |