コード例 #1
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())));
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Serializer.cs プロジェクト: slove3000/Usdk
        public static void WriteDict(StringBuilder sb, PBXElementDict el, int indent, bool compact,
                                     PropertyCommentChecker checker, GUIDToCommentMap comments)
        {
            sb.Append("{");

            if (el.Contains("isa"))
            {
                WriteDictKeyValue(sb, "isa", el["isa"], indent + 1, compact, checker, comments);
            }
            var keys = new List <string>(el.values.Keys);

            keys.Sort(StringComparer.Ordinal);
            foreach (var key in keys)
            {
                if (key != "isa")
                {
                    WriteDictKeyValue(sb, key, el[key], indent + 1, compact, checker, comments);
                }
            }
            if (!compact)
            {
                sb.Append("\n");
                sb.Append(GetIndent(indent));
            }
            sb.Append("}");
        }
コード例 #3
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);
        }
コード例 #4
0
        /*
         * Allows the setting of target attributes in the project section such as Provisioning Style and Team ID for each target
         *
         * The Target Attributes are structured like so:
         * attributes = {
         *      TargetAttributes = {
         *          1D6058900D05DD3D006BFB54 = {
         *              DevelopmentTeam = Z6SFPV59E3;
         *              ProvisioningStyle = Manual;
         *          };
         *          5623C57217FDCB0800090B9E = {
         *              DevelopmentTeam = Z6SFPV59E3;
         *              ProvisioningStyle = Manual;
         *              TestTargetID = 1D6058900D05DD3D006BFB54;
         *          };
         *      };
         *  };
         */
        internal void SetTargetAttributes(string key, string value)
        {
            PBXElementDict properties = project.project.GetPropertiesRaw();
            PBXElementDict attributes;
            PBXElementDict targetAttributes;

            if (properties.Contains("attributes"))
            {
                attributes = properties["attributes"] as PBXElementDict;
            }
            else
            {
                attributes = properties.CreateDict("attributes");
            }

            if (attributes.Contains("TargetAttributes"))
            {
                targetAttributes = attributes["TargetAttributes"] as PBXElementDict;
            }
            else
            {
                targetAttributes = attributes.CreateDict("TargetAttributes");
            }

            foreach (KeyValuePair <string, PBXNativeTargetData> target in nativeTargets.GetEntries())
            {
                PBXElementDict targetAttributesRaw;
                if (targetAttributes.Contains(target.Key))
                {
                    targetAttributesRaw = targetAttributes[target.Key].AsDict();
                }
                else
                {
                    targetAttributesRaw = targetAttributes.CreateDict(target.Key);
                }
                targetAttributesRaw.SetString(key, value);
            }
            project.project.UpdateVars();
        }
コード例 #5
0
        internal void SetTargetAttributes(string key, string value)
        {
            PBXElementDict dict2;
            PBXElementDict dict3;
            PBXElementDict propertiesRaw = this.project.project.GetPropertiesRaw();

            if (propertiesRaw.Contains("attributes"))
            {
                dict2 = propertiesRaw["attributes"] as PBXElementDict;
            }
            else
            {
                dict2 = propertiesRaw.CreateDict("attributes");
            }
            if (dict2.Contains("TargetAttributes"))
            {
                dict3 = dict2["TargetAttributes"] as PBXElementDict;
            }
            else
            {
                dict3 = dict2.CreateDict("TargetAttributes");
            }
            foreach (KeyValuePair <string, PBXNativeTargetData> pair in this.nativeTargets.GetEntries())
            {
                PBXElementDict dict4;
                if (dict3.Contains(pair.Key))
                {
                    dict4 = dict3[pair.Key].AsDict();
                }
                else
                {
                    dict4 = dict3.CreateDict(pair.Key);
                }
                dict4.SetString(key, value);
            }
            this.project.project.UpdateVars();
        }
コード例 #6
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();
        }
コード例 #7
0
        private GUIDToCommentMap BuildCommentMap()
        {
            GUIDToCommentMap comments = new GUIDToCommentMap();

            // buildFiles are handled below
            // filerefs are handled below
            foreach (var e in groups.GetObjects())
            {
                comments.Add(e.guid, e.name);
            }
            foreach (var e in containerItems.GetObjects())
            {
                comments.Add(e.guid, "PBXContainerItemProxy");
            }
            foreach (var e in references.GetObjects())
            {
                comments.Add(e.guid, e.path);
            }
            foreach (var e in sources.GetObjects())
            {
                comments.Add(e.guid, "Sources");
                BuildCommentMapForBuildFiles(comments, e.files, "Sources");
            }
            foreach (var e in resources.GetObjects())
            {
                comments.Add(e.guid, "Resources");
                BuildCommentMapForBuildFiles(comments, e.files, "Resources");
            }
            foreach (var e in frameworks.GetObjects())
            {
                comments.Add(e.guid, "Frameworks");
                BuildCommentMapForBuildFiles(comments, e.files, "Frameworks");
            }
            foreach (var e in copyFiles.GetObjects())
            {
                string sectName = e.name;
                if (sectName == null)
                {
                    sectName = "CopyFiles";
                }
                comments.Add(e.guid, sectName);
                BuildCommentMapForBuildFiles(comments, e.files, sectName);
            }
            foreach (var e in shellScripts.GetObjects())
            {
                comments.Add(e.guid, "ShellScript");
            }
            foreach (var e in targetDependencies.GetObjects())
            {
                comments.Add(e.guid, "PBXTargetDependency");
            }
            foreach (var e in nativeTargets.GetObjects())
            {
                comments.Add(e.guid, e.name);
                comments.Add(e.buildConfigList, String.Format("Build configuration list for PBXNativeTarget \"{0}\"", e.name));
            }
            foreach (var e in variantGroups.GetObjects())
            {
                comments.Add(e.guid, e.name);
            }
            foreach (var e in buildConfigs.GetObjects())
            {
                comments.Add(e.guid, e.name);
            }
            foreach (var e in project.GetObjects())
            {
                comments.Add(e.guid, "Project object");
                comments.Add(e.buildConfigList, "Build configuration list for PBXProject \"Unity-iPhone\""); // FIXME: project name is hardcoded
            }
            foreach (var e in fileRefs.GetObjects())
            {
                comments.Add(e.guid, e.name);
            }
            if (m_RootElements.Contains("rootObject") && m_RootElements["rootObject"] is PBXElementString)
            {
                comments.Add(m_RootElements["rootObject"].AsString(), "Project object");
            }

            return(comments);
        }