Exemplo n.º 1
0
        public static PBXElementDict ParseTreeAST(TreeAST ast, TokenList tokens, string text)
        {
            var el = new PBXElementDict();

            foreach (var kv in ast.values)
            {
                PBXElementString key   = ParseIdentifierAST(kv.key, tokens, text);
                PBXElement       value = ParseValueAST(kv.value, tokens, text);
                el[key.value] = value;
            }
            return(el);
        }
Exemplo n.º 2
0
        public static PBXBuildFileData CreateFromFramework(string fileRefGUID)
        {
            PBXBuildFileData buildFile = new PBXBuildFileData();

            buildFile.guid = PBXGUID.Generate();
            buildFile.SetPropertyString("isa", "PBXBuildFile");
            buildFile.fileRef = fileRefGUID;
            PBXElementDict  settingsDict = new PBXElementDict();
            PBXElementArray elementArray = new PBXElementArray();

            elementArray.AddString("CodeSignOnCopy");
            elementArray.AddString("RemoveHeadersOnCopy");
            settingsDict["ATTRIBUTES"]         = elementArray;
            buildFile.m_Properties["settings"] = settingsDict;
            buildFile.assetTags = new List <string>();
            return(buildFile);
        }
Exemplo n.º 3
0
        public void ReadFromStream(TextReader sr)
        {
            Clear();
            m_RootElements = ParseContent(sr.ReadToEnd());

            if (!m_RootElements.Contains("objects"))
            {
                throw new Exception("Invalid PBX project file: no objects element");
            }

            var objects = m_RootElements["objects"].AsDict();

            m_RootElements.Remove("objects");
            m_RootElements.SetString("objects", "OBJMARKER");

            if (m_RootElements.Contains("objectVersion"))
            {
                m_ObjectVersion = m_RootElements["objectVersion"].AsString();
                m_RootElements.Remove("objectVersion");
            }

            var    allGuids        = new List <string>();
            string prevSectionName = null;

            foreach (var kv in objects.values)
            {
                allGuids.Add(kv.Key);
                var el = kv.Value;

                if (!(el is PBXElementDict) || !el.AsDict().Contains("isa"))
                {
                    m_UnknownObjects.values.Add(kv.Key, el);
                    continue;
                }
                var dict        = el.AsDict();
                var sectionName = dict["isa"].AsString();

                if (m_Section.ContainsKey(sectionName))
                {
                    var section = m_Section[sectionName];
                    section.AddObject(kv.Key, dict);
                }
                else
                {
                    UnknownSection section;
                    if (m_UnknownSections.ContainsKey(sectionName))
                    {
                        section = m_UnknownSections[sectionName];
                    }
                    else
                    {
                        section = new UnknownSection(sectionName);
                        m_UnknownSections.Add(sectionName, section);
                    }
                    section.AddObject(kv.Key, dict);

                    // update section order
                    if (!m_SectionOrder.Contains(sectionName))
                    {
                        int pos = 0;
                        if (prevSectionName != null)
                        {
                            // this never fails, because we already added any previous unknown sections
                            // to m_SectionOrder
                            pos  = m_SectionOrder.FindIndex(x => x == prevSectionName);
                            pos += 1;
                        }
                        m_SectionOrder.Insert(pos, sectionName);
                    }
                }
                prevSectionName = sectionName;
            }
            RepairStructure(allGuids);
            RefreshAuxMaps();
        }
Exemplo n.º 4
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>();
        }
Exemplo n.º 5
0
 public abstract void AddObject(string key, PBXElementDict value);
Exemplo n.º 6
0
        public override void UpdateProps()
        {
            SetPropertyString("fileRef", fileRef);

            PBXElementDict settings = null;

            if (m_Properties.Contains("settings"))
            {
                settings = m_Properties["settings"].AsDict();
            }

            if (compileFlags != null && compileFlags != "")
            {
                if (settings == null)
                {
                    settings = m_Properties.CreateDict("settings");
                }
                settings.SetString("COMPILER_FLAGS", compileFlags);
            }
            else
            {
                if (settings != null)
                {
                    settings.Remove("COMPILER_FLAGS");
                }
            }

            if (weak)
            {
                if (settings == null)
                {
                    settings = m_Properties.CreateDict("settings");
                }
                PBXElementArray attrs = null;
                if (settings.Contains("ATTRIBUTES"))
                {
                    attrs = settings["ATTRIBUTES"].AsArray();
                }
                else
                {
                    attrs = settings.CreateArray("ATTRIBUTES");
                }

                bool exists = false;
                foreach (var value in attrs.values)
                {
                    if (value is PBXElementString && value.AsString() == "Weak")
                    {
                        exists = true;
                    }
                }
                if (!exists)
                {
                    attrs.AddString("Weak");
                }
            }
            else
            {
                if (settings != null && settings.Contains("ATTRIBUTES"))
                {
                    var attrs = settings["ATTRIBUTES"].AsArray();
                    attrs.values.RemoveAll(el => (el is PBXElementString && el.AsString() == "Weak"));
                    if (attrs.values.Count == 0)
                    {
                        settings.Remove("ATTRIBUTES");
                    }
                }
            }

            if (assetTags.Count > 0)
            {
                if (settings == null)
                {
                    settings = m_Properties.CreateDict("settings");
                }
                var tagsArray = settings.CreateArray("ASSET_TAGS");
                foreach (string tag in assetTags)
                {
                    tagsArray.AddString(tag);
                }
            }
            else
            {
                if (settings != null)
                {
                    settings.Remove("ASSET_TAGS");
                }
            }

            if (settings != null && settings.values.Count == 0)
            {
                m_Properties.Remove("settings");
            }
        }
Exemplo n.º 7
0
 internal void SetPropertiesWhenSerializing(PBXElementDict props)
 {
     m_Properties = props;
 }