You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3105904 on 2016/08/30 by Ben.Marsh PR #2691: Copy .map-file to staging & cleanup (Contributed by projectgheist) Change 3105974 on 2016/08/30 by Ben.Marsh PR #2748: [Bug-Fix] UGS - Ensure older events do not trample newer ones (Contributed by paulevans) Change 3106035 on 2016/08/30 by Ben.Marsh PR #2746: [Bug-Fix] UGS - Starting build colour was the same as disabled (Contributed by paulevans) Change 3106172 on 2016/08/30 by Ben.Marsh UAT: Do not default to submitting build products from BuildCookRun unless -submit is explicitly specified on the command line. #codreview Maciej.Mroz Change 3107642 on 2016/08/31 by Matthew.Griffin More Monolithic editor fixes Fixed IMPLEMENT_MODULE macros with incorrect module name Wrapped some usages of GIsHotReload in WITH_HOT_RELOAD Fixed NiagaraConstants so that they can be used in multiple modules Change 3107808 on 2016/08/31 by Matthew.Griffin Added Node to Compile UAT on Mac to catch any Mono failures which will run as part of monolithics aggregate Change 3111527 on 2016/09/02 by Matthew.Griffin Duplicating CL#3111524 from Release-4.13 stream Including Documentation/Extras in installed build Change 3117683 on 2016/09/08 by Ben.Marsh PR #2771: Fix compilation of C# projects on case-sensitive OSes (Contributed by slonopotamus) Change 3119707 on 2016/09/09 by Ben.Marsh UBT: Add more explicit methods for querying Visual C++ and Visual Studio installation directories. Now uses the same logic in the Visual Studio batch files. Change 3120824 on 2016/09/12 by Ben.Marsh UnrealGameSync: Add a project-wide option which can disable using the last code changelist for version files, and use the sync changelist instead. ("VersionToLastCodeChange" in the "[Options]" section). Update version to 1.80. Change 3120996 on 2016/09/12 by Ben.Marsh Core: Fix lines of output text from FMonitoredProcess being truncated at 512 characters, due to pipe buffer size. Accumulate incomplete lines and merge them together again instead. Also remove CR-LF pairs if they occur at the end of a line. #jira UE-35659 Change 3121353 on 2016/09/12 by Ben.Marsh Core: Manually enumerate and load dependent DLLs for modules by the editor, to work around limitations in the number of search paths checked by the Windows loader. We previously temporarily modified the PATH environment variable to provide this functionality, but are close to the OS limit for length of that string. This method should not have any such restrictions (though it will not work for circular dependencies). Change 3121996 on 2016/09/12 by Ben.Marsh Add support for Visual Studio 2017 (aka "15"; assuming consistent naming with other versions until final name is announced). * Compiler, STL implementation and CRT are binary compatible with VS2015 (see https://blogs.msdn.microsoft.com/vcblog/2016/08/24/c1417-features-and-stl-fixes-in-vs-15-preview-4/), so no new third-party libraries needed so far. WindowsPlatform.GetVisualStudioCompilerVersionName() returns "2015" as a result. * Default compiler for compiling and generating project files is still VS 2015 for now. Pass -2017 on the command line to GenerateProjectFiles.bat to generate VS2017 projects. Projects generated for VS2017 will use the 2017 compiler by default. * Visual Studio source code accessor can talk to VS 2017 instances. * Added a VS2017 configuration for UnrealVS, and added precompiled vsix package. * Switched GetVSComnTools to check the SOFTWARE\Microsoft\VisualStudio\SxS\VS7 registry key rather than the individual product install registry key. "15" doesn't seem to have it's own "InstallDir" key, but this system seems to work for all versions of Visual Studio (including previous releases of VS Express). * Removed ATL dependency from VisualStudioSourceCodeAccessor. It's not installed with VS by default any more, and is only used for a couple of smart pointer classes. Tested running the editor and packaging TP_Flying for Win64. Packaging from the editor still defaults to using the 2015 compiler, so ConfigureToolchain() needs to be overriden from the .target.cs file if multiple Visual Studio versions are installed. Change 3123144 on 2016/09/13 by Ben.Marsh BuildGraph: Fix exception due to mismatched argument lists. Change 3123160 on 2016/09/13 by Ben.Marsh Linux: Make PLATFORM_SUPPORTS_JEMALLOC a globally defined macro rather than just defined by the jemalloc module. Core supplies a default value for this macro which is inconsistent unless your module has an explicit dependency on jemalloc. Change 3123211 on 2016/09/13 by Ben.Marsh UBT: Fix exception writing a version manifest if the output directory does not exist. Change 3125300 on 2016/09/14 by Ben.Marsh UnrealVS: Few fixes to single-file compile command. * All documents are now saved before compile starts. * Now gives a useful error when trying to compile non-cpp files, rather than falling back to the invalid default command handler. * Trying to do a single-file compile while an existing build is running now prompts to stop it, rather than falling back to the default command handler (which gives a "Invalid command" message for makefile projects) Change 3125437 on 2016/09/14 by Ben.Marsh UnrealVS: Update version number to 1.43 in order to prevent installer from bailing unless existing version is uninstalled first. [CL 3126342 by Ben Marsh in Main branch]
348 lines
10 KiB
C#
348 lines
10 KiB
C#
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Reflection;
|
|
using AutomationTool;
|
|
using UnrealBuildTool;
|
|
|
|
[Help(@"Builds/Cooks/Runs a project.
|
|
|
|
For non-uprojects project targets are discovered by compiling target rule files found in the project folder.
|
|
If -map is not specified, the command looks for DefaultMap entry in the project's DefaultEngine.ini and if not found, in BaseEngine.ini.
|
|
If no DefaultMap can be found, the command falls back to /Engine/Maps/Entry.")]
|
|
[Help("project=Path", @"Project path (required), i.e: -project=QAGame, -project=Samples\BlackJack\BlackJack.uproject, -project=D:\Projects\MyProject.uproject")]
|
|
[Help("destsample", "Destination Sample name")]
|
|
[Help("foreigndest", "Foreign Destination")]
|
|
[Help(typeof(ProjectParams))]
|
|
[Help(typeof(UE4Build))]
|
|
[Help(typeof(CodeSign))]
|
|
public class BuildCookRun : BuildCommand
|
|
{
|
|
#region BaseCommand interface
|
|
|
|
public override void ExecuteBuild()
|
|
{
|
|
// allow BCR functions to call UBT functions (especially .ini parsing)
|
|
UnrealBuildTool.UnrealBuildTool.SetupUBTFromUAT();
|
|
|
|
// these need to be done first
|
|
var bForeign = ParseParam("foreign");
|
|
var bForeignCode = ParseParam("foreigncode");
|
|
if (bForeign)
|
|
{
|
|
MakeForeignSample();
|
|
}
|
|
else if (bForeignCode)
|
|
{
|
|
MakeForeignCodeSample();
|
|
}
|
|
var Params = SetupParams();
|
|
|
|
DoBuildCookRun(Params);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Setup
|
|
|
|
protected ProjectParams SetupParams()
|
|
{
|
|
Log("Setting up ProjectParams for {0}", ProjectPath);
|
|
|
|
var Params = new ProjectParams
|
|
(
|
|
Command: this,
|
|
// Shared
|
|
RawProjectPath: ProjectPath
|
|
);
|
|
|
|
var DirectoriesToCook = ParseParamValue("cookdir");
|
|
if (!String.IsNullOrEmpty(DirectoriesToCook))
|
|
{
|
|
Params.DirectoriesToCook = new ParamList<string>(DirectoriesToCook.Split('+'));
|
|
}
|
|
|
|
var InternationalizationPreset = ParseParamValue("i18npreset");
|
|
if (!String.IsNullOrEmpty(InternationalizationPreset))
|
|
{
|
|
Params.InternationalizationPreset = InternationalizationPreset;
|
|
}
|
|
|
|
var CulturesToCook = ParseParamValue("cookcultures");
|
|
if (!String.IsNullOrEmpty(CulturesToCook))
|
|
{
|
|
Params.CulturesToCook = new ParamList<string>(CulturesToCook.Split('+'));
|
|
}
|
|
|
|
if (Params.DedicatedServer)
|
|
{
|
|
foreach (var ServerPlatformInstance in Params.ServerTargetPlatformInstances)
|
|
{
|
|
ServerPlatformInstance.PlatformSetupParams(ref Params);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var ClientPlatformInstance in Params.ClientTargetPlatformInstances)
|
|
{
|
|
ClientPlatformInstance.PlatformSetupParams(ref Params);
|
|
}
|
|
}
|
|
|
|
Params.ValidateAndLog();
|
|
return Params;
|
|
}
|
|
|
|
/// <summary>
|
|
/// In case the command line specified multiple map names with a '+', selects the first map from the list.
|
|
/// </summary>
|
|
/// <param name="Maps">Map(s) specified in the commandline.</param>
|
|
/// <returns>First map or an empty string.</returns>
|
|
private static string GetFirstMap(string Maps)
|
|
{
|
|
string Map = String.Empty;
|
|
if (!String.IsNullOrEmpty(Maps))
|
|
{
|
|
var AllMaps = Maps.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
|
|
if (!IsNullOrEmpty(AllMaps))
|
|
{
|
|
Map = AllMaps[0];
|
|
}
|
|
}
|
|
return Map;
|
|
}
|
|
|
|
private string GetTargetName(Type TargetRulesType)
|
|
{
|
|
const string TargetPostfix = "Target";
|
|
var Name = TargetRulesType.Name;
|
|
if (Name.EndsWith(TargetPostfix, StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
Name = Name.Substring(0, Name.Length - TargetPostfix.Length);
|
|
}
|
|
return Name;
|
|
}
|
|
|
|
private string GetDefaultMap(ProjectParams Params)
|
|
{
|
|
const string EngineEntryMap = "/Engine/Maps/Entry";
|
|
Log("Trying to find DefaultMap in ini files");
|
|
string DefaultMap = null;
|
|
var ProjectFolder = GetDirectoryName(Params.RawProjectPath.FullName);
|
|
var DefaultGameEngineConfig = CombinePaths(ProjectFolder, "Config", "DefaultEngine.ini");
|
|
if (FileExists(DefaultGameEngineConfig))
|
|
{
|
|
Log("Looking for DefaultMap in {0}", DefaultGameEngineConfig);
|
|
DefaultMap = GetDefaultMapFromIni(DefaultGameEngineConfig, Params.DedicatedServer);
|
|
if (DefaultMap == null && Params.DedicatedServer)
|
|
{
|
|
DefaultMap = GetDefaultMapFromIni(DefaultGameEngineConfig, false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var BaseEngineConfig = CombinePaths(CmdEnv.LocalRoot, "Config", "BaseEngine.ini");
|
|
if (FileExists(BaseEngineConfig))
|
|
{
|
|
Log("Looking for DefaultMap in {0}", BaseEngineConfig);
|
|
DefaultMap = GetDefaultMapFromIni(BaseEngineConfig, Params.DedicatedServer);
|
|
if (DefaultMap == null && Params.DedicatedServer)
|
|
{
|
|
DefaultMap = GetDefaultMapFromIni(BaseEngineConfig, false);
|
|
}
|
|
}
|
|
}
|
|
// We check for null here becase null == not found
|
|
if (DefaultMap == null)
|
|
{
|
|
Log("No DefaultMap found, assuming: {0}", EngineEntryMap);
|
|
DefaultMap = EngineEntryMap;
|
|
}
|
|
else
|
|
{
|
|
Log("Found DefaultMap={0}", DefaultMap);
|
|
}
|
|
return DefaultMap;
|
|
}
|
|
|
|
private string GetDefaultMapFromIni(string IniFilename, bool DedicatedServer)
|
|
{
|
|
var IniLines = ReadAllLines(IniFilename);
|
|
string DefaultMap = null;
|
|
|
|
string ConfigKeyStr = "GameDefaultMap";
|
|
if (DedicatedServer)
|
|
{
|
|
ConfigKeyStr = "ServerDefaultMap";
|
|
}
|
|
|
|
foreach (var Line in IniLines)
|
|
{
|
|
if (Line.StartsWith(ConfigKeyStr, StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
var DefaultMapPair = Line.Split('=');
|
|
DefaultMap = DefaultMapPair[1].Trim();
|
|
}
|
|
if (DefaultMap != null)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return DefaultMap;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BuildCookRun
|
|
|
|
protected void DoBuildCookRun(ProjectParams Params)
|
|
{
|
|
const ProjectBuildTargets ClientTargets = ProjectBuildTargets.ClientCooked | ProjectBuildTargets.ServerCooked;
|
|
bool bGenerateNativeScripts = Params.RunAssetNativization;
|
|
int WorkingCL = -1;
|
|
if (P4Enabled && GlobalCommandLine.Submit && AllowSubmit)
|
|
{
|
|
WorkingCL = P4.CreateChange(P4Env.Client, String.Format("{0} build from changelist {1}", Params.ShortProjectName, P4Env.Changelist));
|
|
}
|
|
|
|
Project.Build(this, Params, WorkingCL, bGenerateNativeScripts ? (ProjectBuildTargets.All & ~ClientTargets) : ProjectBuildTargets.All);
|
|
Project.Cook(Params);
|
|
if (bGenerateNativeScripts)
|
|
{
|
|
Project.Build(this, Params, WorkingCL, ClientTargets);
|
|
}
|
|
Project.CopyBuildToStagingDirectory(Params);
|
|
Project.Package(Params, WorkingCL);
|
|
Project.Archive(Params);
|
|
Project.Deploy(Params);
|
|
PrintRunTime();
|
|
Project.Run(Params);
|
|
|
|
// Check everything in!
|
|
if (WorkingCL != -1)
|
|
{
|
|
int SubmittedCL;
|
|
P4.Submit(WorkingCL, out SubmittedCL, true, true);
|
|
}
|
|
}
|
|
|
|
private void MakeForeignSample()
|
|
{
|
|
string Sample = "BlankProject";
|
|
var DestSample = ParseParamValue("DestSample", "CopiedBlankProject");
|
|
var Src = CombinePaths(CmdEnv.LocalRoot, "Samples", "SampleGames", Sample);
|
|
if (!DirectoryExists(Src))
|
|
{
|
|
throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
|
|
}
|
|
|
|
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
|
|
Log("Make a foreign sample {0} -> {1}", Src, Dest);
|
|
|
|
CloneDirectory(Src, Dest);
|
|
|
|
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
|
|
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));
|
|
|
|
RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));
|
|
|
|
var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
|
|
var Ini = new VersionFileUpdater(IniFile);
|
|
Ini.ReplaceLine("GameName=", DestSample);
|
|
Ini.Commit();
|
|
}
|
|
|
|
private void MakeForeignCodeSample()
|
|
{
|
|
string Sample = "PlatformerGame";
|
|
string DestSample = "PlatformerGame";
|
|
var Src = CombinePaths(CmdEnv.LocalRoot, Sample);
|
|
if (!DirectoryExists(Src))
|
|
{
|
|
throw new AutomationException("Can't find source directory to make foreign sample {0}.", Src);
|
|
}
|
|
|
|
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
|
|
Log("Make a foreign sample {0} -> {1}", Src, Dest);
|
|
|
|
CloneDirectory(Src, Dest);
|
|
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Intermediate"));
|
|
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Saved"));
|
|
DeleteDirectory_NoExceptions(CombinePaths(Dest, "Plugins", "FootIK", "Intermediate"));
|
|
|
|
//RenameFile(CombinePaths(Dest, Sample + ".uproject"), CombinePaths(Dest, DestSample + ".uproject"));
|
|
|
|
var IniFile = CombinePaths(Dest, "Config", "DefaultEngine.ini");
|
|
var Ini = new VersionFileUpdater(IniFile);
|
|
Ini.ReplaceLine("GameName=", DestSample);
|
|
Ini.Commit();
|
|
}
|
|
|
|
private FileReference ProjectFullPath;
|
|
public virtual FileReference ProjectPath
|
|
{
|
|
get
|
|
{
|
|
if (ProjectFullPath == null)
|
|
{
|
|
var bForeign = ParseParam("foreign");
|
|
var bForeignCode = ParseParam("foreigncode");
|
|
if (bForeign)
|
|
{
|
|
var DestSample = ParseParamValue("DestSample", "CopiedHoverShip");
|
|
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
|
|
ProjectFullPath = new FileReference(CombinePaths(Dest, DestSample + ".uproject"));
|
|
}
|
|
else if (bForeignCode)
|
|
{
|
|
var DestSample = ParseParamValue("DestSample", "PlatformerGame");
|
|
var Dest = ParseParamValue("ForeignDest", CombinePaths(@"C:\testue4\foreign\", DestSample + "_ _Dir"));
|
|
ProjectFullPath = new FileReference(CombinePaths(Dest, DestSample + ".uproject"));
|
|
}
|
|
else
|
|
{
|
|
var OriginalProjectName = ParseParamValue("project", "");
|
|
|
|
if (string.IsNullOrEmpty(OriginalProjectName))
|
|
{
|
|
throw new AutomationException("No project file specified. Use -project=<project>.");
|
|
}
|
|
|
|
var ProjectName = OriginalProjectName;
|
|
ProjectName = ProjectName.Trim(new char[] { '\"' });
|
|
if (ProjectName.IndexOfAny(new char[] { '\\', '/' }) < 0)
|
|
{
|
|
ProjectName = CombinePaths(CmdEnv.LocalRoot, ProjectName, ProjectName + ".uproject");
|
|
}
|
|
else if (!FileExists_NoExceptions(ProjectName))
|
|
{
|
|
ProjectName = CombinePaths(CmdEnv.LocalRoot, ProjectName);
|
|
}
|
|
if(FileExists_NoExceptions(ProjectName))
|
|
{
|
|
ProjectFullPath = new FileReference(ProjectName);
|
|
}
|
|
else
|
|
{
|
|
var Branch = new BranchInfo(new List<UnrealTargetPlatform> { UnrealBuildTool.BuildHostPlatform.Current.Platform });
|
|
var GameProj = Branch.FindGame(OriginalProjectName);
|
|
if (GameProj != null)
|
|
{
|
|
ProjectFullPath = GameProj.FilePath;
|
|
}
|
|
if (!FileExists_NoExceptions(ProjectFullPath.FullName))
|
|
{
|
|
throw new AutomationException("Could not find a project file {0}.", ProjectName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ProjectFullPath;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|