Nuke.Unreal
Build Unreal apps in Style.
Loading...
Searching...
No Matches
UbtConfig.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Threading.Tasks;
5
6namespace Nuke.Unreal.Tools;
7
8/// <summary>
9/// Unreal Build Tool defines the Unreal project structure and provides unified source
10/// building utilities over multiple platforms
11/// </summary>
13{
14 /// <summary>
15 /// Specify Project file without `-Project`
16 /// </summary>
17 /// <param name="project"></param>
18 /// <param name="withKey">use `-project` key to specify target project</param>
19 /// <returns></returns>
20 public UbtConfig Project(string project, bool withKey = false)
21 {
22 if (!project.EndsWith(".uproject", true, null))
23 {
24 throw new ArgumentException("Project file path specified is not a *.uproject");
25 }
26 if (withKey)
27 {
28 AppendArgument(new("-project", project, Meta: new(AllowMultiple: true)));
29 }
30 else
31 {
32 AppendArgument(project);
33 }
34 return this;
35 }
36
37 /// <summary>
38 /// Build with Game target
39 /// </summary>
40 /// <param name="present"></param>
41 /// <returns></returns>
42 public UbtConfig Game(bool present = true)
43 {
44 if (present)
45 {
46 AppendArgument(new UnrealToolArgument("-game"));
47 }
48 return this;
49 }
50
51
52 /// <summary>
53 /// Build with Engine target
54 /// </summary>
55 /// <param name="present"></param>
56 /// <returns></returns>
57 public UbtConfig Engine(bool present = true)
58 {
59 if (present)
60 {
61 AppendArgument(new UnrealToolArgument("-engine"));
62 }
63 return this;
64 }
65
66 public UbtConfig Target(string name, UnrealPlatform platform, IEnumerable<UnrealConfig> config)
67 {
68 AppendArgument($"-Target={name} {platform} {string.Join('+', config)}", new(IsRawText: true));
69 return this;
70 }
71
72 public UbtConfig Targets(params object[] target) => Targets(target.AsEnumerable());
73 public UbtConfig Targets(IEnumerable<object> target)
74 {
75 AppendArgument(string.Join('+', target), new(IsRawText: true));
76 return this;
77 }
78
79 public UbtConfig TargetPlatforms(params object[] platform) => TargetPlatforms(platform.AsEnumerable());
80 public UbtConfig TargetPlatforms(IEnumerable<object> platform)
81 {
82 AppendArgument(string.Join('+', platform), new(IsRawText: true));
83 return this;
84 }
85
86 public UbtConfig Configurations(params object[] config) => Configurations(config.AsEnumerable());
87 public UbtConfig Configurations(IEnumerable<object> config)
88 {
89 AppendArgument(string.Join('+', config), new(IsRawText: true));
90 return this;
91 }
92}
Unreal Build Tool defines the Unreal project structure and provides unified source building utilities...
Unreal Build Tool defines the Unreal project structure and provides unified source building utilities...
Definition UbtConfig.cs:13
UbtConfig Game(bool present=true)
Build with Game target.
Definition UbtConfig.cs:42
UbtConfig Project(string project, bool withKey=false)
Specify Project file without -Project
Definition UbtConfig.cs:20
UbtConfig Engine(bool present=true)
Build with Engine target.
Definition UbtConfig.cs:57
High level representation of common platforms supported by Unreal Engine (NDA ones excluded) and extr...
partial record class UnrealToolArgument(string Name, string? Value=null, char Setter='=', UnrealToolArgumentMeta? Meta=null)
Argument for an Unreal tool.