Exemplo n.º 1
0
        // These are duplicated from IgorRuntimeUtils.cs in the Core module.  This was necessary to
        // keep the updater working, but they are overridden by the RuntimeUtils version once Core is
        // installed.  If you have any fixes for these two functions, fix them both here and in
        // IgorRuntimeUtils.cs.
        public static bool CopyFile(string SourceFile, string TargetFile)
        {
            if (File.Exists(SourceFile))
            {
                if (File.Exists(TargetFile))
                {
                    DeleteFile(TargetFile);
                }

                try
                {
                    File.Copy(SourceFile, TargetFile);
                }
                catch (System.IO.IOException IOEx)
                {
                    if (IOEx.GetHashCode() == 112)
                    {
                        IgorDebug.CoreCriticalError("Failed to copy file " + SourceFile + " to " + TargetFile + " because there is not enough free space at the target location.");
                    }

                    throw IOEx;

                    return(false);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public static void HandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }
            }

            if (!Status.bWasStartedManually && (Status.bFailed || Status.bDone))
            {
                if (Status.bFailed)
                {
                    Application.Quit();
                }
                else
                {
                    Application.Quit();
                }
            }
        }
Exemplo n.º 3
0
        public static void AddOrUpdateForAllBuildProducts(IIgorModule ModuleInst, string ProjectPath, string Key, string Value)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach (KeyValuePair <string, XCBuildConfiguration> CurrentConfig in CurrentProject.buildConfigurations)
                {
                    object        BuildSettingsObj  = CurrentConfig.Value.data["buildSettings"];
                    PBXDictionary BuildSettingsDict = (PBXDictionary)BuildSettingsObj;

                    if (BuildSettingsDict.ContainsKey(Key))
                    {
                        BuildSettingsDict[Key] = Value;

                        IgorDebug.Log(ModuleInst, "Updated KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                    else
                    {
                        BuildSettingsDict.Add(Key, Value);

                        IgorDebug.Log(ModuleInst, "Added new KeyValuePair (Key: " + Key + " Value: " + Value + ") to build target GUID " + CurrentConfig.Key);
                    }
                }

                CurrentProject.Save();
            }
        }
Exemplo n.º 4
0
        public static void CheckForNamedJobFlag()
        {
            if (IgorJobConfig.IsStringParamSet(NamedJobFlag))
            {
                string JobToStart = IgorJobConfig.GetStringParam(NamedJobFlag);

                foreach (IgorPersistentJobConfig Job in IgorConfig.GetInstance().JobConfigs)
                {
                    if (Job.JobName == JobToStart)
                    {
                        IgorJobConfig ConfigInst = IgorJobConfig.GetConfig();

                        ConfigInst.Persistent = Job;

                        ConfigInst.Save(IgorJobConfig.IgorJobConfigPath);

                        IgorDebug.CoreLog("Starting named job " + JobToStart + ".");

                        return;
                    }
                }

                IgorDebug.CoreLogError("Couldn't find named job " + JobToStart + "!");
            }
        }
Exemplo n.º 5
0
        public static void ZipFilesMac(IIgorModule ModuleInst, List <string> FilesToZip, string ZipFilename, bool bUpdateBuildProducts, string RootDir)
        {
            string ZipParams = "-r \"" + ZipFilename + "\" ";

            foreach (string CurrentFile in FilesToZip)
            {
                ZipParams += "\"" + CurrentFile + "\" ";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "zip", "", ZipParams, Path.GetFullPath(RootDir), "Zipping the files", true) == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " created successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    List <string> NewProducts = new List <string>();

                    NewProducts.Add(ZipFilename);

                    IgorCore.SetNewModuleProducts(NewProducts);
                }
            }
        }
Exemplo n.º 6
0
        public static void ProcessArgs()
        {
            InitializeRuntimeCoreIfNeeded();

            if (RuntimeCore != null)
            {
                if (typeof(IgorCore).IsAssignableFrom(RuntimeCore.GetType()))
                {
                    IgorCore CoreInst = (IgorCore)RuntimeCore;

                    if (CoreInst != null)
                    {
                        ActiveModulesForJob.Clear();

                        foreach (IIgorModule CurrentModule in EnabledModules)
                        {
                            CurrentModule.ProcessArgs(CoreInst);
                        }
                    }
                    else
                    {
                        IgorDebug.CoreCriticalError("Core could not be case to type IgorCore!");
                    }
                }
                else
                {
                    IgorDebug.CoreCriticalError("Core is not of type IgorCore.  Did you make your own?  You may need to change how this works.");
                }
            }
            else
            {
                IgorDebug.CoreCriticalError("Core not found so we bailed out of processing arguments!");
            }
        }
Exemplo n.º 7
0
        public static void CommandLineRunJob()
        {
            IgorDebug.CoreLog("CommandLineRunJob invoked from command line.");

            IgorConfigWindow.OpenOrGetConfigWindow();

            EditorHandleJobStatus(IgorCore.RunJob());
        }
Exemplo n.º 8
0
        public static void AddRequiredDeviceCapability(IIgorModule ModuleInst, string PlistPath, string NewRequiredDeviceCapability)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary.ContainsKey("UIRequiredDeviceCapabilities"), "Can't find UIRequiredDeviceCapabilities in plist."))
                            {
                                NSObject DeviceCapabilities = RootDictionary.Get("UIRequiredDeviceCapabilities");

                                if (IgorAssert.EnsureTrue(ModuleInst, DeviceCapabilities != null, "Plist does not contain UIRequiredDeviceCapabilities."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(DeviceCapabilities.GetType()), "Plist UIRequiredDeviceCapabilities is not an array."))
                                    {
                                        NSArray CapabilitiesArray = (NSArray)DeviceCapabilities;

                                        if (IgorAssert.EnsureTrue(ModuleInst, CapabilitiesArray != null, "UIRequiredDeviceCapabilities is not an array."))
                                        {
                                            if (CapabilitiesArray.ContainsObject(new NSString(NewRequiredDeviceCapability)))
                                            {
                                                IgorDebug.Log(ModuleInst, "UIRequiredDeviceCapabilities already contains " + NewRequiredDeviceCapability);
                                            }
                                            else
                                            {
                                                NSSet NewCapabilitiesSet = new NSSet(CapabilitiesArray.GetArray());

                                                NewCapabilitiesSet.AddObject(new NSString(NewRequiredDeviceCapability));

                                                NSArray NewCapabilitiesArray = new NSArray(NewCapabilitiesSet.AllObjects());

                                                RootDictionary["UIRequiredDeviceCapabilities"] = NewCapabilitiesArray;

                                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                                IgorDebug.Log(ModuleInst, NewRequiredDeviceCapability + " added to UIRequiredDeviceCapabilities.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public static void SortGUIDIntoGroup(IIgorModule ModuleInst, string ProjectPath, string FileGUID, string GroupPath)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundGroup = false;

                    foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if (CurrentGroup.Value.path == GroupPath)
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj PBXGroup " + GroupPath + " doesn't have a children array."))
                            {
                                object GroupChildrenObj = CurrentGroup.Value.data["children"];

                                if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenObj != null, "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be retrieved."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(GroupChildrenObj.GetType()), "XCodeProj PBXGroup " + GroupPath + " has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList GroupChildrenList = (PBXList)GroupChildrenObj;

                                        if (IgorAssert.EnsureTrue(ModuleInst, GroupChildrenList != null, "XCodeProj casted Children List is null."))
                                        {
                                            if (GroupChildrenList.Contains(FileGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "FileGUID " + FileGUID + " has already been added to the Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                GroupChildrenList.Add(FileGUID);

                                                CurrentGroup.Value.data["children"] = GroupChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + FileGUID + " file to the Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundGroup, "Couldn't find a PBXGroup with path " + GroupPath + " in the XCodeProj.");

                    CurrentProject.Save();
                }
            }
        }
Exemplo n.º 10
0
        public static bool VerifyTrue(IIgorModule Module, bool bTrue, string FailMessage)
        {
            if (!bTrue)
            {
                IgorDebug.LogWarning(Module, FailMessage);
            }

            return(bTrue);
        }
Exemplo n.º 11
0
        public static bool EnsureTrue(IIgorModule Module, bool bTrue, string FailMessage)
        {
            if (!bTrue)
            {
                IgorDebug.LogWarning(Module, FailMessage);

                JobFailed();

                Debug.Break();
            }

            return(bTrue);
        }
Exemplo n.º 12
0
        public static bool ExecuteSteps()
        {
            if (IgorAssert.HasJobFailed())
            {
                IgorDebug.CoreLogError("Job failed so we are bailing out early and not finishing the remaining steps!");

                return(false);
            }

            List <StepID> SortedSteps = new List <StepID>(JobSteps.Keys);

            SortedSteps.Sort();

            IgorJobConfig.SetIsRunning(true);

            int StartingPriority        = IgorJobConfig.GetLastPriority();
            int StartingIndexInPriority = IgorJobConfig.GetLastIndexInPriority();

            foreach (StepID CurrentStep in SortedSteps)
            {
                if (CurrentStep.StepPriority > StartingPriority)
                {
                    IgorJobConfig.SetLastPriority(CurrentStep.StepPriority - 1);

                    int LastIndex = 0;

                    List <JobStep> CurrentStepFuncs = JobSteps[CurrentStep];

                    foreach (JobStep CurrentFunction in CurrentStepFuncs)
                    {
                        if (LastIndex > StartingIndexInPriority)
                        {
                            if (CurrentFunction.StepFunction())
                            {
                                IgorJobConfig.SetLastIndexInPriority(LastIndex);
                            }

                            return(false);
                        }

                        ++LastIndex;
                    }

                    StartingIndexInPriority = -1;
                    IgorJobConfig.SetLastIndexInPriority(-1);
                }
            }

            return(true);
        }
Exemplo n.º 13
0
        public static void ZipFilesWindows(IIgorModule ModuleInst, List <string> FilesToZip, string ZipFilename, bool bUpdateBuildProducts, string RootDir)
        {
            string ZipCommand = "";
            string ZipParams  = "";

            string PathX86 = "C:\\Program Files (x86)\\7-Zip\\7z.exe";
            string Path64  = "C:\\Program Files\\7-Zip\\7z.exe";

            if (File.Exists(PathX86))
            {
                ZipCommand = PathX86;
                ZipParams += "a -tzip \"" + ZipFilename + "\" ";
            }
            else
            if (File.Exists(Path64))
            {
                ZipCommand = Path64;
                ZipParams += "a -tzip \"" + ZipFilename + "\" ";
            }
            else
            {
                IgorDebug.LogError(ModuleInst, "7Zip is not installed.  Currently 7Zip is the only zip tool supported on Windows.\nPlease download it from here: http://www.7-zip.org/download.html");
                IgorDebug.LogError(ModuleInst, "Skipping zip step.");

                return;
            }

            foreach (string CurrentFile in FilesToZip)
            {
                ZipParams += "\"" + CurrentFile + "\" ";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", ZipCommand, ZipParams, Path.GetFullPath(RootDir), "Zipping the files") == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " created successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    List <string> NewProducts = new List <string>();

                    NewProducts.Add(ZipFilename);

                    IgorCore.SetNewModuleProducts(NewProducts);
                }
            }
        }
Exemplo n.º 14
0
        public static bool AssertTrue(IIgorModule Module, bool bTrue, string FailMessage)
        {
#if DEBUG
            if (!bTrue)
            {
                IgorDebug.LogError(Module, FailMessage);

                JobFailed();

                Debug.Break();
            }
#endif

            return(bTrue);
        }
Exemplo n.º 15
0
        public static void AddFrameworkSearchPath(IIgorModule ModuleInst, string ProjectPath, string NewPath)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                CurrentProject.AddFrameworkSearchPaths(NewPath);

                IgorDebug.Log(ModuleInst, "Added framework search path " + NewPath);

                CurrentProject.Save();
            }
        }
Exemplo n.º 16
0
        public static int RunProcessCrossPlatform(IIgorModule ModuleInst, string OSXCommand, string WindowsCommand, string Parameters, string Directory, string CommandLogDescription, ref string ProcessOutput, ref string ProcessError, bool bUseShell = false)
        {
            int RunProcessExitCode = RunProcessCrossPlatform(OSXCommand, WindowsCommand, Parameters, Directory, ref ProcessOutput, ref ProcessError, bUseShell);

            IgorRuntimeUtils.PlatformNames CurrentPlatform = IgorRuntimeUtils.RuntimeOrEditorGetPlatform();

            if (!IgorAssert.EnsureTrue(ModuleInst, RunProcessExitCode == 0, CommandLogDescription + " failed!\nCommand: " + (
                                           (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_OSX || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_OSX) ? OSXCommand : WindowsCommand
                                           ) + " " + Parameters + "\nDirectory: " + Directory + "\nOutput:\n" + ProcessOutput + "\n\n\nError:\n" + ProcessError))
            {
                return(RunProcessExitCode);
            }

            IgorDebug.Log(ModuleInst, CommandLogDescription + " succeeded!\nOutput:\n" + ProcessOutput + "\n\n\nError:\n" + ProcessError);

            return(RunProcessExitCode);
        }
Exemplo n.º 17
0
        public static void UnzipFileWindows(IIgorModule ModuleInst, string ZipFilename, string DirectoryToUnzipTo, bool bUpdateBuildProducts)
        {
            string ZipParams = "/c unzip -o \"" + ZipFilename + "\"";

            if (DirectoryToUnzipTo != "")
            {
                ZipParams += " -d \"" + DirectoryToUnzipTo + "\"";
            }

            string ZipOutput = "";
            string ZipError  = "";

            if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", "c:\\windows\\system32\\cmd.exe", ZipParams, Path.GetFullPath("."), "Unzipping the archive " + ZipFilename + " to folder " + DirectoryToUnzipTo, false) == 0)
            {
                IgorDebug.Log(ModuleInst, "Zip file " + ZipFilename + " unzipped successfully!\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                if (bUpdateBuildProducts)
                {
                    if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "", "c:\\windows\\system32\\cmd.exe", "/c unzip -v \"" + ZipFilename + "\"", Path.GetFullPath("."), "Listing the contents of " + ZipFilename, ref ZipOutput, ref ZipError, false) == 0)
                    {
                        IgorDebug.Log(ModuleInst, "Zip " + ZipFilename + " contents are:\nOutput:\n" + ZipOutput + "\nError\n" + ZipError);

                        List <string> NewProducts = new List <string>();

                        string[] Lines = ZipOutput.Split(new char[] { '\n', '\r' });

                        foreach (string ZipLine in Lines)
                        {
                            if (ZipLine.Contains("Defl") || ZipLine.Contains("Stored"))
                            {
                                if (!ZipLine.EndsWith("/"))
                                {
                                    NewProducts.Add(ZipLine.Substring(ZipLine.LastIndexOf(' ') + 1));
                                }
                            }
                        }

                        IgorCore.SetNewModuleProducts(NewProducts);
                    }
                }
            }
        }
Exemplo n.º 18
0
        public static void SetFileExecutable(string FullPath)
        {
            if (File.Exists(FullPath))
            {
                PlatformNames CurrentPlatform = RuntimeOrEditorGetPlatform();

                if (CurrentPlatform == PlatformNames.Editor_OSX || CurrentPlatform == PlatformNames.Standalone_OSX)
                {
                    string ChmodOutput = "";
                    string ChmodError  = "";

                    int ChmodRC = RunProcessCrossPlatform("chmod", "", "+x " + FullPath, Path.GetFullPath("."), ref ChmodOutput, ref ChmodError, true);

                    if (ChmodRC != 0)
                    {
                        IgorDebug.CoreLogError("Failed to make file " + FullPath + " executable!\nOutput:\n\n" + ChmodOutput + "\n\nError:\n\n" + ChmodError);
                    }
                }
            }
        }
Exemplo n.º 19
0
        // Pulled from https://msdn.microsoft.com/en-us/library/bb762914.aspx
        public static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs, bool bSkipUnityMetaFiles = true)
        {
            // Get the subdirectories for the specified directory.
            DirectoryInfo dir = new DirectoryInfo(sourceDirName);

            DirectoryInfo[] dirs = dir.GetDirectories();

            if (!dir.Exists)
            {
                IgorDebug.CoreCriticalError("Source directory does not exist or could not be found: " + sourceDirName);

                return;
            }

            // If the destination directory doesn't exist, create it.
            if (!Directory.Exists(destDirName))
            {
                Directory.CreateDirectory(destDirName);
            }

            // Get the files in the directory and copy them to the new location.
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                if (!file.Name.EndsWith(".meta"))
                {
                    string temppath = Path.Combine(destDirName, file.Name);
                    file.CopyTo(temppath, false);
                }
            }

            // If copying subdirectories, copy them and their contents to new location.
            if (copySubDirs)
            {
                foreach (DirectoryInfo subdir in dirs)
                {
                    string temppath = Path.Combine(destDirName, subdir.Name);
                    DirectoryCopy(subdir.FullName, temppath, copySubDirs);
                }
            }
        }
Exemplo n.º 20
0
        public static void SetStringValue(IIgorModule ModuleInst, string PlistPath, string StringKey, string Value)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            if (RootDictionary.ContainsKey(StringKey))
                            {
                                RootDictionary[StringKey] = new NSString(Value);

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " updated to " + Value);
                            }
                            else
                            {
                                RootDictionary.Add(StringKey, new NSString(Value));

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);

                                IgorDebug.Log(ModuleInst, "Plist key " + StringKey + " added with value of " + Value);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 21
0
        public static void UpdateAndRunJob()
        {
            IgorDebug.CoreLog("UpdateAndRunJob invoked from command line.");

            IgorJobConfig.SetBoolParam("updatebeforebuild", true);

            IgorConfigWindow.OpenOrGetConfigWindow();

            bool DidUpdate = IgorUpdater.CheckForUpdates(false, false, true);

            if (!DidUpdate)
            {
                IgorDebug.CoreLog("Igor did not need to update, running job.");

                EditorHandleJobStatus(IgorCore.RunJob());
            }
            else
            {
                IgorDebug.CoreLog("Igor needed to update, waiting for re-compile to run a job...");
            }
        }
Exemplo n.º 22
0
        public static string AddNewBuildFile(IIgorModule ModuleInst, string ProjectPath, string FileRefGUID)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                foreach (KeyValuePair <string, PBXBuildFile> CurrentBuildFile in CurrentProject.buildFiles)
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, CurrentBuildFile.Value.ContainsKey("fileRef"), "PBXBuildFile doesn't contain a key for fileRef."))
                    {
                        if (CurrentBuildFile.Value.data["fileRef"] == FileRefGUID)
                        {
                            IgorDebug.Log(ModuleInst, "The file GUID " + FileRefGUID + " already has an associated BuildFile in the XCodeProj.");

                            return(CurrentBuildFile.Value.guid);
                        }
                    }
                }

                foreach (KeyValuePair <string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences)
                {
                    if (CurrentFileRef.Value.guid == FileRefGUID)
                    {
                        PBXBuildFile NewBuildFile = new PBXBuildFile(CurrentFileRef.Value);

                        CurrentProject.buildFiles.Add(NewBuildFile);

                        IgorDebug.Log(ModuleInst, "BuildFile for FileRefGUID " + FileRefGUID + " has been added to the XCodeProj.");

                        CurrentProject.Save();

                        return(NewBuildFile.guid);
                    }
                }
            }

            return("");
        }
Exemplo n.º 23
0
        public static void EditorHandleJobStatus(IgorCore.JobReturnStatus Status)
        {
            if (Status.bDone)
            {
                if (IgorAssert.HasJobFailed())
                {
                    IgorDebug.CoreLogError("Job failed!");
                }
                else
                {
                    IgorDebug.CoreLog("Job's done!");
                }

                float time = IgorUtils.PlayJobsDoneSound();
                System.Threading.Thread t = new System.Threading.Thread(() => WaitToExit(time));
                t.Start();

                while (t.IsAlive)
                {
                }
            }

            if (Status.bFailed)
            {
                IgorJobConfig.SetIsRunning(false);

                if (!Status.bWasStartedManually)
                {
                    EditorApplication.Exit(-1);
                }
            }

            if (!Status.bWasStartedManually && Status.bDone)
            {
                EditorApplication.Exit(0);
            }
        }
Exemplo n.º 24
0
        public static void SetDevTeamID(IIgorModule ModuleInst, string ProjectPath, string DevTeamID)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                string ProjectGUID = CurrentProject.project.guid;

                object ProjectSectionObj = CurrentProject.GetObject(ProjectGUID);

                if (IgorAssert.EnsureTrue(ModuleInst, ProjectSectionObj != null, "Can't find Project Section in XCodeProj."))
                {
                    PBXDictionary ProjectSection = (PBXDictionary)ProjectSectionObj;

                    object AttributesSectionObj = ProjectSection["attributes"];

                    if (IgorAssert.EnsureTrue(ModuleInst, AttributesSectionObj != null, "Can't find Attributes Section in Project Section."))
                    {
                        object TargetAttributesObj = ((PBXDictionary)AttributesSectionObj)["TargetAttributes"];

                        if (IgorAssert.EnsureTrue(ModuleInst, TargetAttributesObj != null, "Can't find TargetAttributes Section in Attributes Section."))
                        {
                            PBXDictionary TargetAttributes = (PBXDictionary)TargetAttributesObj;

                            object TargetsObj = ProjectSection["targets"];

                            if (IgorAssert.EnsureTrue(ModuleInst, TargetsObj != null, "Can't find Targets Section in Project Section."))
                            {
                                PBXList TargetsList = ((PBXList)TargetsObj);

                                if (IgorAssert.EnsureTrue(ModuleInst, TargetsList.Count > 0, "No build targets defined in XCodeProj."))
                                {
                                    string PrimaryBuildTargetGUID = (string)(TargetsList[0]);

                                    PBXDictionary PrimaryBuildTargetToDevTeam = new PBXDictionary();
                                    PBXDictionary DevTeamIDDictionary         = new PBXDictionary();

                                    DevTeamIDDictionary.Add("DevelopmentTeam", DevTeamID);

                                    PrimaryBuildTargetToDevTeam.Add(PrimaryBuildTargetGUID, DevTeamIDDictionary);

                                    if (TargetAttributes.ContainsKey(PrimaryBuildTargetGUID))
                                    {
                                        object ExistingPrimaryBuildTargetObj = TargetAttributes[PrimaryBuildTargetGUID];

                                        if (ExistingPrimaryBuildTargetObj != null)
                                        {
                                            PBXDictionary ExistingPrimaryBuildTarget = (PBXDictionary)ExistingPrimaryBuildTargetObj;

                                            if (!ExistingPrimaryBuildTarget.ContainsKey("DevelopmentTeam"))
                                            {
                                                ExistingPrimaryBuildTarget.Append(DevTeamIDDictionary);

                                                IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                            }
                                            else
                                            {
                                                IgorDebug.Log(ModuleInst, "Development Team already set up in XCodeProj.");
                                            }
                                        }
                                        else
                                        {
                                            IgorDebug.LogError(ModuleInst, "Primary build target already has a key in TargetAttributes, but the value stored is invalid.");
                                        }
                                    }
                                    else
                                    {
                                        TargetAttributes.Append(PrimaryBuildTargetToDevTeam);

                                        IgorDebug.Log(ModuleInst, "Added Development Team to XCodeProj.");
                                    }

                                    CurrentProject.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 25
0
        public static void AddBundleURLType(IIgorModule ModuleInst, string PlistPath, string NewURLScheme)
        {
            if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(PlistPath), "Plist " + PlistPath + " doesn't exist!"))
            {
                FileInfo PlistFileInfo = new FileInfo(PlistPath);

                NSObject PlistRoot = PropertyListParser.Parse(PlistFileInfo);

                if (IgorAssert.EnsureTrue(ModuleInst, PlistRoot != null, "Plist " + PlistPath + " could not be parsed!"))
                {
                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(PlistRoot.GetType()), "Plist " + PlistPath + " root object is not a dictionary."))
                    {
                        NSDictionary RootDictionary = (NSDictionary)PlistRoot;

                        if (IgorAssert.EnsureTrue(ModuleInst, RootDictionary != null, "Plist root is not a dictionary."))
                        {
                            NSSet BundleURLTypes = null;

                            if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                            {
                                NSObject BundleURLTypesObj = RootDictionary.Get("CFBundleURLTypes");

                                if (IgorAssert.EnsureTrue(ModuleInst, BundleURLTypesObj != null, "CFBundleURLTypes wasn't found in the root dictionary even though the key exists."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(BundleURLTypesObj.GetType()), "CFBundleURLTypes isn't an NSArray."))
                                    {
                                        BundleURLTypes = new NSSet(((NSArray)BundleURLTypesObj).GetArray());
                                    }
                                }
                            }

                            if (BundleURLTypes == null)
                            {
                                BundleURLTypes = new NSSet();
                            }

                            bool bAlreadyExists = false;

                            foreach (NSObject CurrentURLType in BundleURLTypes)
                            {
                                if (bAlreadyExists)
                                {
                                    break;
                                }

                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSDictionary).IsAssignableFrom(CurrentURLType.GetType()), "One of the CFBundleURLTypes isn't an NSDictionary."))
                                {
                                    NSDictionary CurrentURLTypeDict = (NSDictionary)CurrentURLType;

                                    if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLTypeDict != null, "One of the CFBundleURLTypes didn't cast to NSDictionary correctly."))
                                    {
                                        if (CurrentURLTypeDict.ContainsKey("CFBundleURLSchemes"))
                                        {
                                            NSObject CurrentURLSchemesArrayObj = CurrentURLTypeDict.Get("CFBundleURLSchemes");

                                            if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSArray).IsAssignableFrom(CurrentURLSchemesArrayObj.GetType()), "A CFBundleURLSchemes key exists for a given CFBundleURLType, but it's not an NSArray type."))
                                            {
                                                NSArray CurrentURLSchemesArray = (NSArray)CurrentURLSchemesArrayObj;

                                                if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLSchemesArray != null, "The CFBundleURLSchemes object didn't cast to NSDictionary correctly."))
                                                {
                                                    NSSet CurrentURLSchemesSet = new NSSet(CurrentURLSchemesArray.GetArray());

                                                    foreach (NSObject CurrentURLSchemeObj in CurrentURLSchemesSet)
                                                    {
                                                        if (IgorAssert.EnsureTrue(ModuleInst, typeof(NSString).IsAssignableFrom(CurrentURLSchemeObj.GetType()), "One of the CFBundleURLSchemes is not an NSString."))
                                                        {
                                                            NSString CurrentURLScheme = (NSString)CurrentURLSchemeObj;

                                                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentURLScheme != null, "A CFBundleURLScheme entry didn't cast to NSString correctly."))
                                                            {
                                                                if (CurrentURLScheme.GetContent() == NewURLScheme)
                                                                {
                                                                    bAlreadyExists = true;

                                                                    IgorDebug.Log(ModuleInst, "URL scheme " + NewURLScheme + " is already in " + PlistPath);

                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (!bAlreadyExists)
                            {
                                NSString NewSchemeString = new NSString(NewURLScheme);

                                NSArray NewSchemeArray = new NSArray(1);

                                NewSchemeArray.SetValue(0, NewSchemeString);

                                NSDictionary NewTypeDictionary = new NSDictionary();

                                NewTypeDictionary.Add("CFBundleURLSchemes", NewSchemeArray);

                                BundleURLTypes.AddObject(NewTypeDictionary);

                                NSArray BundleURLTypesArray = new NSArray(BundleURLTypes.AllObjects());

                                if (RootDictionary.ContainsKey("CFBundleURLTypes"))
                                {
                                    RootDictionary["CFBundleURLTypes"] = BundleURLTypesArray;

                                    IgorDebug.Log(ModuleInst, "Updated CFBundleURLTypes to add " + NewURLScheme + ".");
                                }
                                else
                                {
                                    RootDictionary.Add("CFBundleURLTypes", BundleURLTypesArray);

                                    IgorDebug.Log(ModuleInst, "Added CFBundleURLTypes to add " + NewURLScheme + ".");
                                }

                                IgorRuntimeUtils.DeleteFile(PlistPath);

                                PropertyListParser.SaveAsXml(RootDictionary, PlistFileInfo);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
 public virtual void CriticalError(string Message)
 {
     IgorDebug.CriticalError(this, Message);
 }
Exemplo n.º 27
0
 public virtual void LogError(string Message)
 {
     IgorDebug.LogError(this, Message);
 }
Exemplo n.º 28
0
 public virtual void LogWarning(string Message)
 {
     IgorDebug.LogWarning(this, Message);
 }
Exemplo n.º 29
0
        public static void AddFramework(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "")
        {
            string FrameworkFileRefGUID = AddNewFileReference(ModuleInst, ProjectPath, Filename, TreeBase, Path, FileEncoding, LastKnownFileType, Name);

            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    bool bFoundFrameworksGroup = false;

                    foreach (KeyValuePair <string, PBXGroup> CurrentGroup in CurrentProject.groups)
                    {
                        if (CurrentGroup.Value.name == "Frameworks")
                        {
                            if (IgorAssert.EnsureTrue(ModuleInst, CurrentGroup.Value.ContainsKey("children"), "XCodeProj Frameworks PBXGroup doesn't have a children array."))
                            {
                                object FrameworkChildrenObj = CurrentGroup.Value.data["children"];

                                if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenObj != null, "XCodeProj Frameworks PBXGroup has a children key, but it can't be retrieved."))
                                {
                                    if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkChildrenObj.GetType()), "XCodeProj Frameworks PBXGroup has a children key, but it can't be cast to PBXList."))
                                    {
                                        PBXList FrameworkChildrenList = (PBXList)FrameworkChildrenObj;

                                        if (IgorAssert.EnsureTrue(ModuleInst, FrameworkChildrenList != null, "XCodeProj casted Framework Children List is null."))
                                        {
                                            if (FrameworkChildrenList.Contains(FrameworkFileRefGUID))
                                            {
                                                IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                            else
                                            {
                                                FrameworkChildrenList.Add(FrameworkFileRefGUID);

                                                CurrentGroup.Value.data["children"] = FrameworkChildrenList;

                                                IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Group " + CurrentGroup.Key + ".");
                                            }
                                        }
                                    }
                                }

                                bFoundFrameworksGroup = true;

                                break;
                            }
                        }
                    }

                    IgorAssert.EnsureTrue(ModuleInst, bFoundFrameworksGroup, "Couldn't find a Frameworks PBXGroup in the XCodeProj.");

                    CurrentProject.Save();
                }
            }

            string FrameworkBuildFileGUID = AddNewBuildFile(ModuleInst, ProjectPath, FrameworkFileRefGUID);

            if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath))
            {
                XCProject CurrentProject = new XCProject(ProjectPath);

                CurrentProject.Backup();

                if (IgorAssert.EnsureTrue(ModuleInst, CurrentProject != null, "XCodeProj couldn't be loaded."))
                {
                    foreach (KeyValuePair <string, PBXFrameworksBuildPhase> CurrentTarget in CurrentProject.frameworkBuildPhases)
                    {
                        if (IgorAssert.EnsureTrue(ModuleInst, CurrentTarget.Value.ContainsKey("files"), "XCodeProj Framework Build Phase doesn't have a files array."))
                        {
                            object FrameworkFilesObj = CurrentTarget.Value.data["files"];

                            if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesObj != null, "XCodeProj Framework Build Phase has a files key, but it can't be retrieved."))
                            {
                                if (IgorAssert.EnsureTrue(ModuleInst, typeof(PBXList).IsAssignableFrom(FrameworkFilesObj.GetType()), "XCodeProj Framework Build Phase has a files key, but it can't be cast to PBXList."))
                                {
                                    PBXList FrameworkFilesList = (PBXList)FrameworkFilesObj;

                                    if (IgorAssert.EnsureTrue(ModuleInst, FrameworkFilesList != null, "XCodeProj casted Framework File List is null."))
                                    {
                                        if (FrameworkFilesList.Contains(FrameworkBuildFileGUID))
                                        {
                                            IgorDebug.Log(ModuleInst, "Framework " + Filename + " has already been added to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                        else
                                        {
                                            FrameworkFilesList.Add(FrameworkBuildFileGUID);

                                            CurrentTarget.Value.data["files"] = FrameworkFilesList;

                                            IgorDebug.Log(ModuleInst, "Added the " + Filename + " framework to the Framework Build Phase " + CurrentTarget.Key + ".");
                                        }
                                    }
                                }
                            }
                        }
                    }

                    CurrentProject.Save();
                }
            }
        }
Exemplo n.º 30
0
        public static JobReturnStatus RunJob(bool bFromMenu = false)
        {
            bool bWasStartedManually = false;
            bool bThrewException     = false;
            bool bDone = false;

            try
            {
                if (!IgorJobConfig.GetIsRunning())
                {
                    IgorDebug.CoreLog("Job is starting!");

                    IgorAssert.StartJob();

                    CheckForNamedJobFlag();
                }

                if (IgorJobConfig.GetWasMenuTriggered())
                {
                    bWasStartedManually = true;
                }
                else
                {
                    bWasStartedManually = bFromMenu;

                    IgorJobConfig.SetWasMenuTriggered(bWasStartedManually);
                }

                if (!IgorJobConfig.GetIsRunning() || EnabledModules.Count == 0)
                {
                    RegisterAllModules();
                }

                if (!IgorJobConfig.GetIsRunning() || ActiveModulesForJob.Count == 0)
                {
                    ProcessArgs();
                }

                if (ExecuteSteps())
                {
                    IgorJobConfig.SetIsRunning(false);

                    bDone = true;
                }
            }
            catch (Exception e)
            {
                IgorDebug.CoreLogError("Caught exception while running the job.  Exception is " + (e == null ? "NULL exception!" : e.ToString() +
                                                                                                   (e.InnerException == null ? "\n\nNULL inner exception." : ("\n\nInner: " + e.InnerException.ToString()))));

                bThrewException = true;
            }
            finally
            {
                if (bThrewException || bDone)
                {
                    Cleanup();
                }
            }

            JobReturnStatus NewStatus = new JobReturnStatus();

            NewStatus.bDone               = bDone;
            NewStatus.bFailed             = bThrewException || IgorAssert.HasJobFailed();
            NewStatus.bWasStartedManually = bWasStartedManually;

            return(NewStatus);
        }