// The same file can be referred to by more than one project path. private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference) { path = Utils.FixSlashesInPath(path); projectPath = Utils.FixSlashesInPath(projectPath); if (!isFolderReference && Path.GetExtension(path) != Path.GetExtension(projectPath)) { throw new Exception("Project and real path extensions do not match"); } string guid = FindFileGuidByProjectPath(projectPath); if (guid == null) { guid = FindFileGuidByRealPath(path); } if (guid == null) { PBXFileReferenceData fileRef; if (isFolderReference) { fileRef = PBXFileReferenceData.CreateFromFolderReference(path, Utils.GetFilenameFromPath(projectPath), tree); } else { fileRef = PBXFileReferenceData.CreateFromFile(path, Utils.GetFilenameFromPath(projectPath), tree); } PBXGroupData parent = CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)); parent.children.AddGUID(fileRef.guid); FileRefsAdd(path, projectPath, parent, fileRef); guid = fileRef.guid; } return(guid); }
private void RemoveGroupChildrenRecursive(PBXGroupData parent) { List <string> children = new List <string>(parent.children); parent.children.Clear(); foreach (string guid in children) { PBXFileReferenceData file = FileRefsGet(guid); if (file != null) { foreach (var target in nativeTargets.GetEntries()) { RemoveFileFromBuild(target.Value.guid, guid); } FileRefsRemove(guid); continue; } PBXGroupData gr = GroupsGet(guid); if (gr != null) { RemoveGroupChildrenRecursive(gr); GroupsRemove(gr.guid); continue; } } }
void RefreshMapsForGroupChildren(string projectPath, string realPath, PBXSourceTree realPathTree, PBXGroupData parent) { var children = new List <string>(parent.children); foreach (string guid in children) { PBXFileReferenceData fileRef = fileRefs[guid]; string pPath; string rPath; PBXSourceTree rTree; if (fileRef != null) { pPath = Utils.CombinePaths(projectPath, fileRef.name); Utils.CombinePaths(realPath, realPathTree, fileRef.path, fileRef.tree, out rPath, out rTree); if (!m_ProjectPathToFileRefMap.ContainsKey(pPath)) { m_ProjectPathToFileRefMap.Add(pPath, fileRef); } if (!m_FileRefGuidToProjectPathMap.ContainsKey(fileRef.guid)) { m_FileRefGuidToProjectPathMap.Add(fileRef.guid, pPath); } if (!m_RealPathToFileRefMap[rTree].ContainsKey(rPath)) { m_RealPathToFileRefMap[rTree].Add(rPath, fileRef); } if (!m_GuidToParentGroupMap.ContainsKey(guid)) { m_GuidToParentGroupMap.Add(guid, parent); } continue; } PBXGroupData gr = groups[guid]; if (gr != null) { pPath = Utils.CombinePaths(projectPath, gr.name); Utils.CombinePaths(realPath, realPathTree, gr.path, gr.tree, out rPath, out rTree); if (!m_ProjectPathToGroupMap.ContainsKey(pPath)) { m_ProjectPathToGroupMap.Add(pPath, gr); } if (!m_GroupGuidToProjectPathMap.ContainsKey(gr.guid)) { m_GroupGuidToProjectPathMap.Add(gr.guid, pPath); } if (!m_GuidToParentGroupMap.ContainsKey(guid)) { m_GuidToParentGroupMap.Add(guid, parent); } RefreshMapsForGroupChildren(pPath, rPath, rTree, gr); } } }
public void FileRefsRemove(string guid) { PBXFileReferenceData fileRef = fileRefs[guid]; fileRefs.RemoveEntry(guid); m_ProjectPathToFileRefMap.Remove(m_FileRefGuidToProjectPathMap[guid]); m_FileRefGuidToProjectPathMap.Remove(guid); foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees()) { m_RealPathToFileRefMap[tree].Remove(fileRef.path); } m_GuidToParentGroupMap.Remove(guid); }
public static PBXFileReferenceData CreateFromFile(string path, string projectFileName, PBXSourceTree tree) { string guid = PBXGUID.Generate(); PBXFileReferenceData fileRef = new PBXFileReferenceData(); fileRef.SetPropertyString("isa", "PBXFileReference"); fileRef.guid = guid; fileRef.path = path; fileRef.name = projectFileName; fileRef.tree = tree; return(fileRef); }
private void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags) { PBXNativeTargetData target = nativeTargets[targetGuid]; PBXFileReferenceData fileRef = FileRefsGet(fileGuid); string ext = Path.GetExtension(fileRef.path); if (FileTypeUtils.IsBuildable(ext, fileRef.isFolderReference) && BuildFilesGetForSourceFile(targetGuid, fileGuid) == null) { PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(fileGuid, weak, compileFlags); BuildFilesAdd(targetGuid, buildFile); BuildSectionAny(target, ext, fileRef.isFolderReference).files.AddGUID(buildFile.guid); } }
// sourceTree must not be PBXSourceTree.Group public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree) { if (sourceTree == PBXSourceTree.Group) throw new Exception("sourceTree must not be PBXSourceTree.Group"); path = Utils.FixSlashesInPath(path); projectPath = Utils.FixSlashesInPath(projectPath); // note: we are duplicating products group for the project reference. Otherwise Xcode crashes. PBXGroupData productGroup = PBXGroupData.CreateRelative("Products"); GroupsAddDuplicate(productGroup); // don't use GroupsAdd here PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree); FileRefsAdd(path, projectPath, null, fileRef); CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)).children.AddGUID(fileRef.guid); project.project.AddReference(productGroup.guid, fileRef.guid); }
void FileRefsAdd(string realPath, string projectPath, PBXGroupData parent, PBXFileReferenceData fileRef) { m_Data.FileRefsAdd(realPath, projectPath, parent, fileRef); }
public void FileRefsAdd(string realPath, string projectPath, PBXGroupData parent, PBXFileReferenceData fileRef) { fileRefs.AddEntry(fileRef); m_ProjectPathToFileRefMap.Add(projectPath, fileRef); m_FileRefGuidToProjectPathMap.Add(fileRef.guid, projectPath); m_RealPathToFileRefMap[fileRef.tree].Add(realPath, fileRef); // FIXME m_GuidToParentGroupMap.Add(fileRef.guid, parent); }