public IAppInstall InstallApplication(UnrealAppConfig AppConfig) { if (AppConfig.Build is StagedBuild) { return(InstallStagedBuild(AppConfig, AppConfig.Build as StagedBuild)); } EditorBuild EditorBuild = AppConfig.Build as EditorBuild; if (EditorBuild == null) { throw new AutomationException("Invalid build type!"); } MacAppInstall MacApp = new MacAppInstall(AppConfig.Name, this); MacApp.WorkingDirectory = Path.GetFullPath(EditorBuild.ExecutablePath); MacApp.CommandArguments = AppConfig.CommandLine; MacApp.RunOptions = RunOptions; // Mac always forces this to stop logs and other artifacts going to different places MacApp.CommandArguments += string.Format(" -userdir={0}", UserDir); MacApp.ArtifactPath = Path.Combine(UserDir, @"Saved"); // now turn the Foo.app into Foo/Content/MacOS/Foo string AppPath = Path.GetDirectoryName(EditorBuild.ExecutablePath); string FileName = Path.GetFileNameWithoutExtension(EditorBuild.ExecutablePath); MacApp.ExecutablePath = Path.Combine(EditorBuild.ExecutablePath, "Contents", "MacOS", FileName); return(MacApp); }
public IAppInstance Run(IAppInstall App) { MacAppInstall MacInstall = App as MacAppInstall; if (MacInstall == null) { throw new AutomationException("Invalid install type!"); } IProcessResult Result = null; lock (Globals.MainLock) { string NewWorkingDir = string.IsNullOrEmpty(MacInstall.WorkingDirectory) ? MacInstall.LocalPath : MacInstall.WorkingDirectory; string OldWD = Environment.CurrentDirectory; Environment.CurrentDirectory = NewWorkingDir; Log.Info("Launching {0} on {1}", App.Name, ToString()); Log.Verbose("\t{0}", MacInstall.CommandArguments); Result = CommandUtils.Run(MacInstall.ExecutablePath, MacInstall.CommandArguments, Options: MacInstall.RunOptions); if (Result.HasExited && Result.ExitCode != 0) { throw new AutomationException("Failed to launch {0}. Error {1}", MacInstall.ExecutablePath, Result.ExitCode); } Environment.CurrentDirectory = OldWD; } return(new MacAppInstance(MacInstall, Result)); }
public MacAppInstance(MacAppInstall InInstall, IProcessResult InProcess) : base(InProcess, InInstall.CommandArguments) { Install = InInstall; }
protected IAppInstall InstallStagedBuild(UnrealAppConfig AppConfig, StagedBuild InBuild) { bool SkipDeploy = Globals.Params.ParseParam("SkipDeploy"); string BuildPath = InBuild.BuildPath; // Must be on our volume to run string BuildVolume = GetVolumeName(BuildPath); string LocalRoot = GetVolumeName(Environment.CurrentDirectory); if (BuildVolume.Equals(LocalRoot, StringComparison.OrdinalIgnoreCase) == false) { string SubDir = string.IsNullOrEmpty(AppConfig.Sandbox) ? AppConfig.ProjectName : AppConfig.Sandbox; string DestPath = Path.Combine(this.TempDir, SubDir, AppConfig.ProcessType.ToString()); if (!SkipDeploy) { Log.Info("Installing {0} to {1}", AppConfig.Name, ToString()); Log.Verbose("\tCopying {0} to {1}", BuildPath, DestPath); Gauntlet.Utils.SystemHelpers.CopyDirectory(BuildPath, DestPath, Utils.SystemHelpers.CopyOptions.Mirror); } else { Log.Info("Skipping install of {0} (-skipdeploy)", BuildPath); } Utils.SystemHelpers.MarkDirectoryForCleanup(DestPath); BuildPath = DestPath; } MacAppInstall MacApp = new MacAppInstall(AppConfig.Name, this); MacApp.LocalPath = BuildPath; MacApp.WorkingDirectory = MacApp.LocalPath; MacApp.RunOptions = RunOptions; // Set commandline replace any InstallPath arguments with the path we use MacApp.CommandArguments = Regex.Replace(AppConfig.CommandLine, @"\$\(InstallPath\)", BuildPath, RegexOptions.IgnoreCase); // Mac always forces this to stop logs and other artifacts going to different places // Mac always forces this to stop logs and other artifacts going to different places MacApp.CommandArguments += string.Format(" -userdir={0}", UserDir); MacApp.ArtifactPath = Path.Combine(UserDir, @"Saved"); // temp - Mac doesn't support -userdir? //MacApp.ArtifactPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Logs", AppConfig.ProjectName); // clear artifact path if (Directory.Exists(MacApp.ArtifactPath)) { try { Directory.Delete(MacApp.ArtifactPath, true); } catch (Exception Ex) { Log.Warning("Failed to delete {0}. {1}", MacApp.ArtifactPath, Ex.Message); } } if (Path.IsPathRooted(InBuild.ExecutablePath)) { MacApp.ExecutablePath = InBuild.ExecutablePath; } else { // TODO - this check should be at a higher level.... string BinaryPath = Path.Combine(BuildPath, InBuild.ExecutablePath); // check for a local newer executable if (Globals.Params.ParseParam("dev") && AppConfig.ProcessType.UsesEditor() == false) { string LocalBinary = Path.Combine(Environment.CurrentDirectory, InBuild.ExecutablePath); bool LocalFileExists = File.Exists(LocalBinary); bool LocalFileNewer = LocalFileExists && File.GetLastWriteTime(LocalBinary) > File.GetLastWriteTime(BinaryPath); Log.Verbose("Checking for newer binary at {0}", LocalBinary); Log.Verbose("LocalFile exists: {0}. Newer: {1}", LocalFileExists, LocalFileNewer); if (LocalFileExists && LocalFileNewer) { // need to -basedir to have our exe load content from the path MacApp.CommandArguments += string.Format(" -basedir={0}", Path.GetDirectoryName(BinaryPath)); BinaryPath = LocalBinary; } } MacApp.ExecutablePath = BinaryPath; } // now turn the Foo.app into Foo/Content/MacOS/Foo string AppPath = Path.GetDirectoryName(MacApp.ExecutablePath); string FileName = Path.GetFileNameWithoutExtension(MacApp.ExecutablePath); MacApp.ExecutablePath = Path.Combine(MacApp.ExecutablePath, "Contents", "MacOS", FileName); return(MacApp); }