3using System.Runtime.CompilerServices;
5using System.Collections;
6using System.Collections.Generic;
7using Nuke.Common.Utilities.Collections;
9using Nuke.Common.Utilities;
11using System.Reflection;
13using System.Text.RegularExpressions;
15using System.Runtime.InteropServices;
30 var executingAssemblyFolder = (AbsolutePath) Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
32 if (Directory.Exists(executingAssemblyFolder /
"Templates"))
34 return executingAssemblyFolder;
37 var nukeUnrealAssemblyFolder = (AbsolutePath) Path.GetDirectoryName(typeof(
BuildCommon).Assembly.Location);
38 if (Directory.Exists(nukeUnrealAssemblyFolder /
"Templates"))
40 return nukeUnrealAssemblyFolder;
43 var contentFolder = nukeUnrealAssemblyFolder
44 .DescendantsAndSelf(p => p.Parent, d => Path.GetPathRoot(d) != d)
45 .FirstOrDefault(p => Directory.Exists(p /
"content"));
47 Assert.NotNullOrEmpty(contentFolder,
"Couldn't find contents folder of Nuke.Unreal.");
48 return contentFolder!;
58 => !path.Name.StartsWith(
'.')
59 && !path.Name.StartsWith(
"Nuke.")
60 && path.Name !=
"Intermediate"
61 && path.Name !=
"Binaries"
62 && path.Name !=
"ThirdParty"
63 && path.Name !=
"Saved";
70 public static IEnumerable<AbsolutePath>
SubTreeProject(
this AbsolutePath origin, Func<AbsolutePath, bool>? filter =
null) =>
71 origin.SubTree(sd => filter?.Invoke(sd) ??
true && sd.IsProjectFolder());
76 public static bool LookAroundFor(Func<string, bool> predicate, out AbsolutePath? result) =>
86 public static AbsolutePath?
GetOwner(
this AbsolutePath path,
string ownerPattern)
88 .DescendantsAndSelf(d => d.Parent, d => Path.GetPathRoot(d) != d)
89 .SelectMany(p => p.GlobFiles(ownerPattern))
97 .DescendantsAndSelf(d => d.Parent, d => Path.GetPathRoot(d) != d)
98 .SelectMany(p => p.GlobFiles(
"*.uplugin"))
106 .DescendantsAndSelf(d => d.Parent, d => Path.GetPathRoot(d) != d)
107 .SelectMany(p => p.GlobFiles(
"*.uproject"))
115 .DescendantsAndSelf(d => d.Parent, d => Path.GetPathRoot(d) != d)
116 .SelectMany(p => p.GlobFiles(
"*.Build.cs"))
123 public static AbsolutePath
Shorten(
this AbsolutePath longPath,
bool allPlatforms =
false)
125 var result = longPath;
126 if (allPlatforms || RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
128 Log.Information(
"Creating short symlink on {0} for {1}", longPath.GetRoot(), longPath);
129 result = longPath.GetRoot() / Guid.NewGuid().ToString(
"N")[..16];
130 result.Links(longPath);
Extra build related utilities not necessarily associated with Unreal tasks.
static ? AbsolutePath GetOwningPlugin(this AbsolutePath path)
Get the Unreal plugin owning the given subfolder.
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.
static IEnumerable< AbsolutePath > SubTreeProject(this AbsolutePath origin, Func< AbsolutePath, bool >? filter=null)
Gives a recursive folder tree filtering out known intermediate folders.
static bool IsProjectFolder(this AbsolutePath path)
Returns false on known folders which are intermediate results of Engine operations,...
static ? AbsolutePath GetOwningModule(this AbsolutePath path)
Get the Unreal module owning the given subfolder.
static ? AbsolutePath GetOwner(this AbsolutePath path, string ownerPattern)
Get the owning parent folder of an arbitrarily deep subfolder based on wildcard filtering of files in...
static ? AbsolutePath GetOwningProject(this AbsolutePath path)
Get the Unreal project owning the given subfolder.
static AbsolutePath GetContentsFolder()
Get the contents folder Nuke.Unreal is shipped with. This is usually contained in the local nuget ins...
static AbsolutePath Shorten(this AbsolutePath longPath, bool allPlatforms=false)
Create a short path symlink for input path to work around the 260 character path length limitation cu...