Пример #1
0
        public override void AddObject(string key, PBXElementDict value)
        {
            T obj = new T();

            obj.guid = key;
            obj.SetPropertiesWhenSerializing(value);
            obj.UpdateVars();
            m_Entries[obj.guid] = obj;
        }
Пример #2
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");
                }
            }

            settings = UpdatePropsAttribute(settings, weak, "Weak");
            settings = UpdatePropsAttribute(settings, codeSignOnCopy, "CodeSignOnCopy");
            settings = UpdatePropsAttribute(settings, removeHeadersOnCopy, "RemoveHeadersOnCopy");

            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");
            }
        }
Пример #3
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);
        }
Пример #4
0
        PBXElementDict UpdatePropsAttribute(PBXElementDict settings, bool value, string attributeName)
        {
            PBXElementArray attrs = null;

            if (value)
            {
                if (settings == null)
                {
                    settings = m_Properties.CreateDict("settings");
                }
            }

            if (settings != null && settings.Contains("ATTRIBUTES"))
            {
                attrs = settings["ATTRIBUTES"].AsArray();
            }

            if (value)
            {
                if (attrs == null)
                {
                    attrs = settings.CreateArray("ATTRIBUTES");
                }

                bool exists = attrs.values.Any(attr =>
                {
                    return(attr is PBXElementString && attr.AsString() == attributeName);
                });

                if (!exists)
                {
                    attrs.AddString(attributeName);
                }
            }
            else
            {
                if (attrs != null)
                {
                    attrs.values.RemoveAll(el => (el is PBXElementString && el.AsString() == attributeName));
                    if (attrs.values.Count == 0)
                    {
                        settings.Remove("ATTRIBUTES");
                    }
                }
            }

            return(settings);
        }
Пример #5
0
 internal void SetPropertiesWhenSerializing(PBXElementDict props)
 {
     m_Properties = props;
 }
Пример #6
0
        public override void UpdateVars()
        {
            projectReferences = new List <ProjectReference>();
            if (m_Properties.Contains("projectReferences"))
            {
                var el = m_Properties["projectReferences"].AsArray();
                foreach (var value in el.values)
                {
                    PBXElementDict dict = value.AsDict();
                    if (dict.Contains("ProductGroup") && dict.Contains("ProjectRef"))
                    {
                        string group      = dict["ProductGroup"].AsString();
                        string projectRef = dict["ProjectRef"].AsString();
                        projectReferences.Add(ProjectReference.Create(group, projectRef));
                    }
                }
            }

            targets         = GetPropertyList("targets");
            buildConfigList = GetPropertyString("buildConfigurationList");

            // update knownAssetTags
            knownAssetTags = new List <string>();
            if (m_Properties.Contains("attributes"))
            {
                var el = m_Properties["attributes"].AsDict();
                if (el.Contains("knownAssetTags"))
                {
                    var tags = el["knownAssetTags"].AsArray();
                    foreach (var tag in tags.values)
                    {
                        knownAssetTags.Add(tag.AsString());
                    }
                }

                capabilities = new List <PBXCapabilityType.TargetCapabilityPair>();
                teamIDs      = new Dictionary <string, string>();

                if (el.Contains("TargetAttributes"))
                {
                    var targetAttr = el["TargetAttributes"].AsDict();
                    foreach (var attr in targetAttr.values)
                    {
                        if (attr.Key == "DevelopmentTeam")
                        {
                            teamIDs.Add(attr.Key, attr.Value.AsString());
                        }

                        if (attr.Key == "SystemCapabilities")
                        {
                            var caps = el["SystemCapabilities"].AsDict();
                            foreach (var cap in caps.values)
                            {
                                capabilities.Add(new PBXCapabilityType.TargetCapabilityPair(attr.Key,
                                                                                            PBXCapabilityType.StringToPBXCapabilityType(cap.Value.AsString())));
                            }
                        }
                    }
                }
            }
        }
Пример #7
0
 public abstract void AddObject(string key, PBXElementDict value);
Пример #8
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");
            }
        }