Nuke.Unreal
Build Unreal apps in Style.
Loading...
Searching...
No Matches
XRepoLibraryModuleGenerator.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5using Nuke.Cola;
6using Nuke.Cola.Tooling;
7using Nuke.Common.IO;
8using Nuke.Common.Utilities;
9using Nuke.Common.Utilities.Collections;
10
12
13public record XRepoLibraryModuleModel(
14 LibrarySpec Spec,
15 UnrealPlatform Platform,
16 string? Copyright,
17 SuffixRecord Suffix,
18 IEnumerable<XRepoLibraryRecord> Libraries,
19 bool HeaderOnly
20) : CommonModelBase(Spec.Name, Copyright);
21
23{
24 protected XRepoLibraryModuleModel? Model;
25
26 public void Generate(AbsolutePath templatesPath, AbsolutePath currentFolder, LibrarySpec spec, UnrealPlatform platform, IEnumerable<XRepoLibraryRecord> libraries, string? suffix)
27 {
28 var project = new UnrealProject(currentFolder);
29 Model = new(
30 Spec: spec,
31 Platform: platform,
32 Copyright: Unreal.ReadCopyrightFromProject(project.Folder!),
33 Suffix: new(suffix),
34 Libraries: libraries,
35 HeaderOnly: libraries.SelectMany(l => l.LibFiles.Concat(l.SysLibs)).IsEmpty()
36 );
37
38 var templateSubFolder = "XRepoLibraryModule";
39 if (!(templatesPath / templateSubFolder).DirectoryExists())
40 templatesPath = DefaultTemplateFolder;
41
42 var templateDir = templatesPath / templateSubFolder;
43 RenderFolder(templateDir, currentFolder, Model);
44 if (Model.HeaderOnly)
45 {
46 var redundantPlatformModuleFile = $"{spec.UnrealName}{Model.Suffix.Us}.{platform}.Build.cs";
47 (currentFolder / redundantPlatformModuleFile).DeleteFile();
48 }
49 }
50}
static void RenderFolder(AbsolutePath templateRoot, AbsolutePath destinationFolder, object model, AbsolutePath? currentFolder=null)
Render scriban templated scaffoldings and files to destination folder.
High level representation of common platforms supported by Unreal Engine (NDA ones excluded) and extr...
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
Definition Unreal.cs:24
static string ReadCopyrightFromProject(AbsolutePath projectFolder)
Read copyright info from the project's DefaultGame.ini
Definition Unreal.cs:321