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

Method AddOrGetProjectReference

tools/gyp/pylib/gyp/xcodeproj_file.py:2918–2998  ·  view source on GitHub ↗

Add a reference to another project file (via PBXProject object) to this one. Returns [ProductGroup, ProjectRef]. ProductGroup is a PBXGroup object in this project file that contains a PBXReferenceProxy object for each product of each PBXNativeTarget in the other pro

(self, other_pbxproject)

Source from the content-addressed store, hash-verified

2916 group.SortGroup()
2917
2918 def AddOrGetProjectReference(self, other_pbxproject):
2919 """Add a reference to another project file (via PBXProject object) to this
2920 one.
2921
2922 Returns [ProductGroup, ProjectRef]. ProductGroup is a PBXGroup object in
2923 this project file that contains a PBXReferenceProxy object for each
2924 product of each PBXNativeTarget in the other project file. ProjectRef is
2925 a PBXFileReference to the other project file.
2926
2927 If this project file already references the other project file, the
2928 existing ProductGroup and ProjectRef are returned. The ProductGroup will
2929 still be updated if necessary.
2930 """
2931
2932 if "projectReferences" not in self._properties:
2933 self._properties["projectReferences"] = []
2934
2935 product_group = None
2936 project_ref = None
2937
2938 if other_pbxproject not in self._other_pbxprojects:
2939 # This project file isn't yet linked to the other one. Establish the
2940 # link.
2941 product_group = PBXGroup({"name": "Products"})
2942
2943 # ProductGroup is strong.
2944 product_group.parent = self
2945
2946 # There's nothing unique about this PBXGroup, and if left alone, it will
2947 # wind up with the same set of hashables as all other PBXGroup objects
2948 # owned by the projectReferences list. Add the hashables of the
2949 # remote PBXProject that it's related to.
2950 product_group._hashables.extend(other_pbxproject.Hashables())
2951
2952 # The other project reports its path as relative to the same directory
2953 # that this project's path is relative to. The other project's path
2954 # is not necessarily already relative to this project. Figure out the
2955 # pathname that this project needs to use to refer to the other one.
2956 this_path = posixpath.dirname(self.Path())
2957 projectDirPath = self.GetProperty("projectDirPath")
2958 if projectDirPath:
2959 if posixpath.isabs(projectDirPath[0]):
2960 this_path = projectDirPath
2961 else:
2962 this_path = posixpath.join(this_path, projectDirPath)
2963 other_path = gyp.common.RelativePath(other_pbxproject.Path(), this_path)
2964
2965 # ProjectRef is weak (it's owned by the mainGroup hierarchy).
2966 project_ref = PBXFileReference(
2967 {
2968 "lastKnownFileType": "wrapper.pb-project",
2969 "path": other_path,
2970 "sourceTree": "SOURCE_ROOT",
2971 }
2972 )
2973 self.ProjectsGroup().AppendChild(project_ref)
2974
2975 ref_dict = {"ProductGroup": product_group, "ProjectRef": project_ref}

Callers 3

AddDependencyMethod · 0.80
AddDependencyMethod · 0.80
Finalize2Method · 0.80

Calls 14

PathMethod · 0.95
ProjectsGroupMethod · 0.95
_AllSymrootsUniqueMethod · 0.95
PBXGroupClass · 0.85
PBXFileReferenceClass · 0.85
sortedFunction · 0.85
GetPropertyMethod · 0.80
AppendPropertyMethod · 0.80
extendMethod · 0.45
HashablesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected