| 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 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2856 product_group._properties['children'] = sorted( | 2856 product_group._properties['children'] = sorted( |
| 2857 product_group._properties['children'], | 2857 product_group._properties['children'], |
| 2858 cmp=lambda x, y, rp=remote_products: CompareProducts(x, y, rp)) | 2858 cmp=lambda x, y, rp=remote_products: CompareProducts(x, y, rp)) |
| 2859 | 2859 |
| 2860 | 2860 |
| 2861 class XCProjectFile(XCObject): | 2861 class XCProjectFile(XCObject): |
| 2862 _schema = XCObject._schema.copy() | 2862 _schema = XCObject._schema.copy() |
| 2863 _schema.update({ | 2863 _schema.update({ |
| 2864 'archiveVersion': [0, int, 0, 1, 1], | 2864 'archiveVersion': [0, int, 0, 1, 1], |
| 2865 'classes': [0, dict, 0, 1, {}], | 2865 'classes': [0, dict, 0, 1, {}], |
| 2866 'objectVersion': [0, int, 0, 1, 45], | 2866 'objectVersion': [0, int, 0, 1, 46], |
| 2867 'rootObject': [0, PBXProject, 1, 1], | 2867 'rootObject': [0, PBXProject, 1, 1], |
| 2868 }) | 2868 }) |
| 2869 | 2869 |
| 2870 def SetXcodeVersion(self, version): | |
| 2871 version_to_object_version = { | |
| 2872 '2.4': 45, | |
| 2873 '3.0': 45, | |
| 2874 '3.1': 45, | |
| 2875 '3.2': 46, | |
| 2876 } | |
| 2877 if not version in version_to_object_version: | |
| 2878 supported_str = ', '.join(sorted(version_to_object_version.keys())) | |
| 2879 raise Exception( | |
| 2880 'Unsupported Xcode version %s (supported: %s)' % | |
| 2881 ( version, supported_str ) ) | |
| 2882 compatibility_version = 'Xcode %s' % version | |
| 2883 self._properties['rootObject'].SetProperty('compatibilityVersion', | |
| 2884 compatibility_version) | |
| 2885 self.SetProperty('objectVersion', version_to_object_version[version]); | |
| 2886 | |
| 2887 def ComputeIDs(self, recursive=True, overwrite=True, hash=None): | 2870 def ComputeIDs(self, recursive=True, overwrite=True, hash=None): |
| 2888 # Although XCProjectFile is implemented here as an XCObject, it's not a | 2871 # Although XCProjectFile is implemented here as an XCObject, it's not a |
| 2889 # proper object in the Xcode sense, and it certainly doesn't have its own | 2872 # proper object in the Xcode sense, and it certainly doesn't have its own |
| 2890 # ID. Pass through an attempt to update IDs to the real root object. | 2873 # ID. Pass through an attempt to update IDs to the real root object. |
| 2891 if recursive: | 2874 if recursive: |
| 2892 self._properties['rootObject'].ComputeIDs(recursive, overwrite, hash) | 2875 self._properties['rootObject'].ComputeIDs(recursive, overwrite, hash) |
| 2893 | 2876 |
| 2894 def Print(self, file=sys.stdout): | 2877 def Print(self, file=sys.stdout): |
| 2895 self.VerifyHasRequiredProperties() | 2878 self.VerifyHasRequiredProperties() |
| 2896 | 2879 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2932 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') | 2915 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') |
| 2933 for object in sorted(objects_by_class[class_name], | 2916 for object in sorted(objects_by_class[class_name], |
| 2934 cmp=lambda x, y: cmp(x.id, y.id)): | 2917 cmp=lambda x, y: cmp(x.id, y.id)): |
| 2935 object.Print(file) | 2918 object.Print(file) |
| 2936 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') | 2919 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') |
| 2937 | 2920 |
| 2938 if self._should_print_single_line: | 2921 if self._should_print_single_line: |
| 2939 self._XCPrint(file, 0, '}; ') | 2922 self._XCPrint(file, 0, '}; ') |
| 2940 else: | 2923 else: |
| 2941 self._XCPrint(file, 1, '};\n') | 2924 self._XCPrint(file, 1, '};\n') |
| OLD | NEW |