Пример #1
0
        public void AddFrameworkOrLibrary(string path, AddMethod addMethod, LinkType linkType)
        {
            path = ProjectUtil.MakePathRelativeToProject(path);

            if (_entries.FindIndex(o => o.Path == path) < 0)
            {
                BaseFileEntry entry    = null;
                var           fileType = PBXFileTypeHelper.FileTypeFromFileName(path);

                if (PBXFileTypeHelper.IsFrameworkOrLibrary(fileType))
                {
                    entry = FileAndFolderEntryFactory.CreateFrameworkEntry(path, addMethod, linkType, false);
                }
                else
                {
                    Debug.LogWarning("EgoXproject: File is not a known Framework or library file type. Adding as a regular file: " + path);
                    entry = FileAndFolderEntryFactory.Create(path, addMethod);
                }

                if (entry == null)
                {
                    Debug.LogError("EgoXproject: Could not add file. Either it does not exist or is on Ignore List: " + path);
                }
                else
                {
                    _entries.Add(entry);
                }
            }
        }
Пример #2
0
        public void AddEmbeddedFramework(string path)
        {
            path = ProjectUtil.MakePathRelativeToProject(path);

            if (_entries.FindIndex(o => o.Path == path) < 0)
            {
                BaseFileEntry entry    = null;
                var           fileType = PBXFileTypeHelper.FileTypeFromFileName(path);

                if (PBXFileTypeHelper.IsFramework(fileType))
                {
                    entry = FileAndFolderEntryFactory.CreateFrameworkEntry(path, AddMethod.Copy, LinkType.Required, true);

                    if (entry == null)
                    {
                        Debug.LogError("EgoXproject: Could not add file. Either it does not exist or is on Ignore List: " + path);
                    }
                    else
                    {
                        _entries.Add(entry);
                    }
                }
                else
                {
                    Debug.LogWarning("EgoXproject: File is not a Framework type. Skipping: " + path);
                }
            }
        }
Пример #3
0
        public void AddSourceFile(string path, AddMethod addMethod, string compilerFlags = "")
        {
            path = ProjectUtil.MakePathRelativeToProject(path);

            if (_entries.FindIndex(o => o.Path == path) < 0)
            {
                BaseFileEntry entry    = null;
                var           fileType = PBXFileTypeHelper.FileTypeFromFileName(path);

                if (PBXFileTypeHelper.IsSourceCodeFile(fileType))
                {
                    entry = FileAndFolderEntryFactory.CreateSourceEntry(path, addMethod, compilerFlags);
                }
                else
                {
                    Debug.LogWarning("EgoXproject: File is not a known source file type. Adding as a regular file: " + path);
                    entry = FileAndFolderEntryFactory.Create(path, addMethod);
                }

                if (entry == null)
                {
                    Debug.LogError("EgoXproject: Could not add file. Either it does not exist or is on Ignore List: " + path);
                }
                else
                {
                    _entries.Add(entry);
                }
            }
        }
Пример #4
0
        void UpgradeSettingsFile(string fileName)
        {
            var plist = new PList();

            if (!plist.Load(fileName))
            {
                return;
            }

            if (plist.Root.StringValue("Type") != "EgoXproject Settings")
            {
                return;
            }

            if (plist.Root.IntValue("Version") != 1 && plist.Root.IntValue("Version") != 2)
            {
                return;
            }

            var dirName        = Path.GetDirectoryName(fileName);
            var configurations = new XcodeConfigurations(dirName);
            var platformConfig = configurations.Configuration(BuildPlatform.iOS);
            var configs        = plist.Root.DictionaryValue("Configurations");

            if (configs != null)
            {
                foreach (var kvp in configs)
                {
                    var entries = kvp.Value as PListArray;

                    if (entries == null || entries.Count <= 0)
                    {
                        platformConfig.AddConfiguration(kvp.Key);
                        continue;
                    }

                    for (int ii = 0; ii < entries.Count; ++ii)
                    {
                        platformConfig.AddChangeFileToConfiguration(entries.StringValue(ii), kvp.Key);
                    }
                }
            }

            var active = plist.Root.StringValue("ActiveConfiguration");

            if (!string.IsNullOrEmpty(active))
            {
                platformConfig.ActiveConfiguration = active;
            }

            configurations.Save();
            plist.Root.Remove("Configurations");
            plist.Root.Remove("ActiveConfiguration");
            plist.Save();
            string oldPath = ProjectUtil.MakePathRelativeToProject(plist.SavePath);
            string newPath = ProjectUtil.MakePathRelativeToProject(Path.Combine(Path.GetDirectoryName(oldPath), "egoxproject.settings"));

            AssetDatabase.MoveAsset(oldPath, newPath);
        }
Пример #5
0
        void SaveVersionFile(string path)
        {
            List <string> entries = new List <string>();

            entries.Add(VERSION_KEY + ": " + DllUtils.Version());
            File.WriteAllLines(path, entries.ToArray());
            AssetDatabase.ImportAsset(ProjectUtil.MakePathRelativeToProject(path));
        }
Пример #6
0
        void AddEntry(string path, AddMethod addMethod = AddMethod.Link)
        {
            path = ProjectUtil.MakePathRelativeToProject(path);

            if (_entries.FindIndex(o => o.Path == path) > -1)
            {
                return;
            }

            var entry = FileAndFolderEntryFactory.Create(path, addMethod);

            if (entry != null)
            {
                _entries.Add(entry);
            }
        }
Пример #7
0
        void FindChangeFiles()
        {
            _iosChangeFiles.Clear();
            _tvosChangeFiles.Clear();
            _macosChangeFiles.Clear();
            string[] allPListPaths = Directory.GetFiles(Application.dataPath, "*" + XcodeChangeFile.Extension, SearchOption.AllDirectories);

            if (allPListPaths.Length > 0)
            {
                foreach (var path in allPListPaths)
                {
                    string fileName = Path.GetFileName(path);

                    if (string.IsNullOrEmpty(fileName) || fileName.StartsWith(".", StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    //load and validate the files
                    var tmp = XcodeChangeFile.Load(path);

                    if (tmp != null)
                    {
                        string relativePath = ProjectUtil.MakePathRelativeToProject(path);

                        if (tmp.Platform == BuildPlatform.tvOS)
                        {
                            _tvosChangeFiles.Add(relativePath);
                        }
                        else if (tmp.Platform == BuildPlatform.MacOS)
                        {
                            _macosChangeFiles.Add(relativePath);
                        }
                        else
                        {
                            _iosChangeFiles.Add(relativePath);
                        }
                    }
                    else
                    {
                        Debug.LogError("EgoXproject: Failed to load " + path);
                    }
                }
            }
        }
Пример #8
0
        public void AddFileOrFolder(string path, AddMethod addMethod = AddMethod.Link)
        {
            path = ProjectUtil.MakePathRelativeToProject(path);

            if (_entries.FindIndex(o => o.Path == path) < 0)
            {
                var entry = FileAndFolderEntryFactory.Create(path, addMethod);

                if (entry == null)
                {
                    Debug.LogError("EgoXproject: Could not add file. Either does not exist or is on Ignore List: " + path);
                }
                else
                {
                    _entries.Add(entry);
                }
            }
        }
Пример #9
0
        void Populate()
        {
            bool populated = _entries.Count > 0;
            var  files     = Directory.GetFiles(Path);

            foreach (var f in files)
            {
                if (!FileAndFolderEntryFactory.IsValidFileOrFolder(f))
                {
                    continue;
                }

                var rel = ProjectUtil.MakePathRelativeToProject(f);
                AddEntry(FileAndFolderEntryFactory.Create(rel, Add));
            }

            var folders = Directory.GetDirectories(Path);

            foreach (var f in folders)
            {
                if (!FileAndFolderEntryFactory.IsValidFileOrFolder(f))
                {
                    continue;
                }

                var rel   = ProjectUtil.MakePathRelativeToProject(f);
                int index = -1;

                if (populated)
                {
                    index = _entries.FindIndex(o => o.Path == rel);
                }

                if (index < 0)
                {
                    AddEntry(FileAndFolderEntryFactory.Create(rel, Add));
                }
                else if (_entries[index] is FolderEntry)
                {
                    var subfe = _entries[index] as FolderEntry;
                    subfe.Populate();
                }
            }
        }
Пример #10
0
        public void Save()
        {
            var plist = new PList();

            plist.Root.Add(TYPE_KEY, TYPE_VALUE);
            plist.Root.Add(VERSION_KEY, VERSION);
            plist.Root.Add(AUTORUN_KEY, _autoRun);
            plist.Root.Add(IGNORE_KEY, new PListArray(IgnoredFiles.CustomList));
            bool assetImport = !File.Exists(_savePath);

            if (plist.Save(_savePath, true))
            {
                IsDirty = false;

                if (assetImport)
                {
                    AssetDatabase.ImportAsset(ProjectUtil.MakePathRelativeToProject(_savePath));
                }
            }
        }
Пример #11
0
        void BackupFile(string fileName)
        {
            string dstFileName = fileName + ".bak";
            int    counter     = 1;

            while (File.Exists(dstFileName))
            {
                dstFileName = fileName + " " + counter.ToString() + ".bak";
                counter++;
            }

            var  from    = ProjectUtil.MakePathRelativeToProject(fileName);
            var  to      = ProjectUtil.MakePathRelativeToProject(dstFileName);
            bool success = AssetDatabase.CopyAsset(from, to);

            if (!success)
            {
                Debug.LogError("EgoXproject: Failed to backup file " + from + " to " + to + ".");
            }
        }
Пример #12
0
        public void Save()
        {
            var plist = new PList();

            plist.Root.Add(TYPE_KEY, TYPE_VALUE);
            plist.Root.Add(VERSION_KEY, VERSION);
            plist.Root.Add(BuildPlatform.iOS.ToString(), _iosConfigs.Serialize());
            plist.Root.Add(BuildPlatform.tvOS.ToString(), _tvosConfigs.Serialize());
            bool assetImport = !File.Exists(_savePath);

            if (plist.Save(_savePath, true))
            {
                IsDirty = false;

                if (assetImport)
                {
                    AssetDatabase.ImportAsset(ProjectUtil.MakePathRelativeToProject(_savePath));
                }
            }
        }