LEFT | RIGHT |
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 hash = seed_hash.copy() | 428 hash = seed_hash.copy() |
429 | 429 |
430 hashables = self.Hashables() | 430 hashables = self.Hashables() |
431 assert len(hashables) > 0 | 431 assert len(hashables) > 0 |
432 for hashable in hashables: | 432 for hashable in hashables: |
433 _HashUpdate(hash, hashable) | 433 _HashUpdate(hash, hashable) |
434 | 434 |
435 if recursive: | 435 if recursive: |
436 hashables_for_child = self.HashablesForChild() | 436 hashables_for_child = self.HashablesForChild() |
437 if hashables_for_child is None: | 437 if hashables_for_child is None: |
438 child_hash = hash.copy() | 438 child_hash = hash |
439 else: | 439 else: |
440 assert len(hashables_for_child) > 0 | 440 assert len(hashables_for_child) > 0 |
441 child_hash = seed_hash.copy() | 441 child_hash = seed_hash.copy() |
442 for hashable in hashables_for_child: | 442 for hashable in hashables_for_child: |
443 _HashUpdate(child_hash, hashable) | 443 _HashUpdate(child_hash, hashable) |
444 | 444 |
445 for child in self.Children(): | 445 for child in self.Children(): |
446 child.ComputeIDs(recursive, overwrite, child_hash) | 446 child.ComputeIDs(recursive, overwrite, child_hash) |
447 | 447 |
448 if overwrite or self.id is None: | 448 if overwrite or self.id is None: |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 for child in self._properties.get('children', []): | 1118 for child in self._properties.get('children', []): |
1119 self._AddChildToDicts(child) | 1119 self._AddChildToDicts(child) |
1120 | 1120 |
1121 def Hashables(self): | 1121 def Hashables(self): |
1122 # super | 1122 # super |
1123 hashables = XCHierarchicalElement.Hashables(self) | 1123 hashables = XCHierarchicalElement.Hashables(self) |
1124 | 1124 |
1125 # It is not sufficient to just rely on name and parent to build a unique | 1125 # It is not sufficient to just rely on name and parent to build a unique |
1126 # hashable : a node could have two child PBXGroup sharing a common name. | 1126 # hashable : a node could have two child PBXGroup sharing a common name. |
1127 # To add entropy the hashable is enhanced with the names of all its | 1127 # To add entropy the hashable is enhanced with the names of all its |
1128 # children. | 1128 # children. |
1129 for child in self._properties.get('children', []): | 1129 for child in self._properties.get('children', []): |
1130 child_name = child.Name() | 1130 child_name = child.Name() |
1131 if child_name != None: | 1131 if child_name != None: |
1132 hashables.append(child_name) | 1132 hashables.append(child_name) |
1133 | 1133 |
1134 return hashables | 1134 return hashables |
1135 | 1135 |
1136 def HashablesForChild(self): | 1136 def HashablesForChild(self): |
1137 # To avoid a circular reference the hashables used to compute a child id do | 1137 # To avoid a circular reference the hashables used to compute a child id do |
1138 # not include the child names. | 1138 # not include the child names. |
(...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') | 2859 self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') |
2860 for object in sorted(objects_by_class[class_name], | 2860 for object in sorted(objects_by_class[class_name], |
2861 cmp=lambda x, y: cmp(x.id, y.id)): | 2861 cmp=lambda x, y: cmp(x.id, y.id)): |
2862 object.Print(file) | 2862 object.Print(file) |
2863 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') | 2863 self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') |
2864 | 2864 |
2865 if self._should_print_single_line: | 2865 if self._should_print_single_line: |
2866 self._XCPrint(file, 0, '}; ') | 2866 self._XCPrint(file, 0, '}; ') |
2867 else: | 2867 else: |
2868 self._XCPrint(file, 1, '};\n') | 2868 self._XCPrint(file, 1, '};\n') |
LEFT | RIGHT |