4using System.Collections.Generic;
6using System.Runtime.InteropServices;
7using Nuke.Common.Tooling;
12using Nuke.Cola.Tooling;
14using Nuke.Common.Utilities;
15using Newtonsoft.Json.Converters;
38 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
45 if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
49 (AbsolutePath)
@"/Users/Shared/Epic Games",
53 if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
58 (AbsolutePath)
@"/Users/Shared/Epic Games",
63 throw new Exception(
"Attempting to build on an unsupported platform");
71 MissingMemberHandling = MissingMemberHandling.Ignore,
72 DefaultValueHandling = DefaultValueHandling.Populate,
73 NullValueHandling = NullValueHandling.Include,
75 new StringEnumConverter(
false)
82 public static void WriteJson(
object input, AbsolutePath path)
84 var sb =
new StringBuilder();
85 var sw =
new StringWriter(sb);
87 using var jtw =
new JsonTextWriter(sw)
89 Formatting = Formatting.Indented,
94 var serializer =
new JsonSerializer()
96 NullValueHandling = NullValueHandling.Ignore,
97 Formatting = Formatting.Indented,
99 new StringEnumConverter(
false)
102 serializer.Serialize(jtw, input);
103 File.WriteAllText(path, sb.ToString());
116 public static AbsolutePath
GetEnginePath(
string engineAssociation,
bool ignoreCache =
false)
120 IUnrealLocator locator = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
124 Log.Debug(
"Looking for Unreal Engine installation {0}", engineAssociation);
127 Assert.NotNull(
EnginePathCache,
"Couldn't find Unreal Engine with that association");
143 => ~(compatibility - 1);
159 => (enginePath /
"Engine" /
"Build" /
"InstalledBuild.txt").FileExists();
176 public static bool IsSource(AbsolutePath enginePath)
199 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
202 if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
205 if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
208 throw new Exception(
"Attempting to build on an unsupported platform");
215 ofVersion.EnginePath /
"Engine" /
"Build" /
"BatchFiles" /
"Mac" /
"RunMono.sh";
221 var ubtPath = ofVersion.SemanticalVersion.Major >= 5
222 ? ofVersion.EnginePath /
"Engine" /
"Binaries" /
"DotNET" /
"UnrealBuildTool" /
"UnrealBuildTool.exe"
223 : ofVersion.EnginePath /
"Engine" /
"Binaries" /
"DotNET" /
"UnrealBuildTool.exe";
225 return ToolResolver.GetTool(ubtPath).WithSemanticLogging();
242 config?.Invoke(toolConfig);
244 arguments: $
"{toolConfig.Gather(ofVersion):nq}",
245 workingDirectory: ofVersion.
EnginePath /
"Engine" /
"Source",
268 var scriptExt = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
"bat" :
"sh";
269 return ToolResolver.GetTool(ofVersion.
EnginePath /
"Engine" /
"Build" /
"BatchFiles" / $
"RunUAT.{scriptExt}")
270 .WithSemanticLogging(filter: l =>
271 !(l.Contains(
"Reading chunk manifest") && l.Contains(
"which contains 0 entries"))
286 config?.Invoke(toolConfig);
288 arguments: $
"{toolConfig.Gather(ofVersion):nq}",
289 workingDirectory: ofVersion.
EnginePath /
"Engine" /
"Source",
313 (folder /
"Intermediate").ExistingDirectory()?.DeleteDirectory();
314 (folder /
"Binaries").ExistingDirectory()?.DeleteDirectory();
315 (folder /
"DerivedDataCache").ExistingDirectory()?.DeleteDirectory();
323 var configPath = projectFolder /
"Config" /
"DefaultGame.ini";
324 if (!File.Exists(configPath))
return "Fill in Copyright info...";
326 var crLine = File.ReadAllLines(configPath)
327 .FirstOrDefault(l => l.StartsWith(
"CopyrightNotice="));
329 if (
string.IsNullOrWhiteSpace(crLine))
return "Fill in Copyright info...";
331 var crEntry = crLine.Split(
'=', 2, StringSplitOptions.TrimEntries);
332 if (crEntry.Length < 2)
return "Fill in Copyright info...";
348 var ext = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
".exe" :
"";
349 var path = binaries / (name + ext);
351 if (!path.FileExists())
352 path = binaries / (
"Unreal" + name + ext);
354 Assert.FileExists(path, $
"Requested tool {name} doesn't exist.");
355 return ToolResolver.GetTool(path);
High level representation of an Unreal Engine version.
Version SemanticalVersion
Semantical version representation of the given Unreal Engine.
AbsolutePath EnginePath
Cached engine path.
An empty Unreal Locator implementation which doesn't know about installed instances,...
The main build class Unreal projects using Nuke.Unreal should inherit from. This class contains all b...
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
static Tool AutomationTool(UnrealBuild build, Action< UatConfig > config)
Prepare invocation for UAT with extra fluent-API configuration.
static bool IsSource(EngineVersion ofVersion)
Are we working with an engine built from source?
static Tool BuildTool(UnrealBuild build, Action< UbtConfig > config)
Prepare invocation for UBT with extra fluent-API configuration.
static void WriteJson(object input, AbsolutePath path)
Write data in JSON with Unreal conventions of JSON format.
static bool Is4(UnrealBuild build)
Are we working with UE4.
static bool IsSource(UnrealBuild build)
Are we working with an engine built from source?
static Tool AutomationTool(EngineVersion ofVersion)
Prepare invocation for UAT.
static Tool BuildTool(UnrealBuild build)
Prepare invocation for UBT.
static bool IsInstalled(UnrealBuild build)
Are we working with a vanilla engine most probably installed via the Marketplace?
static Tool BuildTool(EngineVersion ofVersion, Action< UbtConfig > config)
Prepare invocation for UBT with extra fluent-API configuration.
static AbsolutePath MacRunMono(EngineVersion ofVersion)
On Mac many Unreal tools need the Mono bootstrap.
static Tool GetTool(UnrealBuild build, string name)
Get a native binary tool from Engine/Binaries folder. Unreal tools written in C# or stored in other f...
static bool Is5(UnrealBuild build)
Are we working with UE5.
static void InvalidateEnginePathCache()
In the rare and unlikely case that the Engine location may have changed during one session.
static bool IsSource(AbsolutePath enginePath)
Is given path an engine built from source?
static string ReadCopyrightFromProject(AbsolutePath projectFolder)
Read copyright info from the project's DefaultGame.ini
static Tool BuildTool(EngineVersion ofVersion)
Prepare invocation for UBT.
static UnrealCompatibility AndLater(this UnrealCompatibility compatibility)
Create a compatibility flag mask which indicates that a feature is available un-broken in given and t...
static readonly JsonSerializerSettings JsonReadSettings
Common JsonSerializerSettings for Unreal conventions of JSON format.
static Tool AutomationTool(UnrealBuild build)
Prepare invocation for UAT.
static EngineVersion Version(UnrealBuild build)
Get high-level version of currently used Engine.
static UnrealPlatformFlag GetDefaultPlatform()
Get the current development platform Nuke.Unreal is ran on.
static bool IsInstalled(AbsolutePath enginePath)
Is given path a vanilla engine most probably installed via the Marketplace?
static ? AbsolutePath EnginePathCache
Once the Engine location is found for the current session, it ain't gonna move around,...
static bool IsInstalled(EngineVersion ofVersion)
Are we working with a vanilla engine most probably installed via the Marketplace?
static void ClearFolder(AbsolutePath folder)
Clear intermediate folders of Unreal from a given folder.
static readonly? HashSet< AbsolutePath > EngineSearchPaths
Frankly this is not really relevant anymore.
static AbsolutePath GetEnginePath(string engineAssociation, bool ignoreCache=false)
Get the Unreal Engine path based on an input association text. (version, GUID or absolute path)
static Tool AutomationTool(EngineVersion ofVersion, Action< UatConfig > config)
Prepare invocation for UAT with extra fluent-API configuration.
Common interface for locating Unreal Engine instances in different environments.
AbsolutePath? GetEngine(string name)
Get the path to an installed engine by its name or its absolute path.
UnrealPlatformFlag
Bit-field representation of Unreal platforms and platform-families.
UnrealCompatibility
A flag enum representation for checking the Unreal version compatibility of various features....