5using Newtonsoft.Json.Linq;
7using Nuke.Common.Tooling;
8using System.ComponentModel;
10using System.Text.RegularExpressions;
12using System.Collections.Generic;
15using Nuke.Common.Utilities;
19[TypeConverter(typeof(TypeConverter<LibraryType>))]
25 Value = nameof(Header),
26 TemplateSubfolder =
"HeaderLibrary"
31 Value = nameof(CMake),
32 TemplateSubfolder =
"CMakeLibrary"
37 Value = nameof(XRepo),
38 TemplateSubfolder =
"XRepoLibrary",
39 ParseSpec = XRepoLibrary.ParseSpec
42 public required
string TemplateSubfolder { init;
get; }
43 public Func<string, LibrarySpec> ParseSpec {
get;
private set; } = s =>
new LibrarySpec(s, s);
46public record
class LibrarySpec(
49 string? Version =
null,
50 string? Provider =
null,
51 string? Options =
null,
52 string? Features = null
54 public string UnrealName => Name
60public record
class SuffixRecord(string? Text, string? Us, string? Dot)
62 public SuffixRecord(
string? suffix) : this(suffix, suffix.PrependNonEmpty(
"_"), suffix.PrependNonEmpty(
".")) {}
65public record
class LibraryModel(
70) : CommonModelBase(Spec.Name, Copyright);
74 protected LibraryModel? Model;
76 public void Generate(
IUnrealBuild build, AbsolutePath templatesPath, AbsolutePath currentFolder,
string fullSpec,
LibraryType libraryType,
string? suffix)
79 var spec = libraryType.ParseSpec(fullSpec);
80 if (spec.Name.IsNullOrWhiteSpace())
82 throw new ArgumentException($
"Library name was empty. Using spec '{fullSpec}'");
91 if ((currentFolder / (spec.Name + Model.Suffix.Us)).DirectoryExists())
93 throw new InvalidOperationException($
"The library module folder of {spec.Name} already exists in the current folder.");
96 if(!(templatesPath / libraryType.TemplateSubfolder).DirectoryExists())
97 templatesPath = DefaultTemplateFolder;
99 var templateDir = templatesPath / libraryType.TemplateSubfolder;
101 RenderFolder(templateDir, currentFolder, Model);
bool IsCompatibleWith(UnrealCompatibility compatibility)
Check if given compatibility mask applies to this version too.
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
static EngineVersion Version(IUnrealBuild build)
Get high-level version of currently used Engine.
static string ReadCopyrightFromProject(AbsolutePath projectFolder)
Read copyright info from the project's DefaultGame.ini
Base interface for build components which require an UnrealBuild main class.