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 |
| @@ -40,25 +44,31 @@ |
| configs = spec['configurations'] |
| for configname, config in configs.iteritems(): |
| self.xcode_settings[configname] = config.get('xcode_settings', {}) |
| + self._ConvertConditionalKeys(configname) |
| if self.xcode_settings[configname].get('IPHONEOS_DEPLOYMENT_TARGET', |
| 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] |
| - |
| # This is only non-None temporarily during the execution of some methods. |
| self.configname = None |
| # Used by _AdjustLibrary to match .a and .dylib entries in libraries. |
| self.library_re = re.compile(r'^lib([^/]+)\.(a|dylib)$') |
| + def _ConvertConditionalKeys(self, configname): |
|
Nico
2013/10/15 02:12:57
docstring
justincohen
2013/10/15 16:47:33
Done.
|
| + settings = self.xcode_settings[configname] |
| + conditional_keys = [key for key in settings if key.endswith(']')] |
| + for key in conditional_keys: |
| + # If you need more, speak up at http://crbug.com/122592 |
|
Nico
2013/10/15 02:12:57
indented too far
justincohen
2013/10/15 16:47:33
Done.
|
| + if key.endswith("[sdk=iphoneos*]"): |
| + if configname.endswith("iphoneos"): |
| + new_key = key.split("[")[0] |
| + settings[new_key] = settings[key] |
| + else: |
| + print 'Warning: Conditional keys not implemented, ignoring:', \ |
| + ' '.join(conditional_keys) |
| + del settings[key] |
| + |
| def _Settings(self): |
| assert self.configname |
| return self.xcode_settings[self.configname] |
| @@ -752,6 +762,43 @@ |
| self._GetDebugInfoPostbuilds(configname, output, output_binary, quiet) + |
| self._GetStripPostbuilds(configname, output_binary, quiet)) |
| + def _GetIOSPostbuilds(self, configname, is_app, output_binary): |
| + """Return a shell command to codesign the iOS output binary so it can |
| + be deployed to a device. This should be run as the very last step of the |
| + build.""" |
| + if not (self.isIOS and is_app): |
|
Nico
2013/10/15 02:12:57
this can read self.spec['type'], no need to for th
justincohen
2013/10/15 16:47:33
Done.
|
| + return [] |
| + |
| + self.configname = configname |
| + identity = self._Settings().get('CODE_SIGN_IDENTITY') |
| + if identity == None: |
| + return [] |
|
Nico
2013/10/15 02:12:57
now self.configname is wrong
Nico
2013/10/15 02:33:27
Also, setting this to "" (the empty string) appare
justincohen
2013/10/15 16:47:33
Done.
justincohen
2013/10/15 16:47:33
Done
On 2013/10/15 02:33:27, Nico wrote:
|
| + if identity not in XcodeSettings._codesigning_key_cache: |
| + proc = subprocess.Popen(['security', 'find-identity', '-p', 'codesigning', |
| + '-v'], stdout=subprocess.PIPE) |
|
Nico
2013/10/15 02:19:29
why -v here?
Nico
2013/10/15 02:22:28
Ignore this, I misread the man page for `security`
justincohen
2013/10/15 16:47:33
Done.
justincohen
2013/10/15 16:47:33
Done.
|
| + output = proc.communicate()[0].strip() |
| + key = None |
| + for item in output.split("\n"): |
| + if identity in item: |
| + assert key == None, ( |
| + "Multiple codesigning identities for identity: %s" % |
| + identity) |
| + key = item.split(' ')[1] |
| + XcodeSettings._codesigning_key_cache[identity] = key |
| + self.configname = None |
| + key = XcodeSettings._codesigning_key_cache[identity] |
| + if key: |
| + return ["/usr/bin/codesign -v --force --sign %s %s" % |
|
Nico
2013/10/15 02:12:57
the rest of this file uses ' quotes
why "/usr/bin
justincohen
2013/10/15 16:47:33
Yeah, it was as verbose. I removed it.
On 2013/1
|
| + (key, output_binary)] |
| + return [] |
| + |
| + def AddImplicitPostbuilds(self, configname, is_app, output, output_binary, |
| + postbuilds, quiet=False): |
|
Nico
2013/10/15 02:12:57
docstring
justincohen
2013/10/15 16:47:33
Done.
|
| + assert output_binary is not None |
| + pre = self.GetTargetPostbuilds(configname, output, output_binary, quiet) |
| + post = self._GetIOSPostbuilds(configname, is_app, output_binary) |
| + return (pre + postbuilds + post) |
|
Nico
2013/10/15 02:12:57
no parens
justincohen
2013/10/15 16:47:33
Done.
|
| + |
| def _AdjustLibrary(self, library, config_name=None): |
| if library.endswith('.framework'): |
| l = '-framework ' + os.path.splitext(os.path.basename(library))[0] |