public static string GetZipAlignPath(IIgorModule ModuleInst) { string AndroidSDKPath = GetAndroidSDKPath(ModuleInst); string ZipAlignPath = ""; if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(AndroidSDKPath), "The Android SDK path " + AndroidSDKPath + " doesn't exist!")) { string BuildToolsPath = Path.Combine(AndroidSDKPath, "build-tools"); if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(BuildToolsPath), "The Android build tools path " + BuildToolsPath + " doesn't exist!")) { List<string> BuildToolVersions = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(BuildToolsPath, false, true, false, true, true); foreach(string CurrentVersion in BuildToolVersions) { string ZipAlignVersionPath = Path.Combine(BuildToolsPath, Path.Combine(CurrentVersion, "zipalign")); if(File.Exists(ZipAlignVersionPath)) { ZipAlignPath = ZipAlignVersionPath; break; } } IgorAssert.EnsureTrue(ModuleInst, ZipAlignPath != "", "ZipAlign couldn't be found! Have you downloaded the android build-tools?"); } } return ZipAlignPath; }
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); } } }
public static string GetZipAlignPath(IIgorModule ModuleInst) { string AndroidSDKPath = GetAndroidSDKPath(ModuleInst); string ZipAlignPath = ""; if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(AndroidSDKPath), "The Android SDK path " + AndroidSDKPath + " doesn't exist!")) { string BuildToolsPath = Path.Combine(AndroidSDKPath, "build-tools"); if (IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(BuildToolsPath), "The Android build tools path " + BuildToolsPath + " doesn't exist!")) { List <string> BuildToolVersions = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(BuildToolsPath, false, true, false, true, true); foreach (string CurrentVersion in BuildToolVersions) { string ZipAlignVersionPath = Path.Combine(BuildToolsPath, Path.Combine(CurrentVersion, "zipalign")); if (File.Exists(ZipAlignVersionPath)) { ZipAlignPath = ZipAlignVersionPath; break; } } IgorAssert.EnsureTrue(ModuleInst, ZipAlignPath != "", "ZipAlign couldn't be found! Have you downloaded the android build-tools?"); } } return(ZipAlignPath); }
public static int RunProcessCrossPlatform(IIgorModule ModuleInst, string OSXCommand, string WindowsCommand, string Parameters, string Directory, string CommandLogDescription, bool bUseShell = false) { string ProcessOutput = ""; string ProcessError = ""; return(RunProcessCrossPlatform(ModuleInst, OSXCommand, WindowsCommand, Parameters, Directory, CommandLogDescription, ref ProcessOutput, ref ProcessError, bUseShell)); }
public static void ReplaceStringsInFile(IIgorModule ModuleInst, string FilePath, string OriginalString, string NewString) { string FullFilePath = FilePath; if (!File.Exists(FullFilePath)) { FullFilePath = Path.Combine(Path.GetFullPath("."), FilePath); } if (File.Exists(FullFilePath)) { File.SetAttributes(FullFilePath, System.IO.FileAttributes.Normal); } if (IgorAssert.EnsureTrue(ModuleInst, File.Exists(FullFilePath), "Replace string in file failed because " + FullFilePath + " doesn't exist.")) { string FileContents = File.ReadAllText(FilePath); FileContents = FileContents.Replace(OriginalString, NewString); IgorRuntimeUtils.DeleteFile(FileContents); File.WriteAllText(FilePath, FileContents); } }
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(); } }
public static string GetModuleString(IIgorModule Module, string StringKey, string DefaultValue = "") { IgorConfig Inst = GetInstance(); if (Inst != null) { string FullKey = StringKey; if (Module != null) { FullKey = Module.GetModuleName() + "." + FullKey; } foreach (IgorConfigKeyValuePair <string, string> CurrentValue in Inst.ModuleStrings) { if (CurrentValue.Key == FullKey) { return(CurrentValue.Value); } } return(DefaultValue); } return(DefaultValue); }
public static bool RunAnt(IIgorModule ModuleInst, string ProjectDirectory, string Targets) { string ANT_ROOT = IgorRuntimeUtils.GetEnvVariable("ANT_ROOT"); string AntCommand = ""; string FinalParams = ""; #if UNITY_EDITOR_OSX if (ANT_ROOT != "") { AntCommand = Path.Combine(ANT_ROOT, Path.Combine("bin", "ant")); } else { AntCommand = "/usr/bin/ant"; } FinalParams += Targets + " -lib " + Path.Combine(EditorApplication.applicationPath, Path.Combine("Contents", Path.Combine("PlaybackEngines", Path.Combine("AndroidPlayer", Path.Combine("bin", "classes.jar"))))); #else AntCommand = "C:\\Windows\\System32\\cmd.exe"; FinalParams += "/C " + ANT_ROOT + "bin\\ant.bat " + Targets + " -lib " + Path.Combine(EditorApplication.applicationPath, Path.Combine("Data", Path.Combine("PlaybackEngines", Path.Combine("androidplayer", Path.Combine("bin", "classes.jar"))))); #endif // UNITY_EDITOR_OSX if (!IgorAssert.EnsureTrue(ModuleInst, File.Exists(AntCommand), "Can't find the Ant executable! Did you set your ANT_ROOT?")) { return(false); } // IgorCore.LogError(ModuleInst, "Ant params are " + FinalParams); return(IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, AntCommand, AntCommand, FinalParams, ProjectDirectory, "Running Ant build") == 0); }
public static void SetModuleString(IIgorModule Module, string StringKey, string Value) { IgorConfig Inst = GetInstance(); if (Inst != null) { string FullKey = StringKey; if (Module != null) { FullKey = Module.GetModuleName() + "." + FullKey; } int CurrentIndex = 0; foreach (IgorConfigKeyValuePair <string, string> CurrentValue in Inst.ModuleStrings) { if (CurrentValue.Key == FullKey) { Inst.ModuleStrings[CurrentIndex].Value = Value; return; } ++CurrentIndex; } IgorConfigKeyValuePair <string, string> NewInst = new IgorConfigKeyValuePair <string, string>(FullKey, Value); Inst.ModuleStrings.Add(NewInst); } }
protected static void StaticRegisterJobStep(StepID CurrentStep, IIgorModule Module, IgorRuntimeUtils.JobStepFunc StepFunction) { List <JobStep> NewSteps = new List <JobStep>(); StepID Priority = new StepID(); foreach (KeyValuePair <StepID, List <JobStep> > CurrentPriority in JobSteps) { if (CurrentPriority.Key.StepPriority == CurrentStep.StepPriority) { NewSteps = CurrentPriority.Value; Priority = CurrentPriority.Key; break; } } NewSteps.Add(new JobStep(Module, StepFunction)); if (JobSteps.ContainsKey(Priority)) { JobSteps[Priority] = NewSteps; } else { JobSteps.Add(CurrentStep, NewSteps); } }
public static bool GetModuleBool(IIgorModule Module, string BoolKey, bool bDefaultValue = false) { IgorConfig Inst = GetInstance(); if (Inst != null) { string FullKey = BoolKey; if (Module != null) { FullKey = Module.GetModuleName() + "." + FullKey; } foreach (IgorConfigKeyValuePair <string, bool> CurrentValue in Inst.ModuleBools) { if (CurrentValue.Key == FullKey) { return(CurrentValue.Value); } } return(bDefaultValue); } return(bDefaultValue); }
public static void ReplaceStringsInFile(IIgorModule ModuleInst, string FilePath, string OriginalString, string NewString) { string FullFilePath = FilePath; if(!File.Exists(FullFilePath)) { FullFilePath = Path.Combine(Path.GetFullPath("."), FilePath); } if(File.Exists(FullFilePath)) { File.SetAttributes(FullFilePath, System.IO.FileAttributes.Normal); } if(IgorAssert.EnsureTrue(ModuleInst, File.Exists(FullFilePath), "Replace string in file failed because " + FullFilePath + " doesn't exist.")) { string FileContents = File.ReadAllText(FilePath); FileContents = FileContents.Replace(OriginalString, NewString); IgorRuntimeUtils.DeleteFile(FileContents); File.WriteAllText(FilePath, FileContents); } }
public static bool VerifyTrue(IIgorModule Module, bool bTrue, string FailMessage) { if(!bTrue) { IgorDebug.LogWarning(Module, FailMessage); } return bTrue; }
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."); } } } } } } } } } }
public static bool VerifyTrue(IIgorModule Module, bool bTrue, string FailMessage) { if (!bTrue) { IgorDebug.LogWarning(Module, FailMessage); } return(bTrue); }
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(); } } }
public override bool IsDependentOnModule(IIgorModule ModuleInst) { if (ModuleInst.GetModuleName() == "Configure.SetScriptingDefines") { return(true); } return(false); }
public static void LogError(IIgorModule Module, string Message) { if (Logger != null) { Logger.LogError(Module, Message); } else { Debug.LogError("Igor Error: " + Module + " : " + Message); } }
public virtual void LogWarning(IIgorModule Module, string Message) { if (Module != null) { Debug.LogWarning("Igor Warning: " + Module.GetModuleName() + " : " + Message); } else { LogWarning(Message); } }
public virtual void LogError(IIgorModule Module, string Message) { if (Module != null) { Debug.LogError("Igor Error: " + Module.GetModuleName() + " : " + Message); } else { LogError(Message); } }
public virtual void LogWarning(IIgorModule Module, string Message) { if(Module != null) { Debug.LogWarning("Igor Warning: " + Module.GetModuleName() + " : " + Message); } else { LogWarning(Message); } }
public static void LogWarning(IIgorModule Module, string Message) { if (Logger != null) { Logger.LogWarning(Module, Message); } else { Debug.LogWarning("Igor Warning: " + Module + " : " + Message); } }
public virtual void LogError(IIgorModule Module, string Message) { if(Module != null) { Debug.LogError("Igor Error: " + Module.GetModuleName() + " : " + Message); } else { LogError(Message); } }
public static bool StaticIsModuleNeededByOtherModules(IIgorModule Module) { foreach (IIgorModule CurrentModule in EnabledModules) { if (CurrentModule.IsDependentOnModule(Module)) { return(true); } } return(false); }
public static void RegisterAllModules() { foreach (Type CurrentType in ModuleTypes) { IIgorModule CurrentModule = (IIgorModule)Activator.CreateInstance(CurrentType); if (CurrentModule != null) { CurrentModule.RegisterModule(); } } }
public static bool EnsureTrue(IIgorModule Module, bool bTrue, string FailMessage) { if(!bTrue) { IgorDebug.LogWarning(Module, FailMessage); JobFailed(); Debug.Break(); } return bTrue; }
public static bool EnsureTrue(IIgorModule Module, bool bTrue, string FailMessage) { if (!bTrue) { IgorDebug.LogWarning(Module, FailMessage); JobFailed(); Debug.Break(); } return(bTrue); }
public virtual void CriticalError(IIgorModule Module, string Message) { if (Module != null) { Debug.LogError("Igor Error: " + Module.GetModuleName() + " : " + Message); throw new UnityException(Message); } else { LogError(Message); } }
public static void UnzipArchiveCrossPlatform(IIgorModule ModuleInst, string ZipFilename, string DirectoryToUnzipTo, bool bUpdateBuildProducts = false) { IgorRuntimeUtils.PlatformNames CurrentPlatform = IgorRuntimeUtils.RuntimeOrEditorGetPlatform(); if (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_OSX || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_OSX) { UnzipFileMac(ModuleInst, ZipFilename, DirectoryToUnzipTo, bUpdateBuildProducts); } else if (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_Windows || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_Windows) { UnzipFileWindows(ModuleInst, ZipFilename, DirectoryToUnzipTo, bUpdateBuildProducts); } }
public static void CriticalError(IIgorModule Module, string Message) { if (Logger != null) { Logger.CriticalError(Module, Message); } else { Debug.LogError("Igor Error: " + Module + " : " + Message); throw new UnityException(Module + " : " + Message); } }
public virtual void CriticalError(IIgorModule Module, string Message) { if(Module != null) { Debug.LogError("Igor Error: " + Module.GetModuleName() + " : " + Message); throw new UnityException(Message); } else { LogError(Message); } }
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); } } }
public static bool AssertTrue(IIgorModule Module, bool bTrue, string FailMessage) { #if DEBUG if (!bTrue) { IgorDebug.LogError(Module, FailMessage); JobFailed(); Debug.Break(); } #endif return(bTrue); }
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(); } }
public static bool AssertTrue(IIgorModule Module, bool bTrue, string FailMessage) { #if DEBUG if(!bTrue) { IgorDebug.LogError(Module, FailMessage); JobFailed(); Debug.Break(); } #endif return bTrue; }
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); }
public static void ZipFilesCrossPlatform(IIgorModule ModuleInst, List <string> FilesToZip, string ZipFilename, bool bUpdateBuildProducts = true, string RootDir = ".") { if (File.Exists(ZipFilename)) { IgorRuntimeUtils.DeleteFile(ZipFilename); } IgorRuntimeUtils.PlatformNames CurrentPlatform = IgorRuntimeUtils.RuntimeOrEditorGetPlatform(); if (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_OSX || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_OSX) { ZipFilesMac(ModuleInst, FilesToZip, ZipFilename, bUpdateBuildProducts, RootDir); } else if (CurrentPlatform == IgorRuntimeUtils.PlatformNames.Editor_Windows || CurrentPlatform == IgorRuntimeUtils.PlatformNames.Standalone_Windows) { ZipFilesWindows(ModuleInst, FilesToZip, ZipFilename, bUpdateBuildProducts, RootDir); } }
public static bool ResignAPK(IIgorModule ModuleInst, string SourceAPK, string RepackagingDirectory, ref string FinalFilename, string KeystoreFilename, string KeystorePassword, string KeyAlias, string KeyAliasPassword) { if (Directory.Exists(RepackagingDirectory)) { IgorRuntimeUtils.DeleteDirectory(RepackagingDirectory); } Directory.CreateDirectory(RepackagingDirectory); IgorZip.UnzipArchiveCrossPlatform(ModuleInst, SourceAPK, RepackagingDirectory); IgorRuntimeUtils.DeleteDirectory(Path.Combine(RepackagingDirectory, "META-INF")); string UnsignedAPK = Path.Combine(RepackagingDirectory, "Repackaged.unsigned.apk"); List <string> APKContents = IgorRuntimeUtils.GetListOfFilesAndDirectoriesInDirectory(RepackagingDirectory); IgorZip.ZipFilesCrossPlatform(ModuleInst, APKContents, UnsignedAPK, false, RepackagingDirectory); string SignedAPK = Path.Combine(RepackagingDirectory, "Repackaged.signed.apk"); // IgorCore.LogError(ModuleInst, "jarsigner command running from " + Path.GetFullPath(".") + " is\n" + "-verbose -keystore \"" + KeystoreFilename + "\" -storepass " + KeystorePassword + // " -keypass " + KeyAliasPassword + " -signedjar \"" + SignedAPK + "\" \"" + UnsignedAPK + "\" " + KeyAlias); if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, "jarsigner", "jarsigner", "-verbose -sigalg SHA1withDSA -digestalg SHA1 -keystore \"" + KeystoreFilename + "\" -storepass " + KeystorePassword + " -keypass " + KeyAliasPassword + " -signedjar \"" + SignedAPK + "\" \"" + UnsignedAPK + "\" " + KeyAlias, Path.GetFullPath("."), "Running jarsigner", true) != 0) { return(false); } string ZipAlignPath = GetZipAlignPath(ModuleInst); string AlignedAPK = Path.Combine(RepackagingDirectory, "Repackaged.aligned.apk"); if (IgorRuntimeUtils.RunProcessCrossPlatform(ModuleInst, ZipAlignPath, ZipAlignPath, "-v 4 \"" + SignedAPK + "\" \"" + AlignedAPK + "\"", Path.GetFullPath("."), "Running zipalign") != 0) { return(false); } FinalFilename = AlignedAPK; return(true); }
public virtual bool IsModuleNeededByOtherModules(IIgorModule Module) { return StaticIsModuleNeededByOtherModules(Module); }
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(); } }
public static bool StaticIsModuleNeededByOtherModules(IIgorModule Module) { foreach(IIgorModule CurrentModule in EnabledModules) { if(CurrentModule.IsDependentOnModule(Module)) { return true; } } return false; }
public static void AddFunctionToAppControllerSource(IIgorModule ModuleInst, string PathToProject, string FunctionSource) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "@implementation UnityAppController", "@implementation UnityAppController\n" + FunctionSource); }
public static void AddSourceToApplicationDidBecomeActive(IIgorModule ModuleInst, string PathToProject, string AdditionalSource) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "printf_console(\"-> applicationDidBecomeActive()\\n\");", AdditionalSource + "\nprintf_console(\"-> applicationDidBecomeActive()\\n\");"); }
public static void CriticalError(IIgorModule Module, string Message) { if(Logger != null) { Logger.CriticalError(Module, Message); } else { Debug.LogError("Igor Error: " + Module + " : " + Message); throw new UnityException(Module + " : " + Message); } }
public static bool RegisterNewModule(IIgorModule NewModule) { if(StaticGetEnabledModuleNames().Contains(NewModule.GetModuleName())) { bool bFound = false; foreach(IIgorModule CurrentModule in EnabledModules) { if(CurrentModule.GetModuleName() == NewModule.GetModuleName()) { bFound = true; } } if(!bFound) { EnabledModules.Add(NewModule); return true; } } return false; }
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(); } } }
public static string AddNewFileReference(IIgorModule ModuleInst, string ProjectPath, string Filename, TreeEnum TreeBase, string Path = "", int FileEncoding = -1, string LastKnownFileType = "", string Name = "") { if(IgorAssert.EnsureTrue(ModuleInst, Directory.Exists(ProjectPath), "XCodeProj doesn't exist at path " + ProjectPath)) { XCProject CurrentProject = new XCProject(ProjectPath); CurrentProject.Backup(); foreach(KeyValuePair<string, PBXFileReference> CurrentFileRef in CurrentProject.fileReferences) { if(CurrentFileRef.Value.name == Filename) { IgorDebug.Log(ModuleInst, "The file " + Filename + " is already referenced in the XCodeProj."); return CurrentFileRef.Value.guid; } } PBXFileReference NewFile = new PBXFileReference(Filename, TreeBase); if(Path != "") { if(NewFile.ContainsKey("path")) { NewFile.Remove("path"); } NewFile.Add("path", Path); } if(FileEncoding != -1) { if(NewFile.ContainsKey("fileEncoding")) { NewFile.Remove("fileEncoding"); } NewFile.Add("fileEncoding", FileEncoding); } if(LastKnownFileType != "") { if(NewFile.ContainsKey("lastKnownFileType")) { NewFile.Remove("lastKnownFileType"); } NewFile.Add("lastKnownFileType", LastKnownFileType); } if(Name != "") { if(NewFile.ContainsKey("name")) { NewFile.Remove("name"); } NewFile.Add("name", Name); } CurrentProject.fileReferences.Add(NewFile); IgorDebug.Log(ModuleInst, "File " + Filename + " has been added to the XCodeProj."); CurrentProject.Save(); return NewFile.guid; } return ""; }
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(); } } } } } } }
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(); } }
protected static void StaticRegisterJobStep(StepID CurrentStep, IIgorModule Module, IgorRuntimeUtils.JobStepFunc StepFunction) { List<JobStep> NewSteps = new List<JobStep>(); StepID Priority = new StepID(); foreach(KeyValuePair<StepID, List<JobStep>> CurrentPriority in JobSteps) { if(CurrentPriority.Key.StepPriority == CurrentStep.StepPriority) { NewSteps = CurrentPriority.Value; Priority = CurrentPriority.Key; break; } } NewSteps.Add(new JobStep(Module, StepFunction)); if(JobSteps.ContainsKey(Priority)) { JobSteps[Priority] = NewSteps; } else { JobSteps.Add(CurrentStep, NewSteps); } }
public static void LogWarning(IIgorModule Module, string Message) { if(Logger != null) { Logger.LogWarning(Module, Message); } else { Debug.LogWarning("Igor Warning: " + Module + " : " + Message); } }
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(); } } }
public virtual void RegisterJobStep(StepID CurrentStep, IIgorModule Module, IgorRuntimeUtils.JobStepFunc StepFunction) { StaticRegisterJobStep(CurrentStep, Module, StepFunction); }
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 ""; }
public override bool IsDependentOnModule(IIgorModule ModuleInst) { if(ModuleInst.GetModuleName() == "Configure.SetScriptingDefines") { return true; } return false; }
public static void AddHeaderToAppControllerSource(IIgorModule ModuleInst, string PathToProject, string HeaderFile) { IgorUtils.ReplaceStringsInFile(ModuleInst, Path.Combine(PathToProject, Path.Combine("Classes", "UnityAppController.mm")), "@implementation UnityAppController", "#import \"" + HeaderFile + "\"\n@implementation UnityAppController"); }
public static void LogError(IIgorModule Module, string Message) { if(Logger != null) { Logger.LogError(Module, Message); } else { Debug.LogError("Igor Error: " + Module + " : " + Message); } }
public static void SetModuleActiveForJob(IIgorModule NewModule) { if(EnabledModules.Contains(NewModule) && !ActiveModulesForJob.Contains(NewModule)) { bool bFound = false; foreach(IIgorModule CurrentModule in ActiveModulesForJob) { if(CurrentModule.GetModuleName() == NewModule.GetModuleName()) { bFound = true; } } if(!bFound) { ActiveModulesForJob.Add(NewModule); } } }
public virtual bool IsDependentOnModule(IIgorModule ModuleInst) { return false; }
public JobStep(IIgorModule Module, IgorRuntimeUtils.JobStepFunc Function) { ModuleInst = Module; StepFunction = Function; }