2019-12-26 23:01:54 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-07-23 15:25:57 -04:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2020-12-21 23:07:37 -04:00
|
|
|
using EpicGames.Core;
|
2019-07-23 15:25:57 -04:00
|
|
|
using UnrealBuildTool;
|
|
|
|
|
|
|
|
|
|
namespace AutomationTool
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[Help("Opens the specified project.")]
|
2020-09-10 15:39:00 -04:00
|
|
|
[Help("project=<QAGame>", "Project to open. Will search current path and paths in ueprojectdirs. If omitted will open vanilla UnrealEditor")]
|
2019-07-23 15:25:57 -04:00
|
|
|
class OpenEditor: BuildCommand
|
|
|
|
|
{
|
|
|
|
|
// exposed as a property so projects can derive and set this directly
|
|
|
|
|
public string ProjectName { get; set; }
|
|
|
|
|
|
|
|
|
|
public OpenEditor()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ExitCode Execute()
|
|
|
|
|
{
|
2020-09-10 15:39:00 -04:00
|
|
|
string EditorPath = HostPlatform.Current.GetUE4ExePath("UnrealEditor");
|
2019-07-23 15:25:57 -04:00
|
|
|
|
|
|
|
|
string EditorArgs = "";
|
|
|
|
|
|
|
|
|
|
ProjectName = ParseParamValue("project", ProjectName);
|
|
|
|
|
|
|
|
|
|
if (!String.IsNullOrEmpty(ProjectName))
|
|
|
|
|
{
|
|
|
|
|
FileReference ProjectFile = ProjectUtils.FindProjectFileFromName(ProjectName);
|
|
|
|
|
|
|
|
|
|
if (ProjectFile == null)
|
|
|
|
|
{
|
|
|
|
|
throw new AutomationException("Unable to find uproject file for {0}", ProjectName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditorArgs = ProjectFile.FullName;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 14:57:28 -04:00
|
|
|
IEnumerable<string> ParamList = this.Params
|
|
|
|
|
.Where(P => P.StartsWith("project=", StringComparison.OrdinalIgnoreCase) == false)
|
|
|
|
|
.Select(P => "-" + P);
|
|
|
|
|
|
|
|
|
|
bool bLaunched = RunUntrackedProcess(EditorPath, string.Join(" ", ParamList));
|
|
|
|
|
|
|
|
|
|
return bLaunched ? ExitCode.Success : ExitCode.Error_UATLaunchFailure;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected bool RunUntrackedProcess(string BinaryPath, string Args)
|
|
|
|
|
{
|
|
|
|
|
LogInformation("Running {0} {1}", BinaryPath, Args);
|
|
|
|
|
|
|
|
|
|
var NewProcess = HostPlatform.Current.CreateProcess(BinaryPath);
|
|
|
|
|
var Result = new ProcessResult(BinaryPath, NewProcess, false, false);
|
|
|
|
|
System.Diagnostics.Process Proc = Result.ProcessObject;
|
|
|
|
|
|
|
|
|
|
Proc.StartInfo.FileName = BinaryPath;
|
|
|
|
|
Proc.StartInfo.Arguments = string.IsNullOrEmpty(Args) ? "" : Args;
|
|
|
|
|
Proc.StartInfo.UseShellExecute = false;
|
|
|
|
|
return Proc.Start();
|
2019-07-23 15:25:57 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|