2using System.Collections.Generic;
8using Nuke.Common.Utilities;
9using Nuke.Common.Utilities.Collections;
21public enum IniHierarchyLevel
35 public abstract partial class UnrealBuild : NukeBuild
40 protected T
Self<T>() where T : INukeBuild => (T)(
object)this;
45 protected T? SelfAs<T>() where T : class, INukeBuild => (
object)this as T;
47 protected override
void OnBuildInitialized()
49 base.OnBuildInitialized();
52 Log.Warning(
"This project is part of a perforce workspace.");
53 Log.Warning(
"Some files may be locked by P4 which this build may modify. This may result in file-system errors.");
63 Specify the target Unreal Engine version. It's used only
64 for the Switch target. Everything else should infer engine
65 version from the project file. Can be simple version name
66 like `5.5`, a GUID associated with engine location or an
67 absolute path to engine root.
74 [Parameter(
"Specify the output working directory for artifacts")]
75 public AbsolutePath? Output;
83 [Parameter(
"Set platform for running targets")]
86 [Parameter(
"The target configuration for building or packaging the project")]
89 [Parameter(
"The editor configuration to be used while building or packaging the project")]
92 [Parameter(
"The Unreal target type for building the project")]
117 .If(!ubtArgs.IsEmpty(), _ => _.
UbtArgs(ubtArgs.JoinSpace()));
128 if (_engineVersionCache ==
null)
131 Assert.NotNull(versionString,
"Unreal Engine version couldn't be determined");
132 _engineVersionCache =
new(versionString!);
134 return _engineVersionCache!;
150 Log.Information(
"Project name: {0}",
ProjectPath.NameWithoutExtension);
151 Log.Information(
"Unreal version: {0}", unrealVersion.VersionName);
152 Log.Information(
"Unreal full version: {0}", unrealVersion.VersionPatch);
154 Log.Information(
"Output folder: {0}",
GetOutput());
167 => Arguments.GetBlock(name)
172 .DoubleQuoteIfNeeded()
199 IniHierarchyLevel lowestLevel = IniHierarchyLevel.Base,
200 IniHierarchyLevel highestLevel = IniHierarchyLevel.Saved,
201 bool considerPlugins =
true,
202 IEnumerable<string>? extraConfigSubfolder =
null
205 extraConfigSubfolder = (extraConfigSubfolder ?? Enumerable.Empty<
string>())
206 .Append(Platform.ToString());
208 IReadOnlyCollection<AbsolutePath> GlobIni(AbsolutePath folder)
210 return folder.GlobFiles($
"{shortName}.ini", $
"*{shortName}.ini");
213 void MergeInis(AbsolutePath folder,
ConfigIni result)
215 if (folder.DirectoryExists())
216 foreach (var iniFile
in GlobIni(folder))
220 result.
Merge(currIni);
224 void GatherInis(AbsolutePath configFolder,
ConfigIni result)
226 MergeInis(configFolder, resultIni);
227 foreach (var folder
in extraConfigSubfolder.Select(s => configFolder / s))
229 if (folder.DirectoryExists())
230 MergeInis(folder, resultIni);
234 if (lowestLevel <= IniHierarchyLevel.Base && highestLevel >= IniHierarchyLevel.Base)
237 var baseIni =
ConfigIni.
Parse(File.ReadAllText(configFolder /
"Base.ini"));
239 resultIni.
Merge(baseIni);
241 GatherInis(configFolder, resultIni);
244 if (lowestLevel <= IniHierarchyLevel.Default && highestLevel >= IniHierarchyLevel.Default)
247 GatherInis(configFolder, resultIni);
249 if (lowestLevel <= IniHierarchyLevel.Default && highestLevel >= IniHierarchyLevel.Default && considerPlugins)
251 foreach (var pluginConfigFolder
in (
ProjectFolder /
"Plugins").GlobDirectories(
"**/Config"))
253 GatherInis(pluginConfigFolder, resultIni);
256 if (lowestLevel <= IniHierarchyLevel.Saved && highestLevel >= IniHierarchyLevel.Saved)
259 GatherInis(configFolder, resultIni);
High level representation of an Unreal Engine version.
The root class representing Unreal INI configuration.
void Merge(ConfigIni from)
Compose another ConfigIni instance into this one, overriding existing values and adding new ones.
static ? ConfigIni Parse(string? input)
Parse an Unreal configuration text into a ConfigIni.
The main build class Unreal projects using Nuke.Unreal should inherit from. This class contains all b...
AbsolutePath ProjectFolder
Path to folder containing the .project file.
virtual IEnumerable< string > GetArgumentBlock(string name="")
Get optionally named argument block (section after -->) with contextual data substituted....
virtual AbsolutePath ProjectPath
ProjectDescriptor ProjectDescriptor
"Immutable" C# representation of the .uproject contents
AbsolutePath UnrealEnginePath
Path to the root of the associated Unreal Engine installation/source.
virtual UbtConfig UbtGlobal(UbtConfig _)
UBT arguments to be applied globally for all UBT invocations. Override this function in your main bui...
virtual bool IsPerforce
Does this project reside in a Perforce workspace?
virtual AbsolutePath GetOutput()
Get an output folder where the targets should store their artifacts. Override this function in your m...
EngineVersion GetEngineVersionFromProject()
Utility function to get the proper Engine version associated with current project....
virtual ? string UnrealVersion
Most targets read the desired Unreal version from the project file.
ConfigIni ReadIniHierarchy(string shortName, IniHierarchyLevel lowestLevel=IniHierarchyLevel.Base, IniHierarchyLevel highestLevel=IniHierarchyLevel.Saved, bool considerPlugins=true, IEnumerable< string >? extraConfigSubfolder=null)
Read INI configuration emulating the same hierarchy of importance as Unreal Engine also does.
virtual void PrintInfo()
Print some rudimentary information onto console about this project and it's environment....
virtual UatConfig UatGlobal(UatConfig _)
UAT arguments to be applied globally for all UAT invocations. Override this function in your main bui...
T Self< T >()
Shortcut to casting this to another class.
Build configurations UBT supports.
The regular target types UBT supports.
static readonly UnrealTargetType Game
Can act as both client and server.
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
static UnrealPlatformFlag GetDefaultPlatform()
Get the current development platform Nuke.Unreal is ran on.
static AbsolutePath GetEnginePath(string engineAssociation, bool ignoreCache=false)
Get the Unreal Engine path based on an input association text. (version, GUID or absolute path)