MCPcopy Create free account
hub / github.com/nodejs/node / SortGroups

Method SortGroups

tools/gyp/pylib/gyp/xcodeproj_file.py:2882–2916  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2880 group.TakeOverOnlyChild(recurse)
2881
2882 def SortGroups(self):
2883 # Sort the children of the mainGroup (like "Source" and "Products")
2884 # according to their defined order.
2885 self._properties["mainGroup"]._properties["children"] = sorted(
2886 self._properties["mainGroup"]._properties["children"],
2887 key=cmp_to_key(lambda x, y: x.CompareRootGroup(y)),
2888 )
2889
2890 # Sort everything else by putting group before files, and going
2891 # alphabetically by name within sections of groups and files. SortGroup
2892 # is recursive.
2893 for group in self._properties["mainGroup"]._properties["children"]:
2894 if not isinstance(group, PBXGroup):
2895 continue
2896
2897 if group.Name() == "Products":
2898 # The Products group is a special case. Instead of sorting
2899 # alphabetically, sort things in the order of the targets that
2900 # produce the products. To do this, just build up a new list of
2901 # products based on the targets.
2902 products = []
2903 for target in self._properties["targets"]:
2904 if not isinstance(target, PBXNativeTarget):
2905 continue
2906 product = target._properties["productReference"]
2907 # Make sure that the product is already in the products group.
2908 assert product in group._properties["children"]
2909 products.append(product)
2910
2911 # Make sure that this process doesn't miss anything that was already
2912 # in the products group.
2913 assert len(products) == len(group._properties["children"])
2914 group._properties["children"] = products
2915 else:
2916 group.SortGroup()
2917
2918 def AddOrGetProjectReference(self, other_pbxproject):
2919 """Add a reference to another project file (via PBXProject object) to this

Callers 1

Finalize1Method · 0.80

Calls 5

sortedFunction · 0.85
CompareRootGroupMethod · 0.80
SortGroupMethod · 0.80
NameMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected