public virtual bool BuildOculus() { List <string> BuiltDesktopFiles = new List <string>(); BuiltDesktopFiles.AddRange(IgorCore.GetModuleProducts()); string OculusDirectToRiftFilename = ""; foreach (string CurrentFile in BuiltDesktopFiles) { if (CurrentFile.EndsWith(".exe")) { OculusDirectToRiftFilename = CurrentFile.Replace(".exe", "_DirectToRift.exe"); } } if (File.Exists(OculusDirectToRiftFilename)) { BuiltDesktopFiles.Add(OculusDirectToRiftFilename); } IgorCore.SetNewModuleProducts(BuiltDesktopFiles); return(true); }
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 virtual bool Build() { string BuiltName = GetBuiltNameForTarget(JobBuildTarget); string BuiltBaseName = BuiltName; if (BuiltBaseName.Contains(".")) { BuiltBaseName = BuiltName.Substring(0, BuiltBaseName.LastIndexOf('.')); } string DataFolderName = BuiltBaseName + "_Data"; if (File.Exists(BuiltName)) { IgorRuntimeUtils.DeleteFile(BuiltName); } if (Directory.Exists(DataFolderName)) { IgorRuntimeUtils.DeleteDirectory(DataFolderName); } #if !UNITY_4_3 BuiltName = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), BuiltName); #endif BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), BuiltName, JobBuildTarget, IgorBuildCommon.GetBuildOptions()); Log("Destination file is: " + BuiltName); List <string> BuiltFiles = new List <string>(); if (Directory.Exists(DataFolderName)) { if (IgorAssert.EnsureTrue(this, File.Exists(BuiltName), "The built file " + BuiltName + " doesn't exist. Something went wrong during the build step. Please check the logs!")) { BuiltFiles.Add(BuiltName); } if (IgorAssert.EnsureTrue(this, Directory.Exists(DataFolderName), "The built data directory for the Windows build " + DataFolderName + " doesn't exist. Something went wrong during the build step. Please check the logs!")) { BuiltFiles.Add(DataFolderName); } } else { if (IgorAssert.EnsureTrue(this, Directory.Exists(BuiltName), "The built app directory for the Mac build " + BuiltName + " doesn't exist. Something went wrong during the build step. Please check the logs!")) { BuiltFiles.Add(BuiltName); } } IgorCore.SetNewModuleProducts(BuiltFiles); return(true); }
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 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); } } } }
public virtual bool CopyToFromSync(bool bToSync) { string LocalFile = ""; if (bToSync) { List <string> BuiltProducts = IgorCore.GetModuleProducts(); IgorAssert.EnsureTrue(this, BuiltProducts.Count == 1, "This module requires exactly one built file, but we found " + BuiltProducts.Count + " instead. Please make sure you've enabled a package step prior to this one."); if (BuiltProducts.Count > 0) { LocalFile = BuiltProducts[0]; } } else { LocalFile = GetParamOrConfigString(CopyToLocalDirFlag, "", Path.GetFullPath("."), false); } if (IgorAssert.EnsureTrue(this, !bToSync || File.Exists(LocalFile), "BitTorrent Sync copy was told to copy file " + LocalFile + ", but the file doesn't exist!")) { string SyncFile = ""; if (IgorJobConfig.IsBoolParamSet(CopyToSyncExpEnabledFlag)) { SyncFile = GetParamOrConfigString(CopyToSyncExplicitFlag, "BitTorrent Sync copy to sync explicit is enabled, but the path isn't set."); } if (SyncFile == "" && IgorJobConfig.IsBoolParamSet(CopyToSyncEnvEnabledFlag)) { string EnvVariable = GetParamOrConfigString(CopyToSyncEnvFlag, "BitTorrent Sync copy to sync based on environment variable is enabled, but the env variable name isn't set."); if (EnvVariable == "") { return(true); } SyncFile = IgorRuntimeUtils.GetEnvVariable(EnvVariable); if (!IgorAssert.EnsureTrue(this, SyncFile != "", "The BitTorrent Sync root path environment variable " + EnvVariable + " isn't set.")) { return(true); } } string SyncFilename = GetParamOrConfigString(CopyToSyncFilenameFlag, (bToSync ? "BitTorrent Sync copy to sync destination filename isn't set." : "BitTorrent Sync copy from sync source filename isn't set.")); if (SyncFilename == "") { return(true); } SyncFile = Path.Combine(SyncFile, SyncFilename); if (bToSync) { if (File.Exists(SyncFile)) { IgorRuntimeUtils.DeleteFile(SyncFile); } IgorRuntimeUtils.CopyFile(LocalFile, SyncFile); Log("File " + LocalFile + " copied to requested location " + SyncFile + " for BitTorrent Sync uploading."); } else { LocalFile = Path.Combine(LocalFile, Path.GetFileName(SyncFile)); if (File.Exists(LocalFile)) { IgorRuntimeUtils.DeleteFile(LocalFile); } IgorRuntimeUtils.CopyFile(SyncFile, LocalFile); Log("File " + SyncFile + " copied from the BitTorrent Sync share to requested location " + LocalFile + "."); List <string> NewProducts = new List <string>(); NewProducts.Add(LocalFile); IgorCore.SetNewModuleProducts(NewProducts); } } return(true); }
public virtual bool CreateWebDeployFiles() { List <string> BuiltProducts = IgorCore.GetModuleProducts(); string FileToCopy = ""; string RootProjectDirectory = ""; string WebDeployTempDir = Path.Combine(Path.GetFullPath("."), "iOSOTATemp"); if (IgorAssert.EnsureTrue(this, BuiltProducts.Count > 1, "iOS OTA expected at least two built products, the IPA and the iOS XCode project directory.")) { FileToCopy = BuiltProducts[0]; RootProjectDirectory = BuiltProducts[1]; } if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "iOS OTA expected the IPA to be at " + FileToCopy + ", but it was not there.") && IgorAssert.EnsureTrue(this, Directory.Exists(RootProjectDirectory), "iOS OTA expected the XCode Project folder to be at " + RootProjectDirectory + ", but it was not there.")) { if (Directory.Exists(WebDeployTempDir)) { IgorRuntimeUtils.DeleteDirectory(WebDeployTempDir); } Directory.CreateDirectory(WebDeployTempDir); string PlistPath = Path.Combine(RootProjectDirectory, "Info.plist"); string BundleIdentifier = PlayerSettings.bundleIdentifier; string BundleVersion = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleVersion"); string DisplayName = IgorPlistUtils.GetStringValue(this, PlistPath, "CFBundleDisplayName"); string OTAManifestPath = GetParamOrConfigString(OTAPlistNameFlag, "", "Application", false); if (!OTAManifestPath.EndsWith(".plist")) { OTAManifestPath += ".plist"; } OTAManifestPath = Path.Combine(WebDeployTempDir, OTAManifestPath); string FullIconName = Path.Combine(RootProjectDirectory, Path.Combine("Unity-iPhone", Path.Combine("Images.xcassets", Path.Combine("AppIcon.appiconset", "Icon.png")))); string IPAName = Path.GetFileName(FileToCopy); string IconName = Path.GetFileName(FullIconName); GenerateAndSavePlist(OTAManifestPath, IPAName, IconName, BundleIdentifier, BundleVersion, DisplayName); string IPADeployName = Path.Combine(WebDeployTempDir, IPAName); string IconDeployName = Path.Combine(WebDeployTempDir, IconName); IgorRuntimeUtils.CopyFile(FileToCopy, IPADeployName); IgorRuntimeUtils.CopyFile(FullIconName, IconDeployName); List <string> NewBuiltProducts = new List <string>(); NewBuiltProducts.Add(OTAManifestPath); NewBuiltProducts.Add(IPADeployName); NewBuiltProducts.Add(IconDeployName); IgorCore.SetNewModuleProducts(NewBuiltProducts); Log("iOS OTA files successfully generated."); } return(true); }
public virtual bool BuildAndroidProj() { List <string> BuildProducts = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Building the Android project, but there were no previous built products.")) { Log("Project should be saved to " + EditorUserBuildSettings.GetBuildLocation(BuildTarget.Android)); string BuiltProjectDir = Path.Combine(BuildProducts[0], PlayerSettings.productName); if (!RunAndroidCommandLineUtility(this, BuiltProjectDir, "update project --path ." + AndroidProjectUpdateAdditionalArgs)) { return(true); } string BuildXML = Path.Combine(BuiltProjectDir, "build.xml"); if (!IgorAssert.EnsureTrue(this, File.Exists(BuildXML), "Can't check " + BuildXML + " for APK name because it doesn't exist.")) { return(false); } string BuildXMLFileContents = File.ReadAllText(BuildXML); int ProjectNameParamStart = BuildXMLFileContents.IndexOf("<project name=\"") + "<project name=\"".Length; int ProjectNameParamEnd = BuildXMLFileContents.IndexOf("\"", ProjectNameParamStart); string APKName = BuildXMLFileContents.Substring(ProjectNameParamStart, ProjectNameParamEnd - ProjectNameParamStart); if (!RunAnt(this, BuiltProjectDir, "clean debug")) { return(true); } Log("Debug APK built!"); string DebugSignedAPK = Path.Combine(BuiltProjectDir, Path.Combine("bin", APKName + "-debug.apk")); string AppropriatelySignedAPK = DebugSignedAPK; if (IgorJobConfig.IsBoolParamSet(AndroidResignInReleaseFlag)) { Log("Re-signing the APK for release."); string RepackageDir = Path.Combine(BuildProducts[0], "Repackage"); if (!ResignAPK(this, DebugSignedAPK, RepackageDir, ref AppropriatelySignedAPK, GetParamOrConfigString(AndroidKeystoreFilenameFlag, "Android Keystore filename isn't set, but you want to re-sign the APK!"), GetParamOrConfigString(AndroidKeystorePassFlag, "Android Keystore password isn't set, but you want to re-sign the APK!"), GetParamOrConfigString(AndroidKeyAliasFlag, "Android Key Alias isn't set, but you want to re-sign the APK!"), GetParamOrConfigString(AndroidKeyAliasPassFlag, "Android Key Alias password isn't set, but you want to re-sign the APK!"))) { return(true); } Log("Re-signing the APK succeeded!"); } string FinalBuildProductName = GetBuiltNameForTarget(BuildTarget.Android); if (File.Exists(FinalBuildProductName)) { IgorRuntimeUtils.DeleteFile(FinalBuildProductName); } IgorRuntimeUtils.CopyFile(AppropriatelySignedAPK, FinalBuildProductName); List <string> NewBuildProducts = new List <string>(); if (IgorAssert.EnsureTrue(this, File.Exists(AppropriatelySignedAPK), "The built APK " + AppropriatelySignedAPK + " doesn't exist. Something went wrong during the build step. Please check the logs!")) { NewBuildProducts.Add(AppropriatelySignedAPK); } IgorCore.SetNewModuleProducts(NewBuildProducts); Log("APK built and renamed to " + AppropriatelySignedAPK + "."); } return(true); }
public virtual bool Build(BuildOptions PlatformSpecificOptions) { if (!IgorAssert.EnsureTrue(this, GetAndroidSDKPath(this) != "", "Android SDK path is not set!")) { return(true); } PlayerSettings.Android.keystorePass = GetParamOrConfigString(AndroidKeystorePassFlag, "Your Android Keystore Password isn't set! We won't be able to sign your application!"); PlayerSettings.Android.keyaliasPass = GetParamOrConfigString(AndroidKeyAliasPassFlag, "Your Android Key Alias Password isn't set! We won't be able to sign your application!"); if (PlayerSettings.Android.keystorePass == "" || PlayerSettings.Android.keyaliasPass == "") { return(true); } FixReadOnlyFilesIn3rdPartyLibs(); string AndroidProjDirectory = Path.Combine(Path.GetFullPath("."), "Android"); if (AndroidProjDirectory.Contains(" ")) { AndroidProjDirectory = Path.Combine(Path.GetTempPath() + PlayerSettings.productName, "Android"); } if (Directory.Exists(AndroidProjDirectory)) { IgorRuntimeUtils.DeleteDirectory(AndroidProjDirectory); } string FullBuiltPath = System.IO.Path.Combine(System.IO.Path.GetFullPath("."), GetBuiltNameForTarget(BuildTarget.Android)); if (File.Exists(FullBuiltPath)) { IgorRuntimeUtils.DeleteFile(FullBuiltPath); } // We need to force create the directory before we use it or it will prompt us for a path to build to Directory.CreateDirectory(AndroidProjDirectory); Log("Android project destination directory is: " + AndroidProjDirectory); EditorUserBuildSettings.symlinkLibraries = true; EditorUserBuildSettings.exportAsGoogleAndroidProject = true; EditorUserBuildSettings.SetBuildLocation(BuildTarget.Android, AndroidProjDirectory); BuildOptions AllOptions = PlatformSpecificOptions | BuildOptions.AcceptExternalModificationsToPlayer; AllOptions |= GetExternalBuildOptions(JobBuildTarget); BuildPipeline.BuildPlayer(IgorUtils.GetLevels(), AndroidProjDirectory, BuildTarget.Android, AllOptions); CopyActivityOverrideSourceFiles(AndroidProjDirectory); List <string> BuiltFiles = new List <string>(); BuiltFiles.Add(AndroidProjDirectory); IgorCore.SetNewModuleProducts(BuiltFiles); Log("Android Eclipse project has been created."); return(true); }