2using Newtonsoft.Json.Linq;
5using Nuke.Common.Utilities;
13 public abstract partial class UnrealBuild : NukeBuild
15 private AbsolutePath? _projectCache =
null;
30 if (_projectCache !=
null)
return _projectCache;
32 var projectCachePath = TemporaryDirectory /
"UProjectFile.txt";
33 if (projectCachePath.FileExists())
35 _projectCache = AbsolutePath.Create(projectCachePath.ReadAllText().Trim());
37 if (!projectCachePath.FileExists() || !_projectCache.FileExists())
39 Log.Information(
"Detecting Unreal project");
42 projectCachePath.WriteAllText(candidate);
43 _projectCache = candidate;
46 Assert.NotNull(_projectCache,
"This build doesn't seem to be an Unreal project.");
47 Log.Information($
"Unreal project: {_projectCache}");
48 return _projectCache!;
56 public AbsolutePath PluginsFolder =>
ProjectFolder /
"Plugins";
70 get => _projectDescriptor
72 protected set => _projectDescriptor = value;
75 private bool? _isPerforceCache =
null;
83 if (_isPerforceCache !=
null)
return _isPerforceCache ??
false;
85 var isP4CachePath = TemporaryDirectory /
"IsP4.txt";
86 if (isP4CachePath.FileExists())
87 _isPerforceCache =
bool.Parse(isP4CachePath.ReadAllText().Trim());
90 Log.Information(
"Detecting Perforce workspace");
92 f => Path.GetFileName(f).EqualsOrdinalIgnoreCase(
"p4config.txt"),
95 isP4CachePath.WriteAllText(isP4.ToString());
96 _isPerforceCache = isP4;
98 Log.Information(_isPerforceCache ??
false
99 ?
"Project is managed by Perforce"
100 :
"Project is not in a Perforce Workspace"
102 return _isPerforceCache ??
false;
Extra build related utilities not necessarily associated with Unreal tasks.
static bool LookAroundFor(Func< string, bool > predicate, out AbsolutePath? result)
Look for something in subtree of a folder or in parent folders based on a predicate.
AbsolutePath ProjectFolder
Path to folder containing the .project file.
virtual AbsolutePath ProjectPath
string ProjectName
Short name of the project.
ProjectDescriptor ProjectDescriptor
"Immutable" C# representation of the .uproject contents
virtual bool IsPerforce
Does this project reside in a Perforce workspace?
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
static readonly JsonSerializerSettings JsonReadSettings
Common JsonSerializerSettings for Unreal conventions of JSON format.