Ejemplo n.º 1
0
        public string FindFileGuidByRealPath(string path)
        {
            path = Utils.FixSlashesInPath(path);

            foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees())
            {
                string res = FindFileGuidByRealPath(path, tree);
                if (res != null)
                    return res;
            }
            return null;
        }
Ejemplo n.º 2
0
        public override void UpdateProps()
        {
            string ext = null;

            if (m_ExplicitFileType != null)
            {
                SetPropertyString("explicitFileType", m_ExplicitFileType);
            }
            else if (m_LastKnownFileType != null)
            {
                SetPropertyString("lastKnownFileType", m_LastKnownFileType);
            }
            else
            {
                if (name != null)
                {
                    ext = Path.GetExtension(name);
                }
                else if (m_Path != null)
                {
                    ext = Path.GetExtension(m_Path);
                }
                if (ext != null)
                {
                    if (FileTypeUtils.IsFileTypeExplicit(ext))
                    {
                        SetPropertyString("explicitFileType", FileTypeUtils.GetTypeName(ext));
                    }
                    else
                    {
                        SetPropertyString("lastKnownFileType", FileTypeUtils.GetTypeName(ext));
                    }
                }
            }
            if (m_Path == name)
            {
                SetPropertyString("name", null);
            }
            else
            {
                SetPropertyString("name", name);
            }
            if (m_Path == null)
            {
                SetPropertyString("path", "");
            }
            else
            {
                SetPropertyString("path", m_Path);
            }
            SetPropertyString("sourceTree", FileTypeUtils.SourceTreeDesc(tree));
        }
Ejemplo n.º 3
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.º 4
0
        public FileGUIDListBase BuildSectionAny(PBXNativeTargetData target, string path, bool isFolderRef)
        {
            string ext   = Path.GetExtension(path);
            var    phase = FileTypeUtils.GetFileType(ext, isFolderRef);

            switch (phase)
            {
            case PBXFileType.Framework:
                foreach (var guid in target.phases)
                {
                    if (frameworks.HasEntry(guid))
                    {
                        return(frameworks[guid]);
                    }
                }
                break;

            case PBXFileType.Resource:
                foreach (var guid in target.phases)
                {
                    if (resources.HasEntry(guid))
                    {
                        return(resources[guid]);
                    }
                }
                break;

            case PBXFileType.Source:
                foreach (var guid in target.phases)
                {
                    if (sources.HasEntry(guid))
                    {
                        return(sources[guid]);
                    }
                }
                break;

            case PBXFileType.CopyFile:
                foreach (var guid in target.phases)
                {
                    if (copyFiles.HasEntry(guid))
                    {
                        return(copyFiles[guid]);
                    }
                }
                break;
            }
            return(null);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 public override void UpdateVars()
 {
     children = GetPropertyList("children");
     path     = GetPropertyString("path");
     name     = GetPropertyString("name");
     if (name == null)
     {
         name = path;
     }
     if (path == null)
     {
         path = "";
     }
     tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree"));
 }
Ejemplo n.º 7
0
        /** This function must be called only after the project the library is in has
            been added as a dependency via AddExternalProjectDependency. projectPath must be
            the same as the 'path' parameter passed to the AddExternalProjectDependency.
            remoteFileGuid must be the guid of the referenced file as specified in
            PBXFileReference section of the external project

            TODO: what. is remoteInfo entry in PBXContainerItemProxy? Is in referenced project name or
            referenced library name without extension?
        */
        public void AddExternalLibraryDependency(string targetGuid, string filename, string remoteFileGuid, string projectPath,
                                                 string remoteInfo)
        {
            PBXNativeTargetData target = nativeTargets[targetGuid];
            filename = Utils.FixSlashesInPath(filename);
            projectPath = Utils.FixSlashesInPath(projectPath);

            // find the products group to put the new library in
            string projectGuid = FindFileGuidByRealPath(projectPath);
            if (projectGuid == null)
                throw new Exception("No such project");

            string productsGroupGuid = null;
            foreach (var proj in project.project.projectReferences)
            {
                if (proj.projectRef == projectGuid)
                {
                    productsGroupGuid = proj.group;
                    break;
                }
            }

            if (productsGroupGuid == null)
                throw new Exception("Malformed project: no project in project references");

            PBXGroupData productGroup = GroupsGet(productsGroupGuid);

            // verify file extension
            string ext = Path.GetExtension(filename);
            if (!FileTypeUtils.IsBuildableFile(ext))
                throw new Exception("Wrong file extension");

            // create ContainerItemProxy object
            var container = PBXContainerItemProxyData.Create(projectGuid, "2", remoteFileGuid, remoteInfo);
            containerItems.AddEntry(container);

            // create a reference and build file for the library
            string typeName = FileTypeUtils.GetTypeName(ext);

            var libRef = PBXReferenceProxyData.Create(filename, typeName, container.guid, "BUILT_PRODUCTS_DIR");
            references.AddEntry(libRef);
            PBXBuildFileData libBuildFile = PBXBuildFileData.CreateFromFile(libRef.guid, false, null);
            BuildFilesAdd(targetGuid, libBuildFile);
            BuildSectionAny(target, ext, false).files.AddGUID(libBuildFile.guid);

            // add to products folder
            productGroup.children.AddGUID(libRef.guid);
        }
Ejemplo n.º 8
0
 public override void UpdateVars()
 {
     name   = GetPropertyString("name");
     m_Path = GetPropertyString("path");
     if (name == null)
     {
         name = m_Path;
     }
     if (m_Path == null)
     {
         m_Path = "";
     }
     tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree"));
     m_ExplicitFileType  = GetPropertyString("explicitFileType");
     m_LastKnownFileType = GetPropertyString("lastKnownFileType");
 }
Ejemplo n.º 9
0
 public override void UpdateProps()
 {
     // The name property is set only if it is different from the path property
     SetPropertyList("children", children);
     if (name == path)
     {
         SetPropertyString("name", null);
     }
     else
     {
         SetPropertyString("name", name);
     }
     if (path == "")
     {
         SetPropertyString("path", null);
     }
     else
     {
         SetPropertyString("path", path);
     }
     SetPropertyString("sourceTree", FileTypeUtils.SourceTreeDesc(tree));
 }
Ejemplo n.º 10
0
 public static bool IsBuildable(string ext)
 {
     return(FileTypeUtils.IsBuildableFile(ext));
 }
Ejemplo n.º 11
0
 public static bool IsKnownExtension(string ext)
 {
     return(FileTypeUtils.IsKnownExtension(ext));
 }
Ejemplo n.º 12
0
        public void Clear()
        {
            buildFiles         = new PBXBuildFileSection("PBXBuildFile");
            fileRefs           = new PBXFileReferenceSection("PBXFileReference");
            groups             = new PBXGroupSection("PBXGroup");
            containerItems     = new PBXContainerItemProxySection("PBXContainerItemProxy");
            references         = new PBXReferenceProxySection("PBXReferenceProxy");
            sources            = new PBXSourcesBuildPhaseSection("PBXSourcesBuildPhase");
            frameworks         = new PBXFrameworksBuildPhaseSection("PBXFrameworksBuildPhase");
            resources          = new PBXResourcesBuildPhaseSection("PBXResourcesBuildPhase");
            copyFiles          = new PBXCopyFilesBuildPhaseSection("PBXCopyFilesBuildPhase");
            embedFrameworks    = new PBXCopyFilesBuildPhaseSection("PBXCopyFilesBuildPhase");
            shellScripts       = new PBXShellScriptBuildPhaseSection("PBXShellScriptBuildPhase");
            nativeTargets      = new PBXNativeTargetSection("PBXNativeTarget");
            targetDependencies = new PBXTargetDependencySection("PBXTargetDependency");
            variantGroups      = new PBXVariantGroupSection("PBXVariantGroup");
            buildConfigs       = new XCBuildConfigurationSection("XCBuildConfiguration");
            configs            = new XCConfigurationListSection("XCConfigurationList");
            project            = new PBXProjectSection();
            m_UnknownSections  = new Dictionary <string, UnknownSection>();

            m_Section = new Dictionary <string, SectionBase>
            {
                { "PBXBuildFile", buildFiles },
                { "PBXFileReference", fileRefs },
                { "PBXGroup", groups },
                { "PBXContainerItemProxy", containerItems },
                { "PBXReferenceProxy", references },
                { "PBXSourcesBuildPhase", sources },
                { "PBXFrameworksBuildPhase", frameworks },
                { "PBXResourcesBuildPhase", resources },
                { "PBXCopyFilesBuildPhase", copyFiles },
                { "PBXEmbedFrameworksBuildPhase", embedFrameworks },
                { "PBXShellScriptBuildPhase", shellScripts },
                { "PBXNativeTarget", nativeTargets },
                { "PBXTargetDependency", targetDependencies },
                { "PBXVariantGroup", variantGroups },
                { "XCBuildConfiguration", buildConfigs },
                { "XCConfigurationList", configs },

                { "PBXProject", project },
            };
            m_RootElements   = new PBXElementDict();
            m_UnknownObjects = new PBXElementDict();
            m_ObjectVersion  = null;
            m_SectionOrder   = new List <string> {
                "PBXBuildFile", "PBXContainerItemProxy", "PBXEmbedFrameworksBuildPhase", "PBXCopyFilesBuildPhase", "PBXFileReference",
                "PBXFrameworksBuildPhase", "PBXGroup", "PBXNativeTarget", "PBXProject", "PBXReferenceProxy",
                "PBXResourcesBuildPhase", "PBXShellScriptBuildPhase", "PBXSourcesBuildPhase", "PBXTargetDependency",
                "PBXVariantGroup", "XCBuildConfiguration", "XCConfigurationList"
            };
            m_FileGuidToBuildFileMap      = new Dictionary <string, Dictionary <string, PBXBuildFileData> >();
            m_ProjectPathToFileRefMap     = new Dictionary <string, PBXFileReferenceData>();
            m_FileRefGuidToProjectPathMap = new Dictionary <string, string>();
            m_RealPathToFileRefMap        = new Dictionary <PBXSourceTree, Dictionary <string, PBXFileReferenceData> >();
            foreach (var tree in FileTypeUtils.AllAbsoluteSourceTrees())
            {
                m_RealPathToFileRefMap.Add(tree, new Dictionary <string, PBXFileReferenceData>());
            }
            m_ProjectPathToGroupMap     = new Dictionary <string, PBXGroupData>();
            m_GroupGuidToProjectPathMap = new Dictionary <string, string>();
            m_GuidToParentGroupMap      = new Dictionary <string, PBXGroupData>();
        }