Ejemplo n.º 1
0
        // 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);
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
        private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference)
        {
            PBXFileReferenceData data;

            path        = PBXPath.FixSlashes(path);
            projectPath = PBXPath.FixSlashes(projectPath);
            if (!isFolderReference && (Path.GetExtension(path) != Path.GetExtension(projectPath)))
            {
                throw new Exception("Project and real path extensions do not match");
            }
            string str = this.FindFileGuidByProjectPath(projectPath);

            if (str == null)
            {
                str = this.FindFileGuidByRealPath(path);
            }
            if (str != null)
            {
                return(str);
            }
            if (isFolderReference)
            {
                data = PBXFileReferenceData.CreateFromFolderReference(path, PBXPath.GetFilename(projectPath), tree);
            }
            else
            {
                data = PBXFileReferenceData.CreateFromFile(path, PBXPath.GetFilename(projectPath), tree);
            }
            PBXGroupData parent = this.CreateSourceGroup(PBXPath.GetDirectory(projectPath));

            parent.children.AddGUID(data.guid);
            this.FileRefsAdd(path, projectPath, parent, data);
            return(data.guid);
        }
Ejemplo n.º 4
0
        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 = PBXPath.Combine(projectPath, fileRef.name);
                    PBXPath.Combine(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 = PBXPath.Combine(projectPath, gr.name);
                    PBXPath.Combine(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);
                }
            }
        }
Ejemplo n.º 5
0
        public string FindFileGuidByProjectPath(string path)
        {
            path = PBXPath.FixSlashes(path);
            PBXFileReferenceData data = this.FileRefsGetByProjectPath(path);

            if (data != null)
            {
                return(data.guid);
            }
            return(null);
        }
Ejemplo n.º 6
0
 private void RefreshMapsForGroupChildren(string projectPath, string realPath, PBXSourceTree realPathTree, PBXGroupData parent)
 {
     foreach (string key1 in new List <string>((IEnumerable <string>)parent.children))
     {
         PBXFileReferenceData fileReferenceData = this.fileRefs[key1];
         string        resPath;
         PBXSourceTree resTree;
         if (fileReferenceData != null)
         {
             string key2 = PBXPath.Combine(projectPath, fileReferenceData.name);
             PBXPath.Combine(realPath, realPathTree, fileReferenceData.path, fileReferenceData.tree, out resPath, out resTree);
             if (!this.m_ProjectPathToFileRefMap.ContainsKey(key2))
             {
                 this.m_ProjectPathToFileRefMap.Add(key2, fileReferenceData);
             }
             if (!this.m_FileRefGuidToProjectPathMap.ContainsKey(fileReferenceData.guid))
             {
                 this.m_FileRefGuidToProjectPathMap.Add(fileReferenceData.guid, key2);
             }
             if (!this.m_RealPathToFileRefMap[resTree].ContainsKey(resPath))
             {
                 this.m_RealPathToFileRefMap[resTree].Add(resPath, fileReferenceData);
             }
             if (!this.m_GuidToParentGroupMap.ContainsKey(key1))
             {
                 this.m_GuidToParentGroupMap.Add(key1, parent);
             }
         }
         else
         {
             PBXGroupData parent1 = this.groups[key1];
             if (parent1 != null)
             {
                 string str = PBXPath.Combine(projectPath, parent1.name);
                 PBXPath.Combine(realPath, realPathTree, parent1.path, parent1.tree, out resPath, out resTree);
                 if (!this.m_ProjectPathToGroupMap.ContainsKey(str))
                 {
                     this.m_ProjectPathToGroupMap.Add(str, parent1);
                 }
                 if (!this.m_GroupGuidToProjectPathMap.ContainsKey(parent1.guid))
                 {
                     this.m_GroupGuidToProjectPathMap.Add(parent1.guid, str);
                 }
                 if (!this.m_GuidToParentGroupMap.ContainsKey(key1))
                 {
                     this.m_GuidToParentGroupMap.Add(key1, parent);
                 }
                 this.RefreshMapsForGroupChildren(str, resPath, resTree, parent1);
             }
         }
     }
 }
Ejemplo n.º 7
0
        private void AddBuildFileImpl(string targetGuid, string fileGuid, bool weak, string compileFlags)
        {
            PBXNativeTargetData  target = this.nativeTargets[targetGuid];
            PBXFileReferenceData data2  = this.FileRefsGet(fileGuid);
            string extension            = Path.GetExtension(data2.path);

            if (FileTypeUtils.IsBuildable(extension, data2.isFolderReference) && (this.BuildFilesGetForSourceFile(targetGuid, fileGuid) == null))
            {
                PBXBuildFileData buildFile = PBXBuildFileData.CreateFromFile(fileGuid, weak, compileFlags);
                this.BuildFilesAdd(targetGuid, buildFile);
                this.BuildSectionAny(target, extension, data2.isFolderReference).files.AddGUID(buildFile.guid);
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        public void FileRefsRemove(string guid)
        {
            PBXFileReferenceData fileReferenceData = this.fileRefs[guid];

            this.fileRefs.RemoveEntry(guid);
            this.m_ProjectPathToFileRefMap.Remove(this.m_FileRefGuidToProjectPathMap[guid]);
            this.m_FileRefGuidToProjectPathMap.Remove(guid);
            foreach (PBXSourceTree index in FileTypeUtils.AllAbsoluteSourceTrees())
            {
                this.m_RealPathToFileRefMap[index].Remove(fileReferenceData.path);
            }
            this.m_GuidToParentGroupMap.Remove(guid);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path = PBXPath.FixSlashes(path);
            PBXFileReferenceData data = this.FileRefsGetByRealPath(path, sourceTree);

            if (data != null)
            {
                return(data.guid);
            }
            return(null);
        }
Ejemplo n.º 12
0
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path        = PBXPath.FixSlashes(path);
            projectPath = PBXPath.FixSlashes(projectPath);
            PBXGroupData gr = PBXGroupData.CreateRelative("Products");

            this.GroupsAddDuplicate(gr);
            PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree);

            this.FileRefsAdd(path, projectPath, null, fileRef);
            this.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fileRef.guid);
            this.project.project.AddReference(gr.guid, fileRef.guid);
        }
Ejemplo n.º 13
0
        internal static void AddExternalProjectDependency(this PBXProject proj, string path, string projectPath, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path        = PBXPath.FixSlashes(path);
            projectPath = PBXPath.FixSlashes(projectPath);
            PBXGroupData relative = PBXGroupData.CreateRelative("Products");

            proj.GroupsAddDuplicate(relative);
            PBXFileReferenceData fromFile = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree);

            proj.FileRefsAdd(path, projectPath, (PBXGroupData)null, fromFile);
            proj.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fromFile.guid);
            proj.project.project.AddReference(relative.guid, fromFile.guid);
        }
Ejemplo n.º 14
0
        private PBXBuildFileData 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);

                return(buildFile);
            }

            return(null);
        }
Ejemplo n.º 15
0
        internal List <string> GetGroupChildrenFiles(string projectPath)
        {
            projectPath = PBXPath.FixSlashes(projectPath);
            PBXGroupData data = this.GroupsGetByProjectPath(projectPath);

            if (data == null)
            {
                return(null);
            }
            List <string> list2 = new List <string>();

            foreach (string str in (IEnumerable <string>)data.children)
            {
                PBXFileReferenceData data2 = this.FileRefsGet(str);
                if (data2 != null)
                {
                    list2.Add(data2.name);
                }
            }
            return(list2);
        }
Ejemplo n.º 16
0
        // 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);
        }
Ejemplo n.º 17
0
 private void BuildCommentMapForBuildFiles(GUIDToCommentMap comments, List <string> guids, string sectName)
 {
     foreach (string str in guids)
     {
         PBXBuildFileData data = this.BuildFilesGet(str);
         if (data != null)
         {
             PBXFileReferenceData data2 = this.FileRefsGet(data.fileRef);
             if (data2 != null)
             {
                 comments.Add(str, $"{data2.name} in {sectName}");
             }
             else
             {
                 PBXReferenceProxyData data3 = this.references[data.fileRef];
                 if (data3 != null)
                 {
                     comments.Add(str, $"{data3.path} in {sectName}");
                 }
             }
         }
     }
 }
Ejemplo n.º 18
0
 private void BuildCommentMapForBuildFiles(GUIDToCommentMap comments, List <string> guids, string sectName)
 {
     foreach (string guid in guids)
     {
         PBXBuildFileData pbxBuildFileData = this.BuildFilesGet(guid);
         if (pbxBuildFileData != null)
         {
             PBXFileReferenceData fileReferenceData = this.FileRefsGet(pbxBuildFileData.fileRef);
             if (fileReferenceData != null)
             {
                 comments.Add(guid, string.Format("{0} in {1}", (object)fileReferenceData.name, (object)sectName));
             }
             else
             {
                 PBXReferenceProxyData referenceProxyData = this.references[pbxBuildFileData.fileRef];
                 if (referenceProxyData != null)
                 {
                     comments.Add(guid, string.Format("{0} in {1}", (object)referenceProxyData.path, (object)sectName));
                 }
             }
         }
     }
 }
Ejemplo n.º 19
0
 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);
 }
Ejemplo n.º 20
0
 public void FileRefsAdd(string realPath, string projectPath, PBXVariantGroupData parent, PBXFileReferenceData fileRef)
 {
     fileRefs.AddEntry(fileRef);
     m_ProjectPathToFileRefMap.Add(projectPath, fileRef);
     m_FileRefGuidToProjectPathMap.Add(fileRef.guid, projectPath);
     if (!m_RealPathToFileRefMap.ContainsKey(fileRef.tree))
     {
         m_RealPathToFileRefMap[fileRef.tree] = new Dictionary <string, PBXFileReferenceData>();
     }
     m_RealPathToFileRefMap[fileRef.tree].Add(realPath, fileRef);
     m_GuidToParentVariantGroupMap.Add(fileRef.guid, parent);
 }
Ejemplo n.º 21
0
 void FileRefsAdd(string realPath, string projectPath, PBXGroupData parent, PBXFileReferenceData fileRef)
 {
     m_Data.FileRefsAdd(realPath, projectPath, parent, fileRef);
 }
Ejemplo n.º 22
0
 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);
     if (m_RealPathToFileRefMap.TryGetValue(fileRef.tree, out var fileRefMap))
     {
         fileRefMap.Add(realPath, fileRef); // FIXME
     }
     m_GuidToParentGroupMap.Add(fileRef.guid, parent);
 }
Ejemplo n.º 23
0
 void FileRefsAdd(string realPath, string projectPath, PBXGroupData parent, PBXFileReferenceData fileRef)
 {
     m_Data.FileRefsAdd(realPath, projectPath, parent, fileRef);
 }