示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Egomotion.EgoXproject.Internal.PBXBaseObject"/> class.
        /// </summary>
        /// <param name="isa">Isa.</param> The type of object it is
        /// <param name="uid">Uid.</param> The UID in the project objects dictionary for this object
        /// <param name="dict">Dict.</param> The dictionary entry in the project objects dictionary for this object
        protected PBXBaseObject(PBXTypes isa, string uid, PBXProjDictionary dict)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new System.ArgumentNullException((uid).ToString(), "Dictionary cannot be null");
            }

            if (dict == null)
            {
                throw new System.ArgumentNullException((dict).ToString(), "Dictionary cannot be null");
            }

            var isaValue = dict.Element <PBXProjString>(isaKey);

            if (isaValue == null)
            {
                throw new System.ArgumentException("Dictionary must contain an isa key with a string value", (dict).ToString());
            }

            if (isa.ToString() != isaValue.Value)
            {
                throw new System.ArgumentException("Dictionary must be a " + isa + " dictionary and not a " + isaValue.Value + " dictionary", (dict).ToString());
            }

            Dict = dict;
            UID  = uid;
            Isa  = isa;
        }
示例#2
0
        public static PBXShellScriptBuildPhase Create(string uid, string name, string script, string shell)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new System.ArgumentNullException((uid).ToString(), "uid cannot be null or empty");
            }

            PBXProjDictionary emptyDic = new PBXProjDictionary();

            emptyDic.Add(isaKey, PBXTypes.PBXShellScriptBuildPhase.ToString());
            PBXBaseBuildPhase.PopulateEmptyDictionary(emptyDic);
            emptyDic.Add(INPUT_PATH_KEY, new PBXProjArray());
            emptyDic.Add(OUTPUT_PATHS_KEY, new PBXProjArray());
            emptyDic.Add(SHELL_PATH_KEY, DEFAULT_SHELL);
            emptyDic.Add(SHELL_SCRIPT_KEY, "\"\"");
            var buildPhase = new PBXShellScriptBuildPhase(uid, emptyDic);

            if (!string.IsNullOrEmpty(name))
            {
                buildPhase.Name = name;
            }

            buildPhase.ShellPath = shell;
            buildPhase.Script    = script;
            return(buildPhase);
        }
示例#3
0
        void SetSettingsEntry(string key, IPBXProjExpression value)
        {
            var settings = Dict.DictionaryValue(SETTINGS_KEY);

            if (settings == null)
            {
                settings = new PBXProjDictionary();
                Dict.Add(SETTINGS_KEY, settings);
            }

            settings[key] = value;
        }
示例#4
0
        public PBXProjDictionary TargetAttributesEntry(string targetKey)
        {
            var val = TargetAttributes.DictionaryValue(targetKey);

            if (val == null)
            {
                val = new PBXProjDictionary();
                TargetAttributes[targetKey] = val;
            }

            return(val);
        }
        void ExtractConditionals(PBXProjDictionary dict)
        {
            _conditionalSettings = new Dictionary <string, List <ConditionalSetting> >();

            //find and log conditionals
            //conditional will generally look like:
            // "SETTING_NAME[sdk=iphoneos*]"
            // but can look like
            // "SETTING_NAME[sdk=iphoneos*][arch=armv7]
            // * may also be a version number
            foreach (var kvp in dict.DictionaryValue(BUILD_SETTINGS_KEY))
            {
                var setting = kvp.Key;

                if (setting.Contains("["))
                {
                    var originalSetting = setting;
                    setting = setting.FromLiteral();
                    var leftBracketIndex = setting.IndexOf("[", System.StringComparison.InvariantCultureIgnoreCase);
                    var bareSetting      = setting.Substring(0, leftBracketIndex);

                    if (!_conditionalSettings.ContainsKey(bareSetting))
                    {
                        _conditionalSettings[bareSetting] = new List <ConditionalSetting>();
                    }

                    int startIndex        = leftBracketIndex;
                    int endIndex          = -1;
                    ConditionalSetting cs = new ConditionalSetting();
                    cs.name         = originalSetting;
                    cs.conditionals = new List <Conditional>();
                    Conditional conditional = null;

                    do
                    {
                        conditional = ExtractConditional(setting, startIndex, out endIndex);

                        if (conditional == null)
                        {
                            break;
                        }
                        else
                        {
                            cs.conditionals.Add(conditional);
                            startIndex = endIndex;
                        }
                    }while (conditional != null);

                    _conditionalSettings[bareSetting].Add(cs);
                }
            }
        }
        public static PBXResourcesBuildPhase Create(string uid)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new System.ArgumentNullException(nameof(uid), "uid cannot be null or empty");
            }

            PBXProjDictionary emptyDic = new PBXProjDictionary();

            emptyDic.Add(isaKey, PBXTypes.PBXResourcesBuildPhase.ToString());
            PopulateEmptyDictionary(emptyDic);
            return(new PBXResourcesBuildPhase(uid, emptyDic));
        }
示例#7
0
        protected static PBXProjDictionary CommonCreate(string uid, PBXTypes type)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new System.ArgumentNullException(nameof(uid), "uid cannot be null or empty");
            }

            PBXProjDictionary emptyDic = new PBXProjDictionary();

            //isa
            emptyDic.Add(isaKey, type.ToString());
            emptyDic.Add(CHILDREN_KEY, new PBXProjArray());
            emptyDic.Add(SOURCE_TREE_KEY, SourceTreeLocation.GROUP);
            return(emptyDic);
        }
示例#8
0
        public void EnableSystemCapability(string targetKey, string capabilityKey, bool enabled)
        {
            var attribs            = TargetAttributesEntry(targetKey);
            var systemCapabilities = attribs.DictionaryValue(SYSTEM_CAPABILITIES_KEY);

            if (systemCapabilities == null)
            {
                systemCapabilities = new PBXProjDictionary();
                attribs[SYSTEM_CAPABILITIES_KEY] = systemCapabilities;
            }

            var enabledDic = new PBXProjDictionary();

            enabledDic.Add(ENABLED_KEY, enabled ? "1" : "0");
            systemCapabilities[capabilityKey] = enabledDic;
        }
示例#9
0
        protected static PBXProjDictionary AddPathAndName(PBXProjDictionary dic, string path)
        {
            //path
            //TODO check to see if we need to remove quotes
            string unquotedPath = path;//.FromLiteral();

            dic.Add(PATH_KEY, unquotedPath.ToLiteralIfRequired());

            //optional name
            if (path.StartsWith("../", System.StringComparison.InvariantCultureIgnoreCase) ||
                path.StartsWith("./", System.StringComparison.InvariantCultureIgnoreCase))
            {
                var fileName = System.IO.Path.GetFileName(unquotedPath);
                dic.Add(NAME_KEY, fileName.ToLiteralIfRequired());
            }

            return(dic);
        }
示例#10
0
        static PBXBuildFile CreateCommon(string uid, string refUID)
        {
            if (string.IsNullOrEmpty(uid))
            {
                throw new System.ArgumentNullException((uid).ToString(), "uid cannot be null or empty");
            }

            if (string.IsNullOrEmpty(refUID))
            {
                throw new System.ArgumentNullException((refUID).ToString(), "refUID cannot be null");
            }

            PBXProjDictionary emptyDic = new PBXProjDictionary();

            emptyDic.Add(isaKey, PBXTypes.PBXBuildFile.ToString());
            emptyDic.Add(FILE_REF_KEY, refUID);
            return(new PBXBuildFile(uid, emptyDic));
        }
示例#11
0
        static PBXFileReference CommonCreate(string uid, string path, string sourceTree, PBXGroup group)
        {
            NullCheck(uid, path, group);
            PBXProjDictionary emptyDic = new PBXProjDictionary();

            //isa
            emptyDic.Add(isaKey, PBXTypes.PBXFileReference.ToString());
            //path
            //TODO check that path will never have quotes or be a literal when entered
            //string unquotedPath = path.FromLiteral();
            string unquotedPath = path;

            emptyDic.Add(PATH_KEY, unquotedPath.ToLiteralIfRequired());
            //file type
            var fileType = PBXFileTypeHelper.FileTypeFromFileName(unquotedPath);

            if (sourceTree == SourceTreeLocation.BUILT_PRODUCTS_DIR)
            {
                emptyDic.Add(EXPLICIT_FILE_TYPE_KEY, fileType.GetXcodeDataValue());
                emptyDic.Add(INCLUDE_IN_INDEX_KEY, 0);
            }
            else
            {
                emptyDic.Add(LAST_KNOWN_FILE_TYPE_KEY, fileType.GetXcodeDataValue());
            }

            //source tree
            emptyDic.Add(SOURCE_TREE_KEY, sourceTree);
            //filename
            var fileName = System.IO.Path.GetFileName(unquotedPath);

            if (fileName != unquotedPath)
            {
                emptyDic.Add(NAME_KEY, fileName.ToLiteralIfRequired());
            }

            //TODO ignore file encoding for now
            var fileRef = new PBXFileReference(uid, emptyDic);

            fileRef.ParentGroup = group;
            return(fileRef);
        }
示例#12
0
 public PBXGroup(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXGroup, uid, dict)
 {
     Init();
 }
示例#13
0
 public PBXTargetDependency(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXTargetDependency, uid, dict)
 {
 }
示例#14
0
 public PBXNativeTarget(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXNativeTarget, uid, dict)
 {
 }
示例#15
0
 public PBXShellScriptBuildPhase(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXShellScriptBuildPhase, uid, dict)
 {
 }
示例#16
0
 public PBXCopyFilesBuildPhase(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXCopyFilesBuildPhase, uid, dict)
 {
 }
 public PBXResourcesBuildPhase(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXResourcesBuildPhase, uid, dict)
 {
 }
示例#18
0
        PBXProjDictionary ParseDictionary()
        {
            // {assignment assignment assignment};
            // { variable = expression; variable = expression; variable = expression;};
            // _current = {
            PBXProjDictionary dic = new PBXProjDictionary();

            ReadNextToken();

            while (!(_currentToken.Type == PBXProjTokenType.Symbol && _currentToken.Value == "}"))      //doing !symbol && !} means that other symbols break the loop.
            {
                // assignment:
                // variable = expression;
                // comment variable comment = expresssion comment; comment
                string preComment = "", keyComment = "", postComment = "";

                if (_currentToken != null && _currentToken.Type == PBXProjTokenType.Comment)
                {
                    preComment = _currentToken.Value;
                    ReadNextToken();
                }

                if (_currentToken.Type != PBXProjTokenType.String)
                {
                    throw new PBXProjParserException("Expected a variable name, but got " + _currentToken.Value);
                }

                string key = _currentToken.Value;
                //              Debug.Log(key);
                ReadNextToken();

                if (_currentToken != null && _currentToken.Type == PBXProjTokenType.Comment)
                {
                    keyComment = _currentToken.Value;
                    ReadNextToken();
                }

                CheckForUnexpectedEndOfSource();
                SkipExpected(PBXProjTokenType.Symbol, "=");
                IPBXProjExpression exp = ParseExpression();

                if (exp == null)
                {
                    throw new PBXProjParserException("Expected an expression to be assigned to " + key);
                }

                SkipExpected(PBXProjTokenType.Symbol, ";");

                if (_currentToken != null && _currentToken.Type == PBXProjTokenType.Comment)
                {
                    postComment = _currentToken.Value;
                    ReadNextToken();
                }

                CheckForUnexpectedEndOfSource();
                dic.Add(key, exp);
                dic.SetPreCommentForKey(key, preComment);
                dic.SetCommentForKey(key, keyComment);
                dic.SetPostCommentForKey(key, postComment);
            }

            ReadNextToken();
            return(dic);
        }
示例#19
0
 public PBXHeadersBuildPhase(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXHeadersBuildPhase, uid, dict)
 {
 }
示例#20
0
 public PBXVariantGroup(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXVariantGroup, uid, dict)
 {
 }
示例#21
0
 public PBXFileReference(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXFileReference, uid, dict)
 {
 }
 public XCBuildConfiguration(string uid, PBXProjDictionary dict)
     : base(PBXTypes.XCBuildConfiguration, uid, dict)
 {
     ExtractConditionals(dict);
 }
 public PBXFrameworksBuildPhase(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXFrameworksBuildPhase, uid, dict)
 {
 }
示例#24
0
 //used by XCVersionGroup and XCVariantGroup
 protected PBXGroup(PBXTypes isa, string uid, PBXProjDictionary dict)
     : base(isa, uid, dict)
 {
     Init();
 }
示例#25
0
 public XCConfigurationList(string uid, PBXProjDictionary dict)
     : base(PBXTypes.XCConfigurationList, uid, dict)
 {
 }
 public PBXContainerItemProxy(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXContainerItemProxy, uid, dict)
 {
 }
示例#27
0
 public PBXBuildFile(string uid, PBXProjDictionary dict)
     : base(PBXTypes.PBXBuildFile, uid, dict)
 {
 }
示例#28
0
 //TODO could this reference a variant group?
 protected PBXBaseBuildPhase(PBXTypes isa, string uid, PBXProjDictionary dict)
     : base(isa, uid, dict)
 {
 }
示例#29
0
 public XCVersionGroup(string uid, PBXProjDictionary dict)
     : base(PBXTypes.XCVersionGroup, uid, dict)
 {
 }
示例#30
0
 protected static void PopulateEmptyDictionary(PBXProjDictionary emptyDic)
 {
     emptyDic.Add(BUILD_ACTION_MASK_KEY, DEFAULT_BUILD_ACTION_MASK);
     emptyDic.Add(FILES_KEY, new PBXProjArray());
     emptyDic.Add(RUN_ONLY_FOR_DEPLOYMENT_POSTPROCESSING_KEY, "0");
 }