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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 def _WarnUnimplemented(self, test_key): | 214 def _WarnUnimplemented(self, test_key): |
215 if test_key in self._Settings(): | 215 if test_key in self._Settings(): |
216 print 'Warning: Ignoring not yet implemented key "%s".' % test_key | 216 print 'Warning: Ignoring not yet implemented key "%s".' % test_key |
217 | 217 |
218 def _IsBundle(self): | 218 def _IsBundle(self): |
219 return int(self.spec.get('mac_bundle', 0)) != 0 | 219 return int(self.spec.get('mac_bundle', 0)) != 0 |
220 | 220 |
221 def _IsIosAppExtension(self): | 221 def _IsIosAppExtension(self): |
222 return int(self.spec.get('ios_app_extension', 0)) != 0 | 222 return int(self.spec.get('ios_app_extension', 0)) != 0 |
223 | 223 |
| 224 def _IsIosWatchKitExtension(self): |
| 225 return int(self.spec.get('ios_watchkit_extension', 0)) != 0 |
| 226 |
| 227 def _IsIosWatchApp(self): |
| 228 return int(self.spec.get('ios_watch_app', 0)) != 0 |
| 229 |
224 def GetFrameworkVersion(self): | 230 def GetFrameworkVersion(self): |
225 """Returns the framework version of the current target. Only valid for | 231 """Returns the framework version of the current target. Only valid for |
226 bundles.""" | 232 bundles.""" |
227 assert self._IsBundle() | 233 assert self._IsBundle() |
228 return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A') | 234 return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A') |
229 | 235 |
230 def GetWrapperExtension(self): | 236 def GetWrapperExtension(self): |
231 """Returns the bundle extension (.app, .framework, .plugin, etc). Only | 237 """Returns the bundle extension (.app, .framework, .plugin, etc). Only |
232 valid for bundles.""" | 238 valid for bundles.""" |
233 assert self._IsBundle() | 239 assert self._IsBundle() |
234 if self.spec['type'] in ('loadable_module', 'shared_library'): | 240 if self.spec['type'] in ('loadable_module', 'shared_library'): |
235 default_wrapper_extension = { | 241 default_wrapper_extension = { |
236 'loadable_module': 'bundle', | 242 'loadable_module': 'bundle', |
237 'shared_library': 'framework', | 243 'shared_library': 'framework', |
238 }[self.spec['type']] | 244 }[self.spec['type']] |
239 wrapper_extension = self.GetPerTargetSetting( | 245 wrapper_extension = self.GetPerTargetSetting( |
240 'WRAPPER_EXTENSION', default=default_wrapper_extension) | 246 'WRAPPER_EXTENSION', default=default_wrapper_extension) |
241 return '.' + self.spec.get('product_extension', wrapper_extension) | 247 return '.' + self.spec.get('product_extension', wrapper_extension) |
242 elif self.spec['type'] == 'executable': | 248 elif self.spec['type'] == 'executable': |
243 if self._IsIosAppExtension(): | 249 if self._IsIosAppExtension() or self._IsIosWatchKitExtension(): |
244 return '.' + self.spec.get('product_extension', 'appex') | 250 return '.' + self.spec.get('product_extension', 'appex') |
245 else: | 251 else: |
246 return '.' + self.spec.get('product_extension', 'app') | 252 return '.' + self.spec.get('product_extension', 'app') |
247 else: | 253 else: |
248 assert False, "Don't know extension for '%s', target '%s'" % ( | 254 assert False, "Don't know extension for '%s', target '%s'" % ( |
249 self.spec['type'], self.spec['target_name']) | 255 self.spec['type'], self.spec['target_name']) |
250 | 256 |
251 def GetProductName(self): | 257 def GetProductName(self): |
252 """Returns PRODUCT_NAME.""" | 258 """Returns PRODUCT_NAME.""" |
253 return self.spec.get('product_name', self.spec['target_name']) | 259 return self.spec.get('product_name', self.spec['target_name']) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 else: | 301 else: |
296 return os.path.join(self.GetBundleContentsFolderPath(), | 302 return os.path.join(self.GetBundleContentsFolderPath(), |
297 'Resources', 'Info.plist') | 303 'Resources', 'Info.plist') |
298 | 304 |
299 def GetProductType(self): | 305 def GetProductType(self): |
300 """Returns the PRODUCT_TYPE of this target.""" | 306 """Returns the PRODUCT_TYPE of this target.""" |
301 if self._IsIosAppExtension(): | 307 if self._IsIosAppExtension(): |
302 assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle ' | 308 assert self._IsBundle(), ('ios_app_extension flag requires mac_bundle ' |
303 '(target %s)' % self.spec['target_name']) | 309 '(target %s)' % self.spec['target_name']) |
304 return 'com.apple.product-type.app-extension' | 310 return 'com.apple.product-type.app-extension' |
| 311 if self._IsIosWatchKitExtension(): |
| 312 assert self._IsBundle(), ('ios_watchkit_extension flag requires ' |
| 313 'mac_bundle (target %s)' % self.spec['target_name']) |
| 314 return 'com.apple.product-type.watchkit-extension' |
| 315 if self._IsIosWatchApp(): |
| 316 assert self._IsBundle(), ('ios_watch_app flag requires mac_bundle ' |
| 317 '(target %s)' % self.spec['target_name']) |
| 318 return 'com.apple.product-type.application.watchapp' |
305 if self._IsBundle(): | 319 if self._IsBundle(): |
306 return { | 320 return { |
307 'executable': 'com.apple.product-type.application', | 321 'executable': 'com.apple.product-type.application', |
308 'loadable_module': 'com.apple.product-type.bundle', | 322 'loadable_module': 'com.apple.product-type.bundle', |
309 'shared_library': 'com.apple.product-type.framework', | 323 'shared_library': 'com.apple.product-type.framework', |
310 }[self.spec['type']] | 324 }[self.spec['type']] |
311 else: | 325 else: |
312 return { | 326 return { |
313 'executable': 'com.apple.product-type.tool', | 327 'executable': 'com.apple.product-type.tool', |
314 'loadable_module': 'com.apple.product-type.library.dynamic', | 328 'loadable_module': 'com.apple.product-type.library.dynamic', |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 ldflags.append('-Wl,-rpath,' + rpath) | 811 ldflags.append('-Wl,-rpath,' + rpath) |
798 | 812 |
799 sdk_root = self._SdkPath() | 813 sdk_root = self._SdkPath() |
800 if not sdk_root: | 814 if not sdk_root: |
801 sdk_root = '' | 815 sdk_root = '' |
802 config = self.spec['configurations'][self.configname] | 816 config = self.spec['configurations'][self.configname] |
803 framework_dirs = config.get('mac_framework_dirs', []) | 817 framework_dirs = config.get('mac_framework_dirs', []) |
804 for directory in framework_dirs: | 818 for directory in framework_dirs: |
805 ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) | 819 ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) |
806 | 820 |
807 if sdk_root and self._IsIosAppExtension(): | 821 is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension() |
| 822 if sdk_root and is_extension: |
808 # Adds the link flags for extensions. These flags are common for all | 823 # Adds the link flags for extensions. These flags are common for all |
809 # extensions and provide loader and main function. | 824 # extensions and provide loader and main function. |
810 # These flags reflect the compilation options used by xcode to compile | 825 # These flags reflect the compilation options used by xcode to compile |
811 # extensions. | 826 # extensions. |
812 ldflags.append('-lpkstart') | 827 ldflags.append('-lpkstart') |
813 ldflags.append(sdk_root + | 828 ldflags.append(sdk_root + |
814 '/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit') | 829 '/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit') |
815 ldflags.append('-fapplication-extension') | 830 ldflags.append('-fapplication-extension') |
816 ldflags.append('-Xlinker -rpath ' | 831 ldflags.append('-Xlinker -rpath ' |
817 '-Xlinker @executable_path/../../Frameworks') | 832 '-Xlinker @executable_path/../../Frameworks') |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 if toolset == 'target': | 1587 if toolset == 'target': |
1573 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' | 1588 iphoneos_config_dict['xcode_settings']['SDKROOT'] = 'iphoneos' |
1574 return targets | 1589 return targets |
1575 | 1590 |
1576 def CloneConfigurationForDeviceAndEmulator(target_dicts): | 1591 def CloneConfigurationForDeviceAndEmulator(target_dicts): |
1577 """If |target_dicts| contains any iOS targets, automatically create -iphoneos | 1592 """If |target_dicts| contains any iOS targets, automatically create -iphoneos |
1578 targets for iOS device builds.""" | 1593 targets for iOS device builds.""" |
1579 if _HasIOSTarget(target_dicts): | 1594 if _HasIOSTarget(target_dicts): |
1580 return _AddIOSDeviceConfigurations(target_dicts) | 1595 return _AddIOSDeviceConfigurations(target_dicts) |
1581 return target_dicts | 1596 return target_dicts |
OLD | NEW |