| 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 """Xcode project file generator. | 5 """Xcode project file generator. |
| 6 | 6 |
| 7 This module is both an Xcode project file generator and a documentation of the | 7 This module is both an Xcode project file generator and a documentation of the |
| 8 Xcode project file format. Knowledge of the project file format was gained | 8 Xcode project file format. Knowledge of the project file format was gained |
| 9 based on extensive experience with Xcode, and by making changes to projects in | 9 based on extensive experience with Xcode, and by making changes to projects in |
| 10 Xcode.app and observing the resultant changes in the associated project files. | 10 Xcode.app and observing the resultant changes in the associated project files. |
| (...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 'buildRules': [1, PBXBuildRule, 1, 1, []], | 2231 'buildRules': [1, PBXBuildRule, 1, 1, []], |
| 2232 'productReference': [0, PBXFileReference, 0, 1], | 2232 'productReference': [0, PBXFileReference, 0, 1], |
| 2233 'productType': [0, str, 0, 1], | 2233 'productType': [0, str, 0, 1], |
| 2234 }) | 2234 }) |
| 2235 | 2235 |
| 2236 # Mapping from Xcode product-types to settings. The settings are: | 2236 # Mapping from Xcode product-types to settings. The settings are: |
| 2237 # filetype : used for explicitFileType in the project file | 2237 # filetype : used for explicitFileType in the project file |
| 2238 # prefix : the prefix for the file name | 2238 # prefix : the prefix for the file name |
| 2239 # suffix : the suffix for the filen ame | 2239 # suffix : the suffix for the filen ame |
| 2240 _product_filetypes = { | 2240 _product_filetypes = { |
| 2241 'com.apple.product-type.application': ['wrapper.application', | 2241 'com.apple.product-type.application': ['wrapper.application', |
| 2242 '', '.app'], | 2242 '', '.app'], |
| 2243 'com.apple.product-type.bundle': ['wrapper.cfbundle', | 2243 'com.apple.product-type.bundle': ['wrapper.cfbundle', |
| 2244 '', '.bundle'], | 2244 '', '.bundle'], |
| 2245 'com.apple.product-type.framework': ['wrapper.framework', | 2245 'com.apple.product-type.framework': ['wrapper.framework', |
| 2246 '', '.framework'], | 2246 '', '.framework'], |
| 2247 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', | 2247 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', |
| 2248 'lib', '.dylib'], | 2248 'lib', '.dylib'], |
| 2249 'com.apple.product-type.library.static': ['archive.ar', | 2249 'com.apple.product-type.library.static': ['archive.ar', |
| 2250 'lib', '.a'], | 2250 'lib', '.a'], |
| 2251 'com.apple.product-type.tool': ['compiled.mach-o.executable', | 2251 'com.apple.product-type.tool': ['compiled.mach-o.executable', |
| 2252 '', ''], | 2252 '', ''], |
| 2253 'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib', | 2253 'com.apple.product-type.bundle.unit-test': ['wrapper.cfbundle', |
| 2254 '', '.so'], | 2254 '', '.xctest'], |
| 2255 'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib', |
| 2256 '', '.so'], |
| 2255 } | 2257 } |
| 2256 | 2258 |
| 2257 def __init__(self, properties=None, id=None, parent=None, | 2259 def __init__(self, properties=None, id=None, parent=None, |
| 2258 force_outdir=None, force_prefix=None, force_extension=None): | 2260 force_outdir=None, force_prefix=None, force_extension=None): |
| 2259 # super | 2261 # super |
| 2260 XCTarget.__init__(self, properties, id, parent) | 2262 XCTarget.__init__(self, properties, id, parent) |
| 2261 | 2263 |
| 2262 if 'productName' in self._properties and \ | 2264 if 'productName' in self._properties and \ |
| 2263 'productType' in self._properties and \ | 2265 'productType' in self._properties and \ |
| 2264 not 'productReference' in self._properties and \ | 2266 not 'productReference' in self._properties and \ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 # Mac OS X use an .so extension. | 2298 # Mac OS X use an .so extension. |
| 2297 if self._properties['productType'] == 'com.googlecode.gyp.xcode.bundle': | 2299 if self._properties['productType'] == 'com.googlecode.gyp.xcode.bundle': |
| 2298 self._properties['productType'] = \ | 2300 self._properties['productType'] = \ |
| 2299 'com.apple.product-type.library.dynamic' | 2301 'com.apple.product-type.library.dynamic' |
| 2300 self.SetBuildSetting('MACH_O_TYPE', 'mh_bundle') | 2302 self.SetBuildSetting('MACH_O_TYPE', 'mh_bundle') |
| 2301 self.SetBuildSetting('DYLIB_CURRENT_VERSION', '') | 2303 self.SetBuildSetting('DYLIB_CURRENT_VERSION', '') |
| 2302 self.SetBuildSetting('DYLIB_COMPATIBILITY_VERSION', '') | 2304 self.SetBuildSetting('DYLIB_COMPATIBILITY_VERSION', '') |
| 2303 if force_extension is None: | 2305 if force_extension is None: |
| 2304 force_extension = suffix[1:] | 2306 force_extension = suffix[1:] |
| 2305 | 2307 |
| 2308 if self._properties['productType'] == \ |
| 2309 'com.apple.product-type-bundle.unit.test': |
| 2310 if force_extension is None: |
| 2311 force_extension = suffix[1:] |
| 2312 |
| 2306 if force_extension is not None: | 2313 if force_extension is not None: |
| 2307 # If it's a wrapper (bundle), set WRAPPER_EXTENSION. | 2314 # If it's a wrapper (bundle), set WRAPPER_EXTENSION. |
| 2308 if filetype.startswith('wrapper.'): | 2315 if filetype.startswith('wrapper.'): |
| 2309 self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) | 2316 self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) |
| 2310 else: | 2317 else: |
| 2311 # Extension override. | 2318 # Extension override. |
| 2312 suffix = '.' + force_extension | 2319 suffix = '.' + force_extension |
| 2313 self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) | 2320 self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) |
| 2314 | 2321 |
| 2315 if filetype.startswith('compiled.mach-o.executable'): | 2322 if filetype.startswith('compiled.mach-o.executable'): |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') | 2879 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') |
| 2873 for object in sorted(objects_by_class[class_name], | 2880 for object in sorted(objects_by_class[class_name], |
| 2874 cmp=lambda x, y: cmp(x.id, y.id)): | 2881 cmp=lambda x, y: cmp(x.id, y.id)): |
| 2875 object.Print(file) | 2882 object.Print(file) |
| 2876 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') | 2883 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') |
| 2877 | 2884 |
| 2878 if self._should_print_single_line: | 2885 if self._should_print_single_line: |
| 2879 self._XCPrint(file, 0, '}; ') | 2886 self._XCPrint(file, 0, '}; ') |
| 2880 else: | 2887 else: |
| 2881 self._XCPrint(file, 1, '};\n') | 2888 self._XCPrint(file, 1, '};\n') |
| OLD | NEW |