public virtual bool UpdateAndroidProj() { List <string> BuildProducts = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the Android project, but one was not generated in the build phase!")) { string RootJavaPluginSource = Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("Android", Path.Combine("src", "com")))); string RootJavaDest = Path.Combine(BuildProducts[0], Path.Combine(PlayerSettings.productName, Path.Combine("src", "com"))); CopyJavaFilesAndReplacePackageName(RootJavaPluginSource, RootJavaDest); string ResourcePath = Path.Combine(BuildProducts[0], Path.Combine(PlayerSettings.productName, "res")); string AppID = GetParamOrConfigString(FacebookAndroidAppIDFlag, "Android Facebook ID isn't set, but we've enabled Facebook! This will probably cause the app to crash on startup!"); IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE"); IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-es"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE"); IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-he"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE"); IgorBuildAndroid.SwapStringValueInStringsXML(Path.Combine(Path.Combine(ResourcePath, "values-iw"), "strings.xml"), "fbapp_id", AppID, "FACEBOOKAPPIDTOREPLACE"); if (IgorBuildAndroid.RunAndroidCommandLineUtility(this, Path.Combine(BuildProducts[0], "facebook"), "update project --path .")) { IgorBuildAndroid.AddNewLibrary("facebook"); } } return(true); }
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 virtual bool UnzipProducts() { List <string> ZipFilename = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, ZipFilename.Count == 1, "Unzipping expected exactly 1 built product, but we found " + ZipFilename.Count)) { Log("Unzipping file " + ZipFilename[0]); UnzipArchiveCrossPlatform(this, ZipFilename[0], Path.GetFullPath("."), true); } return(true); }
public virtual bool UpdateXCodeProj() { List <string> BuildProducts = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!")) { string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj"); IgorXCodeProjUtils.AddFramework(this, ProjectPath, "StoreKit.framework", TreeEnum.SDKROOT, "System/Library/Frameworks/StoreKit.framework", -1, "wrapper.framework", "StoreKit.framework"); } return(true); }
public virtual bool RunTest(string TestName) { MonsterDebug.Log("Attempting to run test " + TestName + " on a standalone copy of the game."); Environment.SetEnvironmentVariable(MonsterTestCore.MonsterStarterTestNameEnvVariable, TestName); string AppPath = ""; if (IgorJobConfig.IsStringParamSet(MonsterTestCore.ExplicitAppPathFlag)) { AppPath = IgorJobConfig.GetStringParam(MonsterTestCore.ExplicitAppPathFlag); } else { foreach (string CurrentProduct in IgorCore.GetModuleProducts()) { if (CurrentProduct.Contains(".app")) { AppPath = CurrentProduct.Substring(0, CurrentProduct.IndexOf(".app") + 4); } else if (CurrentProduct.EndsWith(".exe")) { AppPath = CurrentProduct; } } } if (AppPath.EndsWith(".app")) { AppPath = Path.Combine(AppPath, Path.Combine("Contents", Path.Combine("MacOS", AppPath.Substring(AppPath.LastIndexOf('/') + 1, AppPath.Length - AppPath.LastIndexOf('/') - 5)))); IgorRuntimeUtils.SetFileExecutable(AppPath); } string AppOutput = ""; string AppError = ""; int RunAppRC = IgorRuntimeUtils.RunProcessCrossPlatform(AppPath, AppPath, "", Path.GetFullPath("."), ref AppOutput, ref AppError); if (RunAppRC != 0) { MonsterDebug.LogError("Failed to run test. App retruned RC " + RunAppRC + "!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError); return(true); } MonsterDebug.Log("Test ran successfully!\n\nOutput:\n" + AppOutput + "\n\nError:\n" + AppError); return(true); }
public virtual bool CreateZip() { string ZipFilename = GetParamOrConfigString(ZipFilenameFlag, "Zip destination filename is not set."); string LogDetails = "Creating zip file with name " + ZipFilename + " from files:"; List <string> BuiltProducts = IgorCore.GetModuleProducts(); foreach (string Product in BuiltProducts) { LogDetails += "\n" + Product; } Log(LogDetails); ZipFilesCrossPlatform(this, BuiltProducts, ZipFilename); return(true); }
public virtual bool UpdateXCodeProj() { string FacebookID = GetParamOrConfigString(FacebookIDFlag, "Your Facebook ID hasn't been set! Facebook functionality will probably not work correctly."); string FacebookDisplayName = GetParamOrConfigString(FacebookDisplayNameFlag, "Your Facebook Display Name hasn't been set! Facebook functionality will probably not work correctly."); List <string> BuildProducts = IgorCore.GetModuleProducts(); if (IgorAssert.EnsureTrue(this, BuildProducts.Count > 0, "Attempting to update the XCode project, but one was not generated in the build phase!")) { string ProjectPath = Path.Combine(BuildProducts[0], "Unity-IPhone.xcodeproj"); string FacebookIntegrationGUID = IgorXCodeProjUtils.AddNewFileReference(this, ProjectPath, "FacebookIntegration.h", TreeEnum.GROUP); IgorXCodeProjUtils.SortGUIDIntoGroup(this, ProjectPath, FacebookIntegrationGUID, "Libraries"); IgorXCodeProjUtils.AddFramework(this, ProjectPath, "FacebookSDK.framework", TreeEnum.GROUP, "Libraries/FacebookSDK.framework", -1, "wrapper.framework", "FacebookSDK.framework"); IgorXCodeProjUtils.AddFrameworkSearchPath(this, ProjectPath, "$(SRCROOT)/Libraries"); string PlistPath = Path.Combine(BuildProducts[0], "Info.plist"); IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookAppID", FacebookID); IgorPlistUtils.SetStringValue(this, PlistPath, "FacebookDisplayName", FacebookDisplayName); IgorPlistUtils.AddBundleURLType(this, PlistPath, "fb" + FacebookID); IgorZip.UnzipArchiveCrossPlatform(this, Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("iOS", Path.Combine("FacebookSDK", "FacebookSDK.framework.zip"))))), Path.Combine(BuildProducts[0], "Libraries")); IgoriOSSourceUtils.AddHeaderToAppControllerSource(this, BuildProducts[0], "../Libraries/FacebookIntegration.h"); IgoriOSSourceUtils.AddFunctionToAppControllerSource(this, BuildProducts[0], "/* Pre iOS 4.2 support */\n- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url\n{\n\treturn [FBSession.activeSession handleOpenURL:url];\n}\n"); IgorUtils.ReplaceStringsInFile(this, Path.Combine(BuildProducts[0], Path.Combine("Classes", "UnityAppController.mm")), "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);\n\treturn YES;", "AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData); return [FBSession.activeSession handleOpenURL:url];"); IgoriOSSourceUtils.AddSourceToApplicationDidBecomeActive(this, BuildProducts[0], "[FBSession.activeSession handleDidBecomeActive];"); } return(true); }
public virtual bool UploadToFTP() { 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."); string FileToCopy = ""; if (BuiltProducts.Count > 0) { FileToCopy = BuiltProducts[0]; } if (IgorAssert.EnsureTrue(this, File.Exists(FileToCopy), "JenkinsFTP upload was looking for the file " + FileToCopy + " to upload, but the file couldn't be found.")) { Cleanup(); IgorRuntimeUtils.CopyFile(FileToCopy, GetParamOrConfigString(UploadToFTPFlag, "Destination file for JenkinsFTP isn't set so we can't copy it to the right location.")); Log("File copied to requested location for Jenkins post build FTP uploading."); } return(true); }
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 UploadToFTP() { List <string> BuiltProducts = IgorCore.GetModuleProducts(); string FTPRoot = GetParamOrConfigString(UploadToFTPHostFlag, "FTP Upload host is not set! Can't upload without a host!"); string FTPUsername = GetParamOrConfigString(UploadToFTPUserFlag, "FTP Upload username is not set! Can't upload without a username!"); string FTPPassword = GetParamOrConfigString(UploadToFTPPassFlag, "FTP Upload password is not set! Can't upload without a password!"); string FTPDirectory = GetParamOrConfigString(UploadToFTPDirectoryFlag); if (!FTPRoot.StartsWith("ftp://")) { FTPRoot = "ftp://" + FTPRoot; } if (!FTPRoot.EndsWith("/")) { FTPRoot += "/"; } if (FTPDirectory.Length > 0 && !FTPDirectory.EndsWith("/")) { FTPDirectory += "/"; } if (FTPRoot != "" && FTPUsername != "" && FTPPassword != "") { bool bFailedAtLeastOnce = false; foreach (string CurrentProduct in BuiltProducts) { for (int CurrentTry = 0; CurrentTry < 5; ++CurrentTry) { try { string DestinationFilename = FTPRoot + FTPDirectory + Path.GetFileName(CurrentProduct); // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(DestinationFilename); request.Method = WebRequestMethods.Ftp.UploadFile; request.UseBinary = true; request.EnableSsl = true; request.Timeout = 1800; request.Credentials = new NetworkCredential(FTPUsername, FTPPassword); // Copy the contents of the file to the request stream. byte [] fileContents = File.ReadAllBytes(CurrentProduct); request.ContentLength = fileContents.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Close(); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); if (response.StatusCode == FtpStatusCode.CommandOK || response.StatusCode == FtpStatusCode.ClosingData || response.StatusCode == FtpStatusCode.FileActionOK || response.StatusCode == FtpStatusCode.ClosingControl) { Log("Successfully uploaded file " + CurrentProduct + " to " + DestinationFilename); } else { Log("Failed to upload file " + CurrentProduct + " to " + DestinationFilename + " with error code " + response.StatusCode + " and exit message " + response.ExitMessage); bFailedAtLeastOnce = true; } response.Close(); } catch (System.Net.WebException WebExcept) { LogWarning("Web exception thrown. Depending on your server the file may not have uploaded, but some servers don't behave well with FtpWebRequest. " + WebExcept.ToString()); continue; } catch (System.Net.ProtocolViolationException ProtoExcept) { LogWarning("ProtocolViolationException thrown. Depending on your server the file may not have uploaded, but some servers don't behave well with FtpWebRequest. " + ProtoExcept.ToString()); continue; } break; } } if (!bFailedAtLeastOnce) { Log("All files were successfully uploaded!"); } else { Log("Some files were not successfully uploaded. Please check the logs to see what went wrong."); } } 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); }