| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Xcode project file generator. | 7 """Xcode project file generator. |
| 8 | 8 |
| 9 This module is both an Xcode project file generator and a documentation of the | 9 This module is both an Xcode project file generator and a documentation of the |
| 10 Xcode project file format. Knowledge of the project file format was gained | 10 Xcode project file format. Knowledge of the project file format was gained |
| (...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 [PBXSourcesBuildPhase(), PBXFrameworksBuildPhase()]], | 2156 [PBXSourcesBuildPhase(), PBXFrameworksBuildPhase()]], |
| 2157 'buildRules': [1, PBXBuildRule, 1, 1, []], | 2157 'buildRules': [1, PBXBuildRule, 1, 1, []], |
| 2158 'productReference': [0, PBXFileReference, 0, 1], | 2158 'productReference': [0, PBXFileReference, 0, 1], |
| 2159 'productType': [0, str, 0, 1], | 2159 'productType': [0, str, 0, 1], |
| 2160 }) | 2160 }) |
| 2161 | 2161 |
| 2162 # Mapping from Xcode product-types to settings. The settings are: | 2162 # Mapping from Xcode product-types to settings. The settings are: |
| 2163 # filetype : used for explicitFileType in the project file | 2163 # filetype : used for explicitFileType in the project file |
| 2164 # prefix : the prefix for the file name | 2164 # prefix : the prefix for the file name |
| 2165 # suffix : the suffix for the filen ame | 2165 # suffix : the suffix for the filen ame |
| 2166 # set_xc_exe_prefix : bool to say if EXECUTABLE_PREFIX should be set to the | |
| 2167 # prefix value. | |
| 2168 _product_filetypes = { | 2166 _product_filetypes = { |
| 2169 'com.apple.product-type.application': ['wrapper.application', | 2167 'com.apple.product-type.application': ['wrapper.application', |
| 2170 '', '.app', False], | 2168 '', '.app'], |
| 2171 'com.apple.product-type.bundle': ['wrapper.cfbundle', | 2169 'com.apple.product-type.bundle': ['wrapper.cfbundle', |
| 2172 '', '.bundle', False], | 2170 '', '.bundle'], |
| 2173 'com.apple.product-type.framework': ['wrapper.framework', | 2171 'com.apple.product-type.framework': ['wrapper.framework', |
| 2174 '', '.framework', False], | 2172 '', '.framework'], |
| 2175 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', | 2173 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', |
| 2176 'lib', '.dylib', True], | 2174 'lib', '.dylib'], |
| 2177 'com.apple.product-type.library.static': ['archive.ar', | 2175 'com.apple.product-type.library.static': ['archive.ar', |
| 2178 'lib', '.a', False], | 2176 'lib', '.a'], |
| 2179 'com.apple.product-type.tool': ['compiled.mach-o.executable', | 2177 'com.apple.product-type.tool': ['compiled.mach-o.executable', |
| 2180 '', '', False], | 2178 '', ''], |
| 2179 'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib', |
| 2180 '', '.so'], |
| 2181 } | 2181 } |
| 2182 | 2182 |
| 2183 def __init__(self, properties=None, id=None, parent=None, | 2183 def __init__(self, properties=None, id=None, parent=None, |
| 2184 force_outdir=None, force_prefix=None, force_extension=None): | 2184 force_outdir=None, force_prefix=None, force_extension=None): |
| 2185 # super | 2185 # super |
| 2186 XCTarget.__init__(self, properties, id, parent) | 2186 XCTarget.__init__(self, properties, id, parent) |
| 2187 | 2187 |
| 2188 if 'productName' in self._properties and \ | 2188 if 'productName' in self._properties and \ |
| 2189 'productType' in self._properties and \ | 2189 'productType' in self._properties and \ |
| 2190 not 'productReference' in self._properties and \ | 2190 not 'productReference' in self._properties and \ |
| 2191 self._properties['productType'] in self._product_filetypes: | 2191 self._properties['productType'] in self._product_filetypes: |
| 2192 products_group = None | 2192 products_group = None |
| 2193 pbxproject = self.PBXProjectAncestor() | 2193 pbxproject = self.PBXProjectAncestor() |
| 2194 if pbxproject != None: | 2194 if pbxproject != None: |
| 2195 products_group = pbxproject.ProductsGroup() | 2195 products_group = pbxproject.ProductsGroup() |
| 2196 | 2196 |
| 2197 if products_group != None: | 2197 if products_group != None: |
| 2198 (filetype, prefix, suffix, set_xc_exe_prefix) = \ | 2198 (filetype, prefix, suffix) = \ |
| 2199 self._product_filetypes[self._properties['productType']] | 2199 self._product_filetypes[self._properties['productType']] |
| 2200 # Xcode does not have a distinct type for loadable modules that are |
| 2201 # pure BSD targets (not in a bundle wrapper). GYP allows such modules |
| 2202 # to be specified by setting a target type to loadable_module without |
| 2203 # having mac_bundle set. These are mapped to the pseudo-product type |
| 2204 # com.googlecode.gyp.xcode.bundle. |
| 2205 # |
| 2206 # By picking up this special type and converting it to a dynamic |
| 2207 # library (com.apple.product-type.library.dynamic) with fix-ups, |
| 2208 # single-file loadable modules can be produced. |
| 2209 # |
| 2210 # MACH_O_TYPE is changed to mh_bundle to produce the proper file type |
| 2211 # (as opposed to mh_dylib). In order for linking to succeed, |
| 2212 # DYLIB_CURRENT_VERSION and DYLIB_COMPATIBILITY_VERSION must be |
| 2213 # cleared. They are meaningless for type mh_bundle. |
| 2214 # |
| 2215 # Finally, the .so extension is forcibly applied over the default |
| 2216 # (.dylib), unless another forced extension is already selected. |
| 2217 # .dylib is plainly wrong, and .bundle is used by loadable_modules in |
| 2218 # bundle wrappers (com.apple.product-type.bundle). .so seems an odd |
| 2219 # choice because it's used as the extension on many other systems that |
| 2220 # don't distinguish between linkable shared libraries and non-linkable |
| 2221 # loadable modules, but there's precedent: Python loadable modules on |
| 2222 # Mac OS X use an .so extension. |
| 2223 if self._properties['productType'] == 'com.googlecode.gyp.xcode.bundle': |
| 2224 self._properties['productType'] = \ |
| 2225 'com.apple.product-type.library.dynamic' |
| 2226 self.SetBuildSetting('MACH_O_TYPE', 'mh_bundle') |
| 2227 self.SetBuildSetting('DYLIB_CURRENT_VERSION', '') |
| 2228 self.SetBuildSetting('DYLIB_COMPATIBILITY_VERSION', '') |
| 2229 if force_extension == None: |
| 2230 force_extension = suffix[1:] |
| 2200 | 2231 |
| 2201 if force_extension is not None: | 2232 if force_extension is not None: |
| 2202 # If it's a wrapper (bundle), set WRAPPER_EXTENSION. | 2233 # If it's a wrapper (bundle), set WRAPPER_EXTENSION. |
| 2203 if filetype.startswith('wrapper.'): | 2234 if filetype.startswith('wrapper.'): |
| 2204 self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) | 2235 self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) |
| 2205 else: | 2236 else: |
| 2206 # Extension override. | 2237 # Extension override. |
| 2207 suffix = '.' + force_extension | 2238 suffix = '.' + force_extension |
| 2208 self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) | 2239 self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) |
| 2209 | 2240 |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2729 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') | 2760 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') |
| 2730 for object in sorted(objects_by_class[class_name], | 2761 for object in sorted(objects_by_class[class_name], |
| 2731 cmp=lambda x, y: cmp(x.id, y.id)): | 2762 cmp=lambda x, y: cmp(x.id, y.id)): |
| 2732 object.Print(file) | 2763 object.Print(file) |
| 2733 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') | 2764 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') |
| 2734 | 2765 |
| 2735 if self._should_print_single_line: | 2766 if self._should_print_single_line: |
| 2736 self._XCPrint(file, 0, '}; ') | 2767 self._XCPrint(file, 0, '}; ') |
| 2737 else: | 2768 else: |
| 2738 self._XCPrint(file, 1, '};\n') | 2769 self._XCPrint(file, 1, '};\n') |
| OLD | NEW |