Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. If path is specified, then it is the path that is being added to the phase, and pbxbuildfile must contain either a PBXFileReference directly referencing that path, or it must contain a PBXVariantGroup that i
(self, pbxbuildfile, path=None)
| 1886 | self._files_by_path[path] = pbxbuildfile |
| 1887 | |
| 1888 | def _AddBuildFileToDicts(self, pbxbuildfile, path=None): |
| 1889 | """Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. |
| 1890 | |
| 1891 | If path is specified, then it is the path that is being added to the |
| 1892 | phase, and pbxbuildfile must contain either a PBXFileReference directly |
| 1893 | referencing that path, or it must contain a PBXVariantGroup that itself |
| 1894 | contains a PBXFileReference referencing the path. |
| 1895 | |
| 1896 | If path is not specified, either the PBXFileReference's path or the paths |
| 1897 | of all children of the PBXVariantGroup are taken as being added to the |
| 1898 | phase. |
| 1899 | |
| 1900 | If the path is already present in the phase, raises an exception. |
| 1901 | |
| 1902 | If the PBXFileReference or PBXVariantGroup referenced by pbxbuildfile |
| 1903 | are already present in the phase, referenced by a different PBXBuildFile |
| 1904 | object, raises an exception. This does not raise an exception when |
| 1905 | a PBXFileReference or PBXVariantGroup reappear and are referenced by the |
| 1906 | same PBXBuildFile that has already introduced them, because in the case |
| 1907 | of PBXVariantGroup objects, they may correspond to multiple paths that are |
| 1908 | not all added simultaneously. When this situation occurs, the path needs |
| 1909 | to be added to _files_by_path, but nothing needs to change in |
| 1910 | _files_by_xcfilelikeelement, and the caller should have avoided adding |
| 1911 | the PBXBuildFile if it is already present in the list of children. |
| 1912 | """ |
| 1913 | |
| 1914 | xcfilelikeelement = pbxbuildfile._properties["fileRef"] |
| 1915 | |
| 1916 | paths = [] |
| 1917 | if path is not None: |
| 1918 | # It's best when the caller provides the path. |
| 1919 | if isinstance(xcfilelikeelement, PBXVariantGroup): |
| 1920 | paths.append(path) |
| 1921 | # If the caller didn't provide a path, there can be either multiple |
| 1922 | # paths (PBXVariantGroup) or one. |
| 1923 | elif isinstance(xcfilelikeelement, PBXVariantGroup): |
| 1924 | for variant in xcfilelikeelement._properties["children"]: |
| 1925 | paths.append(variant.FullPath()) |
| 1926 | else: |
| 1927 | paths.append(xcfilelikeelement.FullPath()) |
| 1928 | |
| 1929 | # Add the paths first, because if something's going to raise, the |
| 1930 | # messages provided by _AddPathToDict are more useful owing to its |
| 1931 | # having access to a real pathname and not just an object's Name(). |
| 1932 | for a_path in paths: |
| 1933 | self._AddPathToDict(pbxbuildfile, a_path) |
| 1934 | |
| 1935 | # If another PBXBuildFile references this XCFileLikeElement, there's a |
| 1936 | # problem. |
| 1937 | if ( |
| 1938 | xcfilelikeelement in self._files_by_xcfilelikeelement |
| 1939 | and self._files_by_xcfilelikeelement[xcfilelikeelement] != pbxbuildfile |
| 1940 | ): |
| 1941 | raise ValueError( |
| 1942 | "Found multiple build files for " + xcfilelikeelement.Name() |
| 1943 | ) |
| 1944 | self._files_by_xcfilelikeelement[xcfilelikeelement] = pbxbuildfile |
| 1945 |
no test coverage detected